Skip to content

Commit

Permalink
feat: allow to filter traces for router dispatch event in telemetry m…
Browse files Browse the repository at this point in the history
…odule
  • Loading branch information
scollon42 committed Feb 10, 2023
1 parent 2b207ef commit b31e91f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/spandex_phoenix/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ defmodule SpandexPhoenix.Telemetry do
end

@doc false
def handle_router_event([:phoenix, :router_dispatch, :start], _, meta, %{tracer: tracer, span_opts: opts}) do
if phx_controller?(meta) do
def handle_router_event([:phoenix, :router_dispatch, :start], _, meta, %{tracer: tracer, span_opts: opts} = config) do
if phx_controller?(meta) and trace?(meta.conn, config) do
opts_with_resource = Keyword.put(opts, :resource, "#{meta.plug}.#{meta.plug_opts}")
tracer.start_span("phx.router_dispatch", opts_with_resource)
end
end

def handle_router_event([:phoenix, :router_dispatch, :stop], _, meta, %{tracer: tracer}) do
if phx_controller?(meta) do
def handle_router_event([:phoenix, :router_dispatch, :stop], _, meta, %{tracer: tracer} = config) do
if phx_controller?(meta) and trace?(meta.conn, config) do
tracer.finish_span()
end
end
Expand Down

0 comments on commit b31e91f

Please sign in to comment.