diff --git a/lib/prima_opentelemetry_ex/instrumentation/opentelemetry_ecto.ex b/lib/prima_opentelemetry_ex/instrumentation/opentelemetry_ecto.ex index 03d8487..b7405c3 100644 --- a/lib/prima_opentelemetry_ex/instrumentation/opentelemetry_ecto.ex +++ b/lib/prima_opentelemetry_ex/instrumentation/opentelemetry_ecto.ex @@ -10,15 +10,13 @@ defmodule PrimaOpentelemetryEx.Instrumentation.OpentelemetryEcto do :telemetry.attach( "repo-init-handler", [:ecto, :repo, :init], - &__MODULE__.instrument_repo/4, + fn _event, _measurements, metadata, _config -> + metadata + |> Map.fetch!(:opts) + |> Keyword.fetch!(:telemetry_prefix) + |> OpentelemetryEcto.setup() + end, %{} ) end - - def instrument_repo(_event, _measurements, metadata, _config) do - metadata - |> Map.fetch!(:opts) - |> Keyword.fetch!(:telemetry_prefix) - |> OpentelemetryEcto.setup() - end end