How would you test trace-context and log correlation across services?
Answer
Trigger a known request and verify that valid trace and span context is propagated through synchronous calls, queues, retries and fan-out without creating unrelated root traces. Logs emitted during the work should carry the active identifiers so an investigator can move between a trace and its events. Also test malformed or untrusted incoming context, boundaries to third parties, sampling behaviour and asynchronous continuation so correlation does not become a security leak or a false causal link.
Strong answer includes
- covers synchronous and asynchronous propagation
- verifies logs contain active trace context
- tests trust boundaries and malformed context
Practical example
A test sends one request that flows through an API gateway, a synchronous auth-service call, and then a message published to a queue consumed by an async worker. The engineer confirms all three services log the same trace_id, that the worker's log entry links back via a valid parent span rather than starting a brand-new trace, and then sends a request with a forged, malformed traceparent header from an external caller to confirm the system does not blindly trust or propagate it internally.