From 131b6f3fe9f809f98d61aa4b20aad200da285d5f Mon Sep 17 00:00:00 2001 From: Dan Schultzer <1254724+danschultzer@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:03:01 -0800 Subject: [PATCH] Fix OpentelemetryPhoenix tests --- .../test/integration_test.exs | 3 +-- .../test/opentelemetry_phoenix_test.exs | 15 +++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/instrumentation/opentelemetry_phoenix/test/integration_test.exs b/instrumentation/opentelemetry_phoenix/test/integration_test.exs index dbc18179..eb95a99f 100644 --- a/instrumentation/opentelemetry_phoenix/test/integration_test.exs +++ b/instrumentation/opentelemetry_phoenix/test/integration_test.exs @@ -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 diff --git a/instrumentation/opentelemetry_phoenix/test/opentelemetry_phoenix_test.exs b/instrumentation/opentelemetry_phoenix/test/opentelemetry_phoenix_test.exs index 273b4d4c..4db0a596 100644 --- a/instrumentation/opentelemetry_phoenix/test/opentelemetry_phoenix_test.exs +++ b/instrumentation/opentelemetry_phoenix/test/opentelemetry_phoenix_test.exs @@ -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()}, @@ -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()}, @@ -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()}, @@ -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()}, @@ -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()},