Skip to content

Commit

Permalink
fix: Differentiate telemetry handlers using endpoint_prefix so that w…
Browse files Browse the repository at this point in the history
…e can define multiple (#60)
  • Loading branch information
cheerfulstoic authored Oct 17, 2022
1 parent f77ee41 commit b61c252
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/spandex_phoenix/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,27 @@ defmodule SpandexPhoenix.Telemetry do
endpoint_prefix ++ [:stop]
]

:telemetry.attach_many("spandex-endpoint-telemetry", endpoint_events, &__MODULE__.handle_endpoint_event/4, opts)
handler_id_suffix = "#{Enum.join(endpoint_prefix, "-")}"

:telemetry.attach_many(
"spandex-endpoint-telemetry-#{handler_id_suffix}",
endpoint_events,
&__MODULE__.handle_endpoint_event/4,
opts
)

router_events = [
[:phoenix, :router_dispatch, :start],
[:phoenix, :router_dispatch, :stop],
[:phoenix, :router_dispatch, :exception]
]

:telemetry.attach_many("spandex-router-telemetry", router_events, &__MODULE__.handle_router_event/4, opts)
:telemetry.attach_many(
"spandex-router-telemetry-#{handler_id_suffix}",
router_events,
&__MODULE__.handle_router_event/4,
opts
)
end

@doc false
Expand Down

0 comments on commit b61c252

Please sign in to comment.