Skip to content

Traceparent header may get duplicated with context_propagation: headers #976

@paweljw

Description

@paweljw

Hello! I'm running into the following:

  • an instance of nginx (OBI-instrumented, through Beyla) receives a request with a Traceparent header already set
  • by the time the request leaves nginx, it has two different Traceparent headers

Headers obtained by tcpdumping in the container running nginx. Only including relevant sections.

Case 1: external tracing instrumentation injects traceparent, OBI injects Traceparent.

Traceparent: 00-51c4b295117d40a6a3f531e715ce23d7-a24f141cea4f7d1d-01
X-Forwarded-Proto: http
traceparent: 00-51c4b295117d40a6a3f531e715ce23d7-a8e0bed6092f2234-01

I initially thought it may be due to case difference, so I reconfigured the upstream instrumentation to use Traceparent, matching case. Unfortunately didn't work, leading to:

Case 2: both inject Traceparent, duplicating the header:

Incoming into nginx:

Traceparent: 00-f6ed85f8071a40eca61f756f991ceb30-b7410955bd7a4a59-01

Outgoing from nginx:

Traceparent: 00-f6ed85f8071a40eca61f756f991ceb30-a41beb8a36e8dbe3-01
Traceparent: 00-f6ed85f8071a40eca61f756f991ceb30-b7410955bd7a4a59-01

I was able to confirm this as the source of some down-stream issues with consuming this data by adding a custom de-duplicating context propagator. Otherwise the resulting traces aren't very usable - the trees are "split" in the middle.

Based on some exploration of the codebase, it seems like bpf/tpinjector/tpinjector.c always prepends a Traceparent header, without attempting to check if there already exists a header. Is this by design, please? 🙏 I believe the W3C spec states there should only be one Traceparent header present.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions