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: Fixed undici/fetch instrumentation to properly assign the parent-id portion of the traceparent header on outgoing requests to the active http external span id #2951

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

bizob2828
Copy link
Member

Description

See details in #2950 as to why. This PR adds more tests to the relevant places that inject traceparent to ensure the parts are the expected values.

Related Issues

Closes #2950

…-id portion of the `traceparent` header on outgoing requests to the active http external span id
Comment on lines 139 to +140
createExternalSegment({ shim, request, segment })
addDTHeaders({ transaction, config, request })
Copy link
Contributor

Choose a reason for hiding this comment

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

So there's some side effects in these function such that ordering of their invocation matters in order to get the correct parent id attached to the new request?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. in createExternalSegment we create the segment and set it as active, then assign the outgoing w3c headers. Before we were setting outgoing w3c headers so it was on the parent span of the undici/fetch request. The versioned test proves this, if you swap the order the test fails

Copy link

codecov bot commented Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.30%. Comparing base (acfe953) to head (8cce46c).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2951      +/-   ##
==========================================
- Coverage   97.35%   97.30%   -0.05%     
==========================================
  Files         317      317              
  Lines       48648    48688      +40     
==========================================
+ Hits        47360    47378      +18     
- Misses       1288     1310      +22     
Flag Coverage Δ
integration-tests-cjs-18.x 72.33% <100.00%> (-0.03%) ⬇️
integration-tests-cjs-20.x 72.33% <100.00%> (-0.03%) ⬇️
integration-tests-cjs-22.x 72.55% <100.00%> (-0.03%) ⬇️
integration-tests-esm-18.x 49.96% <0.00%> (-0.01%) ⬇️
integration-tests-esm-20.x 49.97% <0.00%> (-0.01%) ⬇️
integration-tests-esm-22.x 50.02% <0.00%> (-0.01%) ⬇️
unit-tests-18.x 89.02% <100.00%> (-0.04%) ⬇️
unit-tests-20.x 89.02% <100.00%> (-0.04%) ⬇️
unit-tests-22.x 89.03% <100.00%> (-0.04%) ⬇️
versioned-tests-18.x 79.57% <100.00%> (-0.17%) ⬇️
versioned-tests-20.x 79.58% <100.00%> (-0.17%) ⬇️
versioned-tests-22.x 79.59% <100.00%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@bizob2828 bizob2828 merged commit bc714cf into newrelic:main Feb 13, 2025
28 of 29 checks passed
@bizob2828 bizob2828 deleted the fix-undici-dt-headers branch February 13, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done: Issues recently completed
Development

Successfully merging this pull request may close these issues.

traceparent has incorrect parent id when using undici/fetch
2 participants