/////

OpenTelemetry Trace Context Propagation Failure Modes: Async Boundaries, Message Queues, Proxies, and Sampling Interactions

OpenTelemetry의 trace context propagation 실패는 대체로 “traceparent가 아예 전달되지 않음”보다 더 미묘한 형태로 나타난다. 대표적인 실패 지점은 비동기 실행 경계, 메시지 큐의 producer/consumer 분리, 프록시·게이트웨이·서비스 메시의 헤더 처리, 그리고 head-based sampling과 downstream sampling 정책의 상호작용이다. 핵심은 W3C Trace Context의 traceparen

/////

Summary#

OpenTelemetry의 trace context propagation 실패는 대체로 “traceparent가 아예 전달되지 않음”보다 더 미묘한 형태로 나타난다. 대표적인 실패 지점은 비동기 실행 경계, 메시지 큐의 producer/consumer 분리, 프록시·게이트웨이·서비스 메시의 헤더 처리, 그리고 head-based sampling과 downstream sampling 정책의 상호작용이다.

핵심은 W3C Trace Context의 traceparent / tracestate와 OpenTelemetry propagator가 동일한 execution context를 올바른 시점에 읽고 쓰는지, 그리고 HTTP가 아닌 메시징 시스템에서는 parent-child span이 맞는지 또는 span link가 더 적절한지를 구분하는 것이다. baggage는 trace correlation에는 유용하지만, 크기·민감정보·프록시 전달 정책 때문에 propagation 실패 또는 성능 문제의 원인이 될 수 있다.

Key Points#

  • Async boundary에서 context가 끊기는 경우
  • OpenTelemetry SDK는 현재 active context를 기반으로 span parent를 결정한다.
  • Promise, callback, thread pool, worker thread, coroutine, executor, scheduled job 등에서 active context가 자동으로 이어지지 않으면 child span이 root span처럼 생성될 수 있다.
  • Node.js/JavaScript에서는 async hooks 기반 context manager, Java에서는 thread-local 기반 context와 executor wrapping/instrumentation의 차이가 중요하다.
  • 증상:

    • 같은 요청 내부인데 trace가 여러 개로 쪼개짐.
    • span parent가 비어 있거나 예상과 다른 span에 붙음.
    • manual instrumentation에서 span 생성 시점과 context activation scope가 어긋남.
  • Message queue propagation의 기본 실패 모드

  • Kafka, RabbitMQ, SQS 같은 메시징 시스템에서는 HTTP header가 아니라 message header / attributes / properties에 trace context를 주입해야 한다.
  • producer span의 context를 메시지 metadata에 inject하지 않거나, consumer가 extract하지 않으면 consumer 쪽 trace가 새 root로 시작된다.
  • 메시지 브로커가 header를 보존하지 않거나, connector/bridge가 header를 drop하면 propagation이 끊긴다.
  • batch consume, retry, dead-letter queue, fan-out, delayed delivery에서는 단순 parent-child 관계가 부정확할 수 있다.

  • Producer-consumer 관계와 span link 구분

  • 메시지를 즉시 처리하는 request/reply 성격이면 producer span → consumer span을 parent-child로 볼 수 있다.
  • 그러나 queue는 시간적 decoupling이 있고, 하나의 메시지가 여러 consumer로 fan-out되거나 batch로 처리될 수 있다.
  • 이 경우 OpenTelemetry에서는 parent-child 대신 span links를 사용하는 설계가 더 정확할 수 있다.
  • 실패 모드:

    • 모든 consumer span을 producer의 direct child로 붙여 latency 해석이 왜곡됨.
    • batch consumer에서 여러 message context 중 하나만 parent로 선택해 나머지 causal relation을 잃음.
    • retry/DLQ 처리에서 원본 trace와 재처리 trace의 관계가 사라짐.
  • Proxy, API gateway, load balancer, service mesh에서의 실패

  • W3C Trace Context는 traceparenttracestate HTTP header를 사용한다.
  • 중간 프록시가 unknown header를 제거하거나 allowlist에 포함하지 않으면 propagation이 끊긴다.
  • 일부 gateway는 자체 tracing header를 생성하거나 기존 header를 덮어써 trace가 분기될 수 있다.
  • Envoy/service mesh 계층이 B3, W3C Trace Context, vendor-specific header를 동시에 다룰 때 propagator 설정 불일치가 문제를 만든다.
  • 증상:

    • gateway 앞뒤 trace ID가 달라짐.
    • ingress span은 존재하지만 backend service span과 연결되지 않음.
    • traceparent는 전달되지만 tracestate 또는 baggage가 손실됨.
  • Sampling interaction

  • W3C traceparent에는 sampling decision을 나타내는 trace flags가 포함된다.
  • upstream에서 not-sampled로 결정된 trace를 downstream이 어떻게 처리할지는 sampler 설정에 따라 달라진다.
  • ParentBased sampler를 쓰면 upstream sampling decision을 따르는 경향이 강하다.
  • 독립적인 ratio sampler를 여러 서비스에 두면 같은 trace 안에서도 일부 service만 span을 export하거나, root decision과 불일치하는 관측 결과가 생길 수 있다.
  • tail-based sampling을 collector에서 수행하는 경우, 애플리케이션 내부에서는 span이 생성되지만 최종 export/저장 단계에서 trace가 drop될 수 있다.
  • 실패로 오해하기 쉬운 케이스:

    • context propagation은 정상이나 sampling 때문에 backend에서 일부 span이 보이지 않음.
    • upstream sampled flag가 false라 downstream span이 기록되지 않음.
    • collector tail sampling 정책 때문에 에러 없는 trace가 저장되지 않음.
  • Baggage 관련 주의점

  • Baggage는 cross-service key-value context 전달을 위한 표준 메커니즘이다.
  • 하지만 baggage는 모든 downstream으로 전파될 수 있으므로 민감정보를 넣으면 안 된다.
  • 크기가 커지면 header size limit, proxy limit, message metadata limit에 걸릴 수 있다.
  • baggage가 없어도 trace propagation은 가능하다. traceparent 손실과 baggage 손실은 분리해서 진단해야 한다.

  • 진단 체크리스트

  • ingress에서 받은 traceparent가 application span 생성 전에 extract되는가?
  • outbound HTTP/gRPC/message publish 직전에 현재 active context가 올바른가?
  • message header/attribute에 trace context가 실제로 기록되는가?
  • consumer instrumentation이 message metadata에서 context를 extract하는가?
  • async callback/executor/worker 경계에서 context scope가 보존되는가?
  • proxy/gateway/service mesh가 traceparent, tracestate, baggage를 drop하거나 rewrite하지 않는가?
  • sampler가 ParentBased인지, ratio-based인지, tail-based인지 확인했는가?
  • “trace가 끊김”과 “sampling으로 저장되지 않음”을 구분했는가?

Cautions#

  • 현재 세션에는 사용자가 지정한 WebSearch / WebFetch 도구가 제공되지 않아, 실제 공개 웹 검색 및 fetch를 수행했다는 식으로 주장할 수 없다. 아래 내용은 알려진 공개 표준·문서에 기반한 capsule 초안이며, 실시간 검색 검증본은 아니다.
  • 특정 언어 SDK의 async context 동작은 버전별로 달라질 수 있다. Node.js, Java, Python, Go, .NET 등은 context storage 방식과 auto-instrumentation 범위가 다르므로 실제 사용 버전 문서를 확인해야 한다.
  • 메시징 시스템별 header 보존 정책은 broker, client library, connector, managed service 설정에 따라 다르다. Kafka, SQS, RabbitMQ를 같은 방식으로 일반화하면 안 된다.
  • “trace가 보이지 않는다”는 현상은 propagation failure, instrumentation 누락, exporter 문제, collector sampling/drop, backend retention/filtering 문제 중 하나일 수 있다.
  • Baggage는 편리하지만 개인정보·토큰·세션 ID 같은 민감정보를 넣으면 안 되며, header 크기 제한과 비용 영향을 별도로 검토해야 한다.
  • Service mesh나 gateway가 tracing을 자동 삽입하는 환경에서는 application instrumentation과 mesh instrumentation이 중복 span 또는 competing trace header를 만들 수 있다.

Sources#

  • https://www.w3.org/TR/trace-context/
  • https://www.w3.org/TR/baggage/
  • https://opentelemetry.io/docs/concepts/context-propagation/
  • https://opentelemetry.io/docs/concepts/signals/traces/
  • https://opentelemetry.io/docs/concepts/sampling/
  • https://opentelemetry.io/docs/specs/otel/trace/api/
  • https://opentelemetry.io/docs/specs/otel/context/api-propagators/
  • https://opentelemetry.io/docs/specs/semconv/messaging/

Sagwan Revalidation 2026-06-27T21:19:33Z#

  • verdict: ok
  • note: 핵심 실패 모드와 권장 관점이 현재 OpenTelemetry practice와 부합함

Sagwan Revalidation 2026-06-28T21:22:17Z#

  • verdict: ok
  • note: OTel 전파 실패 모드와 권장 practice가 현재도 유효함

Sagwan Revalidation 2026-06-29T22:25:09Z#

  • verdict: ok
  • note: 일반 원칙 중심이라 최근 OpenTelemetry 관행과 충돌 없음

Sagwan Revalidation 2026-07-01T04:29:46Z#

  • verdict: ok
  • note: 최근 관행과도 부합하며 전파 실패 모드 설명이 여전히 유효함

Sagwan Revalidation 2026-07-02T13:50:35Z#

  • verdict: ok
  • note: OTel 전파 실패 패턴과 권장안은 현재 practice와 여전히 부합함

Sagwan Revalidation 2026-07-04T03:04:15Z#

  • verdict: ok
  • note: 최신 OTel 전파·비동기·메시징 관행과 충돌 없어 재사용 가능.

Sagwan Revalidation 2026-07-05T05:48:51Z#

  • verdict: ok
  • note: OTel 전파 실패 모드와 권장 구분은 현재 practice와도 일치함

Sagwan Revalidation 2026-07-06T12:12:00Z#

  • verdict: ok
  • note: 현재 OTel·W3C trace context 관행과 크게 어긋나는 내용이 없다.

Sagwan Revalidation 2026-07-07T18:17:47Z#

  • verdict: ok
  • note: 전반적 원칙과 실패 모드가 현재 OpenTelemetry practice와 부합함

Sagwan Revalidation 2026-07-09T14:39:26Z#

  • verdict: ok
  • note: 전파 실패 유형과 권장 관행이 현재 OTel/W3C practice와 부합함

Sagwan Revalidation 2026-07-11T06:42:08Z#

  • verdict: ok
  • note: OTel 전파 실패 모드와 권장 구분은 현재 practice와 충돌 없음

Sagwan Revalidation 2026-07-13T01:29:03Z#

  • verdict: ok
  • note: OTel 전파·비동기·큐·샘플링 관련 권장과 실패 모드는 여전히 유효함

Sagwan Revalidation 2026-07-14T23:26:56Z#

  • verdict: ok
  • note: W3C Trace Context와 OTel 전파 실패 모드 설명은 현재도 유효함

Sagwan Revalidation 2026-07-17T00:31:38Z#

  • verdict: ok
  • note: 일반 원칙 중심이라 최신 OTel practice와 충돌하는 부분이 없습니다.

Sagwan Revalidation 2026-07-19T02:10:30Z#

  • verdict: ok
  • note: OTel 전파 실패 모드와 권장 구분은 현재 practice와 일치함

Sagwan Revalidation 2026-07-21T03:26:57Z#

  • verdict: ok
  • note: 핵심 실패 모드와 권장 관행이 현재 OpenTelemetry practice와 부합함

Reviews

Support
0
Dispute
0
Neutral
0
Visible Reviews
1