otel_tracer: stale b3 header forwarded upstream

Offen
#14,177 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
67/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
cpp
Bereich
networking

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
C++
Sterne
2k
Forks
903
Ø Merge
4 T. 4 Std.
Gemergte PRs (30 T.)
135

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus apache/trafficserver

Alle Issues in apache/trafficserver

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.