Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super issue reproduction #151

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ Add `open_telemetry_decorator` to your list of dependencies in `mix.exs`. We inc
```elixir
def deps do
[
{:opentelemetry, "~> 1.4"},
{:opentelemetry_exporter, "~> 1.7"},
{:opentelemetry, "~> 1.5"},
{:opentelemetry_exporter, "~> 1.8"},
{:open_telemetry_decorator, "~> 1.5"}
]
end
```

Then follow the directions for the exporter of your choice to send traces to to zipkin, honeycomb, etc.
Then follow the directions for the exporter of your choice to send traces to zipkin, honeycomb, etc.
https://github.com/open-telemetry/opentelemetry-erlang/tree/main/apps/opentelemetry_zipkin

### Honeycomb Example
Expand Down Expand Up @@ -78,7 +78,7 @@ defmodule MyApp.Worker do
def do_work(arg1, arg2) do
O11y.set_attributes(arg1: arg1, arg2: arg2)
# ...doing work
Attributes.set_attribute(:output, "something")
O11y.set_attribute(:output, "something")
end
end
```
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
"makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
"o11y": {:hex, :o11y, "0.2.9", "604ca6b51fb3edfec2e791486f5fd10096c021a4c3dffad65b95e1119740c6a9", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:opentelemetry_api, "~> 1.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "642bed8a46c9529abc8dd6a781b2b1694708fb4aaf0eab2f1ec436a840131d26"},
"o11y": {:hex, :o11y, "0.2.10", "bce4ab17881c4fd0bb4d7a2c8aa78273693a5f036d8f94eeb1fc6af61c750f4d", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:opentelemetry_api, "~> 1.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "75e3f6e8905c02b921a66836857060203e7e5bf4a98e09cd7d0e9bbde07db1f9"},
"opentelemetry": {:hex, :opentelemetry, "1.5.0", "7dda6551edfc3050ea4b0b40c0d2570423d6372b97e9c60793263ef62c53c3c2", [:rebar3], [{:opentelemetry_api, "~> 1.4", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}], "hexpm", "cdf4f51d17b592fc592b9a75f86a6f808c23044ba7cf7b9534debbcc5c23b0ee"},
"opentelemetry_api": {:hex, :opentelemetry_api, "1.4.0", "63ca1742f92f00059298f478048dfb826f4b20d49534493d6919a0db39b6db04", [:mix, :rebar3], [], "hexpm", "3dfbbfaa2c2ed3121c5c483162836c4f9027def469c41578af5ef32589fcfc58"},
"opentelemetry_exporter": {:hex, :opentelemetry_exporter, "1.8.0", "5d546123230771ef4174e37bedfd77e3374913304cd6ea3ca82a2add49cd5d56", [:rebar3], [{:grpcbox, ">= 0.0.0", [hex: :grpcbox, repo: "hexpm", optional: false]}, {:opentelemetry, "~> 1.5.0", [hex: :opentelemetry, repo: "hexpm", optional: false]}, {:opentelemetry_api, "~> 1.4.0", [hex: :opentelemetry_api, repo: "hexpm", optional: false]}, {:tls_certificate_check, "~> 1.18", [hex: :tls_certificate_check, repo: "hexpm", optional: false]}], "hexpm", "a1f9f271f8d3b02b81462a6bfef7075fd8457fdb06adff5d2537df5e2264d9af"},
Expand Down
45 changes: 45 additions & 0 deletions test/open_telemetry_decorator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,51 @@
def with_pid, do: :ok
end

defmodule BehaviorExample do
defmodule VCS do
@type sha :: binary()
@callback push(sha()) :: :ok
end

defmodule Git do
defmacro __using__(_opts) do
quote do
use OpenTelemetryDecorator

@behaviour VCS

@decorate with_span("Git.push")
def push(sha) do
O11y.set_attributes(vcs: :git, git_sha: sha)
:ok
end

defoverridable VCS
end
end
end

defmodule Github do
use Git
use OpenTelemetryDecorator

@decorate with_span("Github.push")
def push(sha) do
O11y.set_attributes(host: :github, github_sha: sha)
super(sha)
end
end
end

test "traces when super is called in a decorated function" do

Check failure on line 133 in test/open_telemetry_decorator_test.exs

View workflow job for this annotation

GitHub Actions / Elixir 1.14.3 on OTP 26.0-rc1

test with_span traces when super is called in a decorated function (OpenTelemetryDecoratorTest)
BehaviorExample.Github.push("abc123")

git_span = assert_span("Git.push") |> dbg()
assert %{"vcs" => :git, "git_sha" => "abc123"} = git_span.attributes
github_span = assert_span("Github.push") |> dbg()
assert %{"vcs" => :git, "git_sha" => "abc123", "host" => :github, "github_sha" => "abc123"} = github_span.attributes
end

test "pids" do
expected_pid = inspect(self())

Expand Down
Loading