otel_tracer: stale b3 header forwarded upstream

オープン
#14,177 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
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時間
マージ済み PR(30日)
135

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/trafficserver のほかの issue

apache/trafficserver の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。