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

rack instrumentation: continue trace from distributed trace digest only when distributed trace is present #4398

Merged

Conversation

anmarchenko
Copy link
Member

@anmarchenko anmarchenko commented Feb 18, 2025

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:

  class WelcomeControllerTest < ActionDispatch::IntegrationTest
    test "should get index" do
      get root_url
      assert_response :success
    end
  end

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:
image

After this patch:
image

@github-actions github-actions bot added integrations Involves tracing integrations tracing labels Feb 18, 2025
@datadog-datadog-prod-us1
Copy link
Contributor

datadog-datadog-prod-us1 bot commented Feb 18, 2025

Datadog Report

Branch report: anmarchenko/fix_rack_distributed_trace_propagation
Commit report: a5be9df
Test service: dd-trace-rb

✅ 0 Failed, 20595 Passed, 1371 Skipped, 3m 12.82s Total Time

@codecov-commenter
Copy link

codecov-commenter commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.71%. Comparing base (89e2082) to head (a5be9df).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4398      +/-   ##
==========================================
+ Coverage   97.70%   97.71%   +0.01%     
==========================================
  Files        1361     1361              
  Lines       83246    83246              
  Branches     4226     4227       +1     
==========================================
+ Hits        81336    81347      +11     
+ Misses       1910     1899      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pr-commenter
Copy link

pr-commenter bot commented Feb 18, 2025

Benchmarks

Benchmark execution time: 2025-02-18 12:41:22

Comparing candidate commit a5be9df in PR branch anmarchenko/fix_rack_distributed_trace_propagation with baseline commit 89e2082 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 31 metrics, 2 unstable metrics.

…entation when there are no distributed tracing headers
@DataDog DataDog deleted a comment from github-actions bot Feb 18, 2025
@anmarchenko anmarchenko marked this pull request as ready for review February 18, 2025 13:08
@anmarchenko anmarchenko requested a review from a team as a code owner February 18, 2025 13:08
@anmarchenko anmarchenko merged commit 5e20f11 into master Feb 18, 2025
276 checks passed
@anmarchenko anmarchenko deleted the anmarchenko/fix_rack_distributed_trace_propagation branch February 18, 2025 15:57
@github-actions github-actions bot added this to the 2.11.0 milestone Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrations Involves tracing integrations tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants