📌 Description
src/tracing/hooks.ts provides traceDbQuery, traceRedisCommand, traceStellarRpc, and traceWebhookDispatch, but no helper traces SSE fan-out. Meanwhile src/streams/sseEmitter.ts carries a correlationId on the update event but does not propagate trace context into the emitted SSE frames, so the trace chain breaks at the SSE boundary. Add a traceSseDispatch() helper and include the correlation/trace id in the SSE event so consumers can correlate.
💡 Why it matters: SSE delivery is currently a tracing blind spot, breaking end-to-end request correlation.
🧩 Requirements and context
- Add
traceSseDispatch() to src/tracing/hooks.ts wrapping the fan-out with subscriber-count and stream-id attributes.
- Include the correlation/trace id as a field/comment line in emitted SSE frames in
src/streams/sseEmitter.ts.
- Keep cardinality bounded (no per-subscriber spans by default).
- Ensure the span closes even when a subscriber write throws.
- Document the SSE trace-propagation contract.
Non-functional requirements
- Must be secure, tested, and documented.
- Should be efficient and easy to review.
🛠️ Suggested execution
1. Fork the repo and create a branch
git checkout -b sse-tracing
2. Implement changes
- Write/modify the relevant source:
src/tracing/hooks.ts, src/streams/sseEmitter.ts
- Write comprehensive tests:
tests/tracing/hooks.test.ts, tests/routes/streams-sse.test.ts
- Add documentation: inline TSDoc + README tracing section
- Include TSDoc doc comments on
traceSseDispatch
- Validate security assumptions: trace ids exposed to clients are non-sensitive
3. Test and commit
- Cover edge cases: subscriber write error, zero subscribers, span closure
- Include test output and security notes in the PR description.
Example commit message
feat(tracing): add SSE fan-out span and propagate correlation id into SSE events
✅ Acceptance criteria
🔒 Security notes
Only expose non-sensitive correlation/trace identifiers in client-visible SSE frames; never embed internal tokens.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
src/tracing/hooks.tsprovidestraceDbQuery,traceRedisCommand,traceStellarRpc, andtraceWebhookDispatch, but no helper traces SSE fan-out. Meanwhilesrc/streams/sseEmitter.tscarries acorrelationIdon the update event but does not propagate trace context into the emitted SSE frames, so the trace chain breaks at the SSE boundary. Add atraceSseDispatch()helper and include the correlation/trace id in the SSE event so consumers can correlate.🧩 Requirements and context
traceSseDispatch()tosrc/tracing/hooks.tswrapping the fan-out with subscriber-count and stream-id attributes.src/streams/sseEmitter.ts.Non-functional requirements
🛠️ Suggested execution
1. Fork the repo and create a branch
2. Implement changes
src/tracing/hooks.ts,src/streams/sseEmitter.tstests/tracing/hooks.test.ts,tests/routes/streams-sse.test.tstraceSseDispatch3. Test and commit
npm testExample commit message
✅ Acceptance criteria
traceSseDispatch()exists and is used in the emitter🔒 Security notes
Only expose non-sensitive correlation/trace identifiers in client-visible SSE frames; never embed internal tokens.
📋 Guidelines