Skip to content

Commit

Permalink
Fix OpentelemetryPhoenix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultzer committed Jan 8, 2025
1 parent b6c577b commit 131b6f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ if otp_vsn >= 27 do
}

on_exit(fn ->
:telemetry.list_handlers([])
|> Enum.each(fn h -> :telemetry.detach(h.id) end)
Enum.each(:telemetry.list_handlers([]), &:telemetry.detach(&1.id))
end)

adapters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ defmodule OpentelemetryPhoenixTest do
end

setup do
Application.ensure_all_started([:telemetry])
:otel_simple_processor.set_exporter(:otel_exporter_pid, self())

OpentelemetryPhoenix.setup(adapter: :cowboy2)

on_exit(fn ->
Application.stop(:telemetry)
Enum.each(:telemetry.list_handlers([]), &:telemetry.detach(&1.id))
end)

:ok
end

test "records spans for Phoenix LiveView mount" do
OpentelemetryPhoenix.setup(adapter: :cowboy2)

:telemetry.execute(
[:phoenix, :live_view, :mount, :start],
%{system_time: System.system_time()},
Expand All @@ -53,8 +52,6 @@ defmodule OpentelemetryPhoenixTest do
end

test "records spans for Phoenix LiveView handle_params" do
OpentelemetryPhoenix.setup(adapter: :cowboy2)

:telemetry.execute(
[:phoenix, :live_view, :handle_params, :start],
%{system_time: System.system_time()},
Expand All @@ -77,8 +74,6 @@ defmodule OpentelemetryPhoenixTest do
end

test "records spans for Phoenix LiveView handle_event" do
OpentelemetryPhoenix.setup(adapter: :cowboy2)

:telemetry.execute(
[:phoenix, :live_view, :handle_event, :start],
%{system_time: System.system_time()},
Expand All @@ -101,8 +96,6 @@ defmodule OpentelemetryPhoenixTest do
end

test "handles exception during Phoenix LiveView handle_params" do
OpentelemetryPhoenix.setup(adapter: :cowboy2)

:telemetry.execute(
[:phoenix, :live_view, :mount, :start],
%{system_time: System.system_time()},
Expand Down Expand Up @@ -160,8 +153,6 @@ defmodule OpentelemetryPhoenixTest do
end

test "handles exceptions during Phoenix LiveView handle_event" do
OpentelemetryPhoenix.setup(adapter: :cowboy2)

:telemetry.execute(
[:phoenix, :live_view, :handle_event, :start],
%{system_time: System.system_time()},
Expand Down

0 comments on commit 131b6f3

Please sign in to comment.