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

fix(w3c): ensure tracecontext headers take precedence over datadog #9254

Merged
merged 11 commits into from
May 22, 2024

Conversation

mabdinur
Copy link
Contributor

@mabdinur mabdinur commented May 13, 2024

Description

Ensures when trace headers with the same trace_id but different span_ids are received by an application the tracecontext headers are treated as the source of truth.

  • The traceparent header will be used to set the parent_id
  • If the conflicting trace information was extracted from datadog headers, the span_id from the datadog headers will be stored in the _dd.parent_id parent_id tag.
  • All other propagation styles are third class citizens. If they conflict with tracecontext headers their span_ids will be overwritten.

This behavior will be validated by the following system-tests: DataDog/system-tests#2385

Checklist

  • Change(s) are motivated and described in the PR description
  • Testing strategy is described if automated tests are not included in the PR
  • Risks are described (performance impact, potential for breakage, maintainability)
  • Change is maintainable (easy to change, telemetry, documentation)
  • Library release note guidelines are followed or label changelog/no-changelog is set
  • Documentation is included (in-code, generated user docs, public corp docs)
  • Backport labels are set (if applicable)
  • If this PR changes the public interface, I've notified @DataDog/apm-tees.

Reviewer Checklist

  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Description motivates each change
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Change is maintainable (easy to change, telemetry, documentation)
  • Release note makes sense to a user of the library
  • Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented May 13, 2024

Datadog Report

Branch report: munir/w3c-phase-3-take2
Commit report: 40c47e0
Test service: dd-trace-py

✅ 0 Failed, 141918 Passed, 29870 Skipped, 7h 44m 31.7s Total duration (1h 51m 29.09s time saved)
⌛ 1 Performance Regression

⌛ Performance Regressions vs Default Branch (1)

  • test_app_service_name - test_grpc.py 10.88s (+10.01s, +1148%) - Details

ddtrace/propagation/http.py Outdated Show resolved Hide resolved
@pr-commenter
Copy link

pr-commenter bot commented May 13, 2024

Benchmarks

Benchmark execution time: 2024-05-20 20:22:46

Comparing candidate commit 8f7eea9 in PR branch munir/w3c-phase-3-take2 with baseline commit c045d04 in branch main.

Found 0 performance improvements and 1 performance regressions! Performance is the same for 208 metrics, 9 unstable metrics.

scenario:httppropagationextract-datadog_tracecontext_tracestate_propagated_on_trace_id_match

  • 🟥 execution_time [+6.276µs; +6.483µs] or [+14.670%; +15.155%]

@mabdinur mabdinur marked this pull request as ready for review May 14, 2024 21:13
@mabdinur mabdinur requested a review from a team as a code owner May 14, 2024 21:13
@mabdinur mabdinur marked this pull request as draft May 14, 2024 21:46
@mabdinur mabdinur added the manual merge Do not automatically merge label May 17, 2024
@mabdinur mabdinur requested a review from ZStriker19 May 17, 2024 14:49
@mabdinur mabdinur marked this pull request as ready for review May 17, 2024 14:50
ddtrace/propagation/http.py Outdated Show resolved Hide resolved
@mabdinur mabdinur changed the title tracing(w3c): ensure tracecontext headers take precedence over datadog chore(w3c): ensure tracecontext headers take precedence over datadog May 17, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 17, 2024

Codecov Report

Attention: Patch coverage is 9.09091% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 10.28%. Comparing base (66b96e9) to head (40c47e0).
Report is 6 commits behind head on main.

Files Patch % Lines
ddtrace/propagation/http.py 10.00% 9 Missing ⚠️
ddtrace/internal/constants.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #9254       +/-   ##
===========================================
- Coverage   76.02%   10.28%   -65.75%     
===========================================
  Files        1294     1264       -30     
  Lines      122816   120999     -1817     
===========================================
- Hits        93370    12439    -80931     
- Misses      29446   108560    +79114     

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

@mabdinur mabdinur requested a review from a team as a code owner May 17, 2024 16:52
@mabdinur mabdinur requested a review from erikayasuda May 20, 2024 14:34
Copy link
Member

@brettlangdon brettlangdon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the point of the configuration value for the inject/extract styles to denote precedence order of headers to look at?

@brettlangdon
Copy link
Member

isn't the point of the configuration value for the inject/extract styles to denote precedence order of headers to look at?

we talked about this off GitHub. "yes", but there is an edge case where that behavior is not desired. this change is really a bug fix for a known edge case when things break.

@brettlangdon brettlangdon removed the manual merge Do not automatically merge label May 22, 2024
@brettlangdon brettlangdon changed the title chore(w3c): ensure tracecontext headers take precedence over datadog fix(w3c): ensure tracecontext headers take precedence over datadog May 22, 2024
@brettlangdon brettlangdon enabled auto-merge (squash) May 22, 2024 20:14
@brettlangdon
Copy link
Member

Even those this is a fix we are not going to backport it right now. There are other changes needed on intake to make this fix work properly. Waiting until 2.10.0 release will be acceptable for this. We can choose to backport this in the future once the intake pieces are ready.

@brettlangdon brettlangdon merged commit 0cd6898 into main May 22, 2024
186 of 191 checks passed
@brettlangdon brettlangdon deleted the munir/w3c-phase-3-take2 branch May 22, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants