Add X-Request-ID header to member publisher messages#268
Conversation
|
Warning Review limit reached
More reviews will be available in 53 minutes and 32 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughAdds NATS request-id header propagation to canonical and frontdoor member publishers and tests that verify the header; introduces sustained-capacity helpers and a preflight validation that runs before NATS setup, updates the ChangesMember Publisher Request ID Headers
Sustained Capacity Preflight
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
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 |
The members-sustained (and members-capacity) generators mint a corrID via idgen.GenerateRequestID() but the canonical and frontdoor member publishers never put it on the NATS message. Backend services require the header: room-worker rejects canonical events with no X-Request-ID as a permanent error, and room-service requires it on the frontdoor request. Stamp corrID as the X-Request-ID header on both publish paths so requests are accepted and trace end-to-end, matching the daily scenario's pattern. https://claude.ai/code/session_014eeLP8ENEQxFhC4SjaAY27
…nfig Candidate accounts are single-use (once added they're room members and can't be re-added; baseline+pool is capped at MAX_ROOM_SIZE), so a sustained run can make at most rooms × floor(pool/usersPerAdd) publishes. The default invocation (rate=100, duration=60s, users-per-add=10 = 6000 ops) exceeded every preset's budget, so the run always aborted with ErrPoolsExhausted — members-medium ran ~50s before failing, smaller presets exhausted during warmup. - Add a preflight capacity guard (SustainableOps + ValidateSustainedCapacity) that fails fast with exit 2 before any NATS/store work, printing the achievable max --rate/--duration for the preset (or steering to a larger preset when it's too small to sustain any sensible run). - Right-size members-medium's candidate pool 500 -> 900 (baseline 100 + 900 = 1000 = MAX_ROOM_SIZE) so the documented default command completes with margin (9000-op budget vs 6000-op demand). - Update README preset table and the over-capacity guidance. https://claude.ai/code/session_014eeLP8ENEQxFhC4SjaAY27
700 rooms x baseline 10 x candidate pool 990 yields 69,300 add-member ops, enough to sustain rate=1000/60s (60,000 ops) at the default users-per-add=10. Pool stays capped at MAX_ROOM_SIZE; capacity scales via room count. https://claude.ai/code/session_014eeLP8ENEQxFhC4SjaAY27
Capacity mode grows each room to --target-size from its single-use pool and never sends a partial batch, so a room with pool P reaches at most baseline + floor(P/users-per-add)*users-per-add. ValidateCapacityTarget rejects an unreachable target before any NATS/store work, naming how many rooms fall short and the reachable ceiling, instead of silently under-filling rooms. https://claude.ai/code/session_014eeLP8ENEQxFhC4SjaAY27
f4afb27 to
785e8bd
Compare
Summary
Propagate correlation IDs as
X-Request-IDheaders in both canonical and frontdoor member publisher messages to enable end-to-end request tracing across the pipeline.Changes
PublishMsgwith anats.Msgthat includes theX-Request-IDheader set to thecorrIDparameter. Previously thecorrIDwas ignored.PublishMsgwith anats.Msgthat includes theX-Request-IDheader set to thecorrIDparameter. Previously usedPublishRequestwithout headers.TestCanonicalMemberPublisher_SetsRequestIDHeader: Verifies canonical publishes carry the correlation ID as theX-Request-IDheaderTestFrontdoorMemberPublisher_SetsRequestIDHeader: Verifies frontdoor publishes carry the correlation ID as theX-Request-IDheader"github.com/hmchangw/chat/pkg/natsutil"to both files to accessRequestIDHeaderconstantImplementation Details
Both publishers now construct a
nats.Msgwith headers before publishing, allowing the correlation ID to flow through downstream services (room-worker and room-service) that require or validate theX-Request-IDheader. This ensures request tracing is consistent across the entire member addition pipeline.https://claude.ai/code/session_014eeLP8ENEQxFhC4SjaAY27
Summary by CodeRabbit
Bug Fixes
New Features
Documentation
Tests