Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to filter traces for router dispatch event in telemetry module #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 trace?(meta.conn, config) and phx_controller?(meta) 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 trace?(meta.conn, config) and phx_controller?(meta) do
tracer.finish_span()
end
end
Expand Down