feat(middleware): add BaggagePropagator for W3C Baggage#108
Conversation
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
PR SummaryMedium Risk Overview Updates Reviewed by Cursor Bugbot for commit 4a1dac1. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR adds W3C baggage propagation to Commanded's OpenTelemetry instrumentation. It introduces a new BaggagePropagator middleware that injects baggage from the OpenTelemetry context into command metadata, and extends the helpers to extract and propagate baggage alongside span context. ChangesW3C Baggage Propagation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/opentelemetry/helpers_test.exs (1)
87-87: 💤 Low valueConsider strengthening the link assertion for consistency.
The assertion
assert [%{}] = linksonly verifies that one link exists but doesn't check its trace_id or span_id. Other tests in this file use more specific assertions (e.g., line 32). Consider matching against the expected trace_id for consistency:- assert [%{}] = links + assert [%{trace_id: ^expected_trace_id}] = linksHowever, if the focus is purely on baggage presence, the current assertion may be intentional.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/opentelemetry/helpers_test.exs` at line 87, Replace the weak pattern match assert [%{}] = links with a stronger pattern that verifies the link's trace_id (and optionally span_id) against the test's expected value — e.g. assert [%{trace_id: ^expected_trace_id, span_id: _}] = links — so the test checks the actual linked trace id (or keep the original if the intent truly is only to assert presence of baggage).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/opentelemetry/helpers_test.exs`:
- Line 87: Replace the weak pattern match assert [%{}] = links with a stronger
pattern that verifies the link's trace_id (and optionally span_id) against the
test's expected value — e.g. assert [%{trace_id: ^expected_trace_id, span_id:
_}] = links — so the test checks the actual linked trace id (or keep the
original if the intent truly is only to assert presence of baggage).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7d5d35c6-eb87-4f9b-9efd-2ebfad109410
📒 Files selected for processing (4)
lib/commanded/middleware/baggage_propagator.exlib/commanded/opentelemetry/helpers.extest/middleware/baggage_propagator_test.exstest/opentelemetry/helpers_test.exs
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
9a2961f to
4a1dac1
Compare
TraceContextPropagator's name accurate.extract_propagated_ctx/1so a baggage-only metadata payload still produces a usable context, otherwise the new middleware would be a no-op for any handler not also receiving trace context.