rack instrumentation: continue trace from distributed trace digest only when distributed trace is present #4398
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Currently Rack always tries to continue from distributed trace when distributed tracing is enabled, even when there is no distributed trace present.
It causes Rack to always start a new trace, which causes issues with tracing during rails integration tests: controller spans are never appended to a test trace.
Motivation:
A bug reported by Datadog Test Optimization customer: spans from rails instrumentation are not appearing in trace view with a test like that:
Change log entry
Yes. Fix: rails spans now appear in test trace view when using Datadog Test Optimization with ActionDispatch::IntegrationTest
How to test the change?
Tested using a reproducible case from customer: https://github.com/anmarchenko/test-datadog-ci
Before this parch:

After this patch:
