otel_tracer: stale b3 header forwarded upstream

未关闭
#14,177 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
67/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp
领域
networking

调研方向

Read plugins/experimental/otel_tracer/otel_tracer.cc around the incoming B3 header handling and outbound request header writing, plus plugins/experimental/otel_tracer/tracer_common.h where the propagator is selected. Reproduce the single-header b3 case and check how the origin receives propagation headers. Done when the outgoing headers consistently identify the ATS span as the origin's parent; the issue leaves the choice of propagation format open.

由索引模型根据 Issue 内容生成。

描述

Bug otel_tracer

Ran into a tracing bug while testing otel_tracer with single-header b3 requests.

When a request comes in with a single b3 header, ATS reads b3 into parent_headers and starts its span as a child of the client span just fine. The problem is what goes out to the origin. tracer_common.h wires up B3PropagatorMultiHeader, so otel_tracer.cc writes X-B3-TraceId, X-B3-SpanId, and X-B3-Sampled onto the request and leaves the old b3 header sitting there. Now the upstream request has both formats, and they don't match.

That breaks the trace chain downstream. In opentelemetry-cpp 1.19.0, and per the B3 spec, the extractor checks b3 first and ignores X-B3-* if b3 is present. So a B3 origin grabs the client's span ID out of the stale b3 header and skips right past ATS. You end up with ATS hanging off to the side as a sibling instead of sitting between the client and the origin.

I tested this on Ubuntu 24.04 with Traffic Server 11.0.0 built from master, opentelemetry-cpp 1.19.0, protobuf 3.21.12, and nlohmann-json 3.11.3. I sent b3: 463ac35c9f6413ad48485a3953bb6124-a2fb4a1d1a96d312-1 through ATS with otel_tracer.so enabled. ATS exported span 3aa4178cab7d8bf9 with parent a2fb4a1d1a96d312, and the origin got these B3 headers:

b3: 463ac35c9f6413ad48485a3953bb6124-a2fb4a1d1a96d312-1
X-B3-Sampled: 1
X-B3-SpanId: 3aa4178cab7d8bf9
X-B3-TraceId: 463ac35c9f6413ad48485a3953bb6124

When I ran opentelemetry-cpp 1.19.0's B3 extractor on those exact headers, it returned span_id=a2fb4a1d1a96d312 instead of 3aa4178cab7d8bf9. Requests that already come in as multi-header X-B3-* work fine since set_request_header overwrites them.

Dropping the incoming b3 header before writing X-B3-* would stop the stale header from winning, or the plugin could inject single-header b3 when that's what came in. Happy to put up a PR if you have a preference between the two.

主要语言
C++
星标
2k
派生
903
平均合并
4 天 4 小时
30 天内合并 PR
135

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/trafficserver 的其他 Issue

查看 apache/trafficserver 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。