Skip to content

Request Tracing and Correlation IDsΒ #3971

Closed

Description

@makr-code

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] Add TracingMiddleware in src/api/tracing_middleware.cpp; generate UUID v4 if X-Correlation-ID absent; inject into thread-local RequestContext. (Implemented β€” TracingMiddleware::processRequest() uses boost::uuids::random_generator per thread.)
  • [x] Forward RequestContext::correlationId to utils/logger.h log macros via a structured field (correlation_id). (Implemented β€” utils::Logger::setTraceContext(corr_id) called in processRequest().)
  • [x] Echo back X-Correlation-ID in all responses including errors and SSE streams (implemented in HttpServer::applyGovernanceHeaders()).
  • [x] Export span data to OpenTelemetry collector via OTLP HTTP exporter (configurable endpoint in config/networking/). Implemented in include/api/otlp_exporter.h + src/api/otlp_exporter.cpp (async queue + libcurl POST, OTLP JSON format); TracingMiddleware extended with finishSpan() and optional OtlpExporter*; configuration in config/networking/otlp.yaml.
  • [x] Decision: retain proprietary X-Correlation-ID as the primary correlation header; the OTLP exporter uses the correlation-ID value as the OTLP traceId. A future W3C traceparent bridge 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 TracingMiddleware in src/api/tracing_middleware.cpp; generate UUID v4 if X-Correlation-ID absent; inject into thread-local RequestContext. (Implemented β€” TracingMiddleware::processRequest() uses boost::uuids::random_generator per thread.)
  • Forward RequestContext::correlationId to utils/logger.h log macros via a structured field (correlation_id). (Implemented β€” utils::Logger::setTraceContext(corr_id) called in processRequest().)
  • Echo back X-Correlation-ID in all responses including errors and SSE streams (implemented in HttpServer::applyGovernanceHeaders()).
  • Export span data to OpenTelemetry collector via OTLP HTTP exporter (configurable endpoint in config/networking/). Implemented in include/api/otlp_exporter.h + src/api/otlp_exporter.cpp (async queue + libcurl POST, OTLP JSON format); TracingMiddleware extended with finishSpan() and optional OtlpExporter*; configuration in config/networking/otlp.yaml.
  • Decision: retain proprietary X-Correlation-ID as the primary correlation header; the OTLP exporter uses the correlation-ID value as the OTLP traceId. A future W3C traceparent bridge 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

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

  1. added this to the v1.7.0 milestone on Mar 12, 2026
  2. added
    type:feature
    area:api
    priority:medium
    status:open
    observability
    on Mar 12, 2026
  3. added
    epic
    on Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:apiepicobservabilitypriority:mediumstatus:opentype:feature

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions