Fix consumer OTel trace isolation#4166
Conversation
Review: Fix consumer OTel trace isolation (#4166)Thanks for this — the fix is well-targeted and the intent is clear. Starting consumer spans as roots when no A few things worth considering: 1. Trace fragmentation / loss of correlation (design — medium)With no The usual OTel pattern for "break the parent but keep the breadcrumb" is to attach an 2.
|
7cc1266 to
5a4d2c4
Compare
|
Claude Code Review — PR 4166: Fix consumer OTel trace isolation Reviewed against the diff and the surrounding BrighterTracer / Reactor / Proactor flow. Overall this is a focused, well-reasoned fix for a real correctness problem (unrelated consumed messages sharing the long-lived pump trace). The helper extraction reads cleanly and stays in scope. What is good
Issue: asymmetric Activity.Current restoration on the propagated-context path Net effect: after processing a message that carries a TraceParent, Test coverage gaps (minor)
Nits
Style/conventions
Nice, targeted fix. Addressing the propagated-context asymmetry would make the behavior fully consistent across both paths. Generated with Claude Code |
5a4d2c4 to
ae65436
Compare
|
Code Review: Fix consumer OTel trace isolation Thanks for this — the fix is well-targeted and the reasoning in the PR description is sound. Consumer spans for messages without a propagated What is good
Design question — receive vs. process for the same message Was linking considered instead of (or in addition to) rooting — e.g. an OTel span link from the process span to the receive span (and/or to the pump span)? Links would keep each message its own trace root while preserving navigability. Not blocking, but worth a sentence in the ADR/PR if it was a deliberate trade-off. Asymmetry worth noting (pre-existing, not a regression) Test coverage
Overall this looks like a solid, well-reasoned fix with good guard-rail tests. The main thing I would like to understand is the receive-to-process correlation trade-off for no-traceparent messages. |
|
Let me know when you need a review? |
Associate consumer spans (receive and process) with the ambient message pump span via an OpenTelemetry ActivityLink instead of parent/child, per the messaging semantic conventions. The pump drives each consume iteration but is not its temporal parent, so a link keeps the spans correlated while allowing their durations to be measured independently. Applies to both the always-root receive/process spans and the producer-parented process span (which keeps its producer parent and also links the pump). Addresses review feedback on PR #4166.
|
Code Review — PR #4166: Fix consumer OTel trace isolation Thanks for this — the core change is well-motivated and the implementation is mostly clean. Forcing consumer spans to roots (with A few things to look at, one of which I think is a real defect. 🐛 Pump link is lost for producer-parented messages after the first loop iteration (likely bug) The restore mechanism relies on When an activity is started with an explicit
Net effect: for the propagated-context (push) path, only the first message in a pump lifetime gets linked to the pump; every subsequent message silently loses the link. The no- Suggested fix: have the producer-parented branch also capture the ambient pump and stamp the custom property so 🧪 Test coverage gap that hides the above
🔎 Minor
✅ Things that look correct
Overall: solid direction; I would just like the producer-parented loop case addressed (or explicitly accepted with a test + comment) before merge. |
Code Review — Fix consumer OTel trace isolation (#4166)Thanks for tackling this — the trace-pollution problem (unrelated consumed messages sharing one long-lived pump trace) is a real and worthwhile fix. Starting context-free consumer spans as roots while keeping a link back to the pump is the right shape and matches OTel messaging semantic conventions. The out-of-order I do see one substantive correctness gap and a couple of smaller points. 🐞 Producer-parented spans don't restore
|
There was a problem hiding this comment.
Code Health Improved
(1 files improve in Code Health)
Our agent can fix these. Install it.
Gates Passed
4 Quality Gates Passed
View Improvements
| File | Code Health Impact | Categories Improved |
|---|---|---|
| BrighterTracer.cs | 7.09 → 7.53 | Code Duplication, Overall Code Complexity |
Quality Gate Profile: Clean Code Collective
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
Review: Fix consumer OTel trace isolation (#4166)Thanks for tackling this — starting non-propagated consumer spans as roots (instead of letting them inherit the long-lived pump activity) is the right fix, and expressing the pump relationship as an 🔴 Producer-parented process spans don't record
|
|
Confirming the 🔴 "producer-parented spans don't restore
The reasoning gap is the model of Probing the exact two-propagated-message loop ( So pump correlation is retained on every iteration, not just the first. The (The minor note about test source registration is correct but pre-existing; the two-source registration is required here so the synthetic producer activity samples and writes a real |
Fixes consumer spans for messages that arrive without a propagated
TraceParent.Previously those spans inherited the long-lived pump activity, so unrelated consumed messages could share one trace. This starts those consumer spans as roots while preserving propagated message context when it exists.
Validated with the new regression test and the core observability test filter.