fix(tracing): make peer service finalization idempotent#9364
Conversation
Overall package sizeSelf size: 7.47 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.2 | 124.41 kB | 440.65 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
|
BenchmarksBenchmark execution time: 2026-07-21 11:20:16 Comparing candidate commit ea19d7d in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2322 metrics, 36 unstable metrics.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9364 +/- ##
========================================
Coverage 98.42% 98.42%
========================================
Files 938 938
Lines 126209 126212 +3
Branches 10735 10849 +114
========================================
+ Hits 124219 124222 +3
Misses 1990 1990
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 236933d494
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
236933d to
ce891eb
Compare
ce891eb to
cbdade2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3dc4c7b306
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The shared helper started the operation before registering its trace expectation and only inspected the first span of each payload. MongoDB connection traffic could therefore consume the payload containing the expected operation span, leaving the test to time out.
Delayed setup traces can carry the same peer-service tags as the operation under test, allowing the shared matcher to pass without observing that operation. Run each generator under a unique parent and match its child span instead. Generator throws and invalid return values can bypass assertion cleanup. Keep the whole operation inside the cleanup boundary so the original failure is not replaced by a leaked-expectation teardown error.
Peer-service spans can be nested below integration spans, so requiring a direct parent excluded valid operations. Match the generated trace to keep setup traffic isolated without constraining span depth.
Keeping the correlation parent open until the operation settled delayed trace export. Integrations that publish duplicate finish notifications could then recompute `_dd.peer.service.source` before the trace was sent.
Repeated finish notifications can reach an outbound span before an ancestor lets the trace flush. The second pass treats the computed peer service as preconfigured and rewrites its source to `peer.service`; an existing source now marks finalization. The peer-service assertion keeps its correlation parent open through completion and matches the integration component, so delayed setup traces and spans from another integration cannot satisfy it.
3dc4c7b to
ea19d7d
Compare
Summary
Peer-service checks now arm the agent expectation before starting the operation and match across every span in a payload. The previous order plus the
traces[0][0]assumption let MongoDB connection spans hide the expected operation span, causing the mongoose test to time out intermittently.