Skip to content

Commit

Permalink
change the default nested attribute joiner to . to better align with …
Browse files Browse the repository at this point in the history
…otlp
  • Loading branch information
marcdel committed May 4, 2023
1 parent b222b5f commit 42321ea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# General application configuration
import Config

# config :open_telemetry_decorator, attr_prefix: ""
config :open_telemetry_decorator, attr_prefix: ""
config :open_telemetry_decorator, attr_joiner: "."

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
Expand Down
2 changes: 1 addition & 1 deletion lib/open_telemetry_decorator/attributes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule OpenTelemetryDecorator.Attributes do
end

defp composite_name(keys) do
joiner = Application.get_env(:open_telemetry_decorator, :attr_joiner) || "_"
joiner = Application.get_env(:open_telemetry_decorator, :attr_joiner) || "."
Enum.join(keys, joiner)
end

Expand Down
6 changes: 6 additions & 0 deletions test/open_telemetry_decorator/attributes_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ defmodule OpenTelemetryDecorator.AttributesTest do
alias OpenTelemetryDecorator.Attributes

describe "take_attrs" do
setup do
prev = Application.get_env(:open_telemetry_decorator, :attr_joiner)
Application.put_env(:open_telemetry_decorator, :attr_joiner, "_")
on_exit(fn -> Application.put_env(:open_telemetry_decorator, :attr_joiner, prev) end)
end

test "handles flat attributes" do
assert Attributes.get([id: 1], [:id]) == [id: 1]
end
Expand Down
6 changes: 6 additions & 0 deletions test/open_telemetry_decorator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ defmodule OpenTelemetryDecoratorTest do
end

describe "trace" do
setup do
prev = Application.get_env(:open_telemetry_decorator, :attr_joiner)
Application.put_env(:open_telemetry_decorator, :attr_joiner, "_")
on_exit(fn -> Application.put_env(:open_telemetry_decorator, :attr_joiner, prev) end)
end

defmodule Example do
use OpenTelemetryDecorator

Expand Down

0 comments on commit 42321ea

Please sign in to comment.