Repository navigation
Description
Context
This issue implements the roadmap item 'Request Tracing and Correlation IDs' for the api domain. It is sourced from the consolidated roadmap under π‘ Medium Priority β Near-term (v1.5.0 β v1.8.0) and targets milestone v1.7.0.
Primary detail section: Request Tracing and Correlation IDs
Goal
Deliver the scoped changes for Request Tracing and Correlation IDs in src/api/ and complete the linked detail section in a release-ready state for v1.7.0.
Detailed Scope
Request Tracing and Correlation IDs
Priority: Medium
Target Version: v1.7.0
All inbound requests must carry or receive a X-Correlation-ID header that propagates through the entire call stack (API β AQL β storage β cache) and appears in all log lines and error responses.
Implementation Notes:
[x]AddTracingMiddlewareinsrc/api/tracing_middleware.cpp; generate UUID v4 ifX-Correlation-IDabsent; inject into thread-localRequestContext. (Implemented βTracingMiddleware::processRequest()usesboost::uuids::random_generatorper thread.)[x]ForwardRequestContext::correlationIdtoutils/logger.hlog macros via a structured field (correlation_id). (Implemented βutils::Logger::setTraceContext(corr_id)called inprocessRequest().)[x]Echo backX-Correlation-IDin all responses including errors and SSE streams (implemented inHttpServer::applyGovernanceHeaders()).[x]Export span data to OpenTelemetry collector via OTLP HTTP exporter (configurable endpoint inconfig/networking/). Implemented ininclude/api/otlp_exporter.h+src/api/otlp_exporter.cpp(async queue + libcurl POST, OTLP JSON format);TracingMiddlewareextended withfinishSpan()and optionalOtlpExporter*; configuration inconfig/networking/otlp.yaml.[x]Decision: retain proprietaryX-Correlation-IDas the primary correlation header; the OTLP exporter uses the correlation-ID value as the OTLPtraceId. A future W3Ctraceparentbridge can be added when SDK interoperability is required.
Performance Targets:
- Middleware overhead < 10 Β΅s per request (UUID generation + thread-local write).
- Zero correlation ID collision probability for β₯ 1 billion requests (UUID v4 guarantee).
Acceptance Criteria
- Add
TracingMiddlewareinsrc/api/tracing_middleware.cpp; generate UUID v4 ifX-Correlation-IDabsent; inject into thread-localRequestContext. (Implemented βTracingMiddleware::processRequest()usesboost::uuids::random_generatorper thread.) - Forward
RequestContext::correlationIdtoutils/logger.hlog macros via a structured field (correlation_id). (Implemented βutils::Logger::setTraceContext(corr_id)called inprocessRequest().) - Echo back
X-Correlation-IDin all responses including errors and SSE streams (implemented inHttpServer::applyGovernanceHeaders()). - Export span data to OpenTelemetry collector via OTLP HTTP exporter (configurable endpoint in
config/networking/). Implemented ininclude/api/otlp_exporter.h+src/api/otlp_exporter.cpp(async queue + libcurl POST, OTLP JSON format);TracingMiddlewareextended withfinishSpan()and optionalOtlpExporter*; configuration inconfig/networking/otlp.yaml. - Decision: retain proprietary
X-Correlation-IDas the primary correlation header; the OTLP exporter uses the correlation-ID value as the OTLPtraceId. A future W3Ctraceparentbridge can be added when SDK interoperability is required. - Middleware overhead < 10 Β΅s per request (UUID generation + thread-local write).
- Zero correlation ID collision probability for β₯ 1 billion requests (UUID v4 guarantee).
Relationships
- Roadmap row: Add comprehensive healthcare strategy paper for German-speaking stakeholdersΒ #140 (π‘ Medium Priority β Near-term (v1.5.0 β v1.8.0))
- Depends on: none identified during generation.
- Part of: consolidated roadmap delivery tracking.
References
- src/ROADMAP.md
- src/api/FUTURE_ENHANCEMENTS.md#request-tracing-and-correlation-ids
- Source key: roadmap:140:api:v1.7.0:request-tracing-and-correlation-ids
Generated from the consolidated source roadmap. Keep the roadmap and issue in sync when scope changes.
Activity