Skip to content

Commit

Permalink
check trace context before starting a trace
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Lewis authored and GregMefford committed Nov 18, 2021
1 parent 451d18e commit 69aa47b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/spandex_phoenix/plug/start_trace.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ defmodule SpandexPhoenix.Plug.StartTrace do
tracer.continue_trace(opts[:span_name], span_context)

{:error, _} ->
tracer.start_trace(opts[:span_name])
# check to ensure we're not already in a trace
# before we start another trace
if {:error, :no_trace_context} == tracer.current_context() do
tracer.start_trace(opts[:span_name])
else
# start a span if we're already in a trace
tracer.start_span(opts[:span_name])
end
end

conn
Expand Down

0 comments on commit 69aa47b

Please sign in to comment.