Skip to content

Commit

Permalink
Merge pull request #4398 from DataDog/anmarchenko/fix_rack_distribute…
Browse files Browse the repository at this point in the history
…d_trace_propagation

rack instrumentation: continue trace from distributed trace digest only when distributed trace is present
  • Loading branch information
anmarchenko authored Feb 18, 2025
2 parents c6d1822 + a5be9df commit 5e20f11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/datadog/tracing/contrib/rack/middlewares.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def call(env)
# so that all spans will be added to the distributed trace.
if configuration[:distributed_tracing]
trace_digest = Contrib::HTTP.extract(env)
Tracing.continue_trace!(trace_digest)
Tracing.continue_trace!(trace_digest) if trace_digest
end

TraceProxyMiddleware.call(env, configuration) do
Expand Down
2 changes: 2 additions & 0 deletions spec/datadog/tracing/contrib/rack/distributed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@

shared_examples_for 'a Rack request without distributed tracing' do
it 'produces a non-distributed Rack trace' do
expect(Datadog::Tracing).not_to receive(:continue_trace!)

is_expected.to be_ok
expect(span).to_not be nil
expect(span.name).to eq('rack.request')
Expand Down

0 comments on commit 5e20f11

Please sign in to comment.