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 cfdaa03
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/spandex_phoenix/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ defmodule SpandexPhoenix.Telemetry do

@doc false
def handle_router_event([:phoenix, :router_dispatch, :start], _, meta, %{tracer: tracer, span_opts: opts}) do
if phx_controller?(meta) do
if phx_controller?(meta) and trace?(meta.conn, opts) 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, span_opts: opts}) do
if phx_controller?(meta) and trace?(meta.conn, opts) do
tracer.finish_span()
end
end
Expand Down

0 comments on commit cfdaa03

Please sign in to comment.