Skip to content

Add TCP Options Context Propagation Support - #914

Merged
MrAlias merged 14 commits into
open-telemetry:mainfrom
rafaelroquetto:tcp_opts
Nov 24, 2025
Merged

Add TCP Options Context Propagation Support#914
MrAlias merged 14 commits into
open-telemetry:mainfrom
rafaelroquetto:tcp_opts

Conversation

@rafaelroquetto

@rafaelroquetto rafaelroquetto commented Nov 21, 2025

Copy link
Copy Markdown
Contributor

Add TCP Options Context Propagation Support

This PR adds support for injecting distributed tracing context via TCP options (kind 25), providing a transport-layer fallback for context propagation when HTTP headers are unavailable (e.g., SSL/TLS traffic or non-HTTP protocols):

  • New tpinjector now injects TCP options in addition to HTTP
  • Flexible configuration with a bitmask-based ContextPropagation field supporting combinations like headers, tcp, ip, or all via OTEL_EBPF_BPF_CONTEXT_PROPAGATION (backwards compatible)
  • Mutual exclusion on egress ensures only one injection method per connection, TCP or IP, in order of precedence
  • "Last one wins" on ingress allows all enabled methods to parse independently, with later methods overwriting earlier ones to establish a natural priority hierarchy (IP < TCP < HTTP)
  • Documentation added to devdocs/context-propagation.md explaining architecture, execution order, and coordination mechanisms

Breaking Changes

Removed deprecated ContextPropagationEnabled boolean field - users must migrate to context_propagation: "all" or specific combinations like "headers,tcp"

@codecov

codecov Bot commented Nov 21, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.21053% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.26%. Comparing base (ff9ebf4) to head (45e22bc).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
pkg/appolly/discover/finder.go 33.33% 2 Missing and 2 partials ⚠️
pkg/internal/ebpf/generictracer/generictracer.go 0.00% 0 Missing and 3 partials ⚠️
pkg/config/ebpf_tracer.go 94.87% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #914      +/-   ##
==========================================
+ Coverage   55.08%   55.26%   +0.17%     
==========================================
  Files         253      253              
  Lines       21756    21769      +13     
==========================================
+ Hits        11985    12031      +46     
+ Misses       8946     8911      -35     
- Partials      825      827       +2     
Flag Coverage Δ
integration-test 23.35% <19.29%> (+0.12%) ⬆️
integration-test-arm 0.00% <0.00%> (ø)
integration-test-vm-${ARCH}-${KERNEL_VERSION} 0.00% <0.00%> (?)
k8s-integration-test 2.73% <0.00%> (-0.01%) ⬇️
oats-test 0.00% <0.00%> (ø)
unittests 46.40% <80.70%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rafaelroquetto
rafaelroquetto force-pushed the tcp_opts branch 4 times, most recently from c48bb1b to 4613686 Compare November 22, 2025 00:47
Comment thread bpf/common/connection_info.h
@rafaelroquetto rafaelroquetto changed the title WIP Introduce TCP context propagation Add TCP Options Context Propagation Support Nov 22, 2025
@rafaelroquetto
rafaelroquetto marked this pull request as ready for review November 22, 2025 03:08
@rafaelroquetto
rafaelroquetto requested a review from a team as a code owner November 22, 2025 03:08

@mmat11 mmat11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments, overall lgtm! nice work on the context propagation docs 👏🏻

Comment thread bpf/tpinjector/tpinjector.c Outdated
Comment thread bpf/tpinjector/tpinjector.c
Comment thread bpf/tpinjector/tpinjector.c Outdated
Comment thread pkg/config/ebpf_tracer.go Outdated
Comment thread pkg/config/ebpf_tracer.go
Comment thread devdocs/context-propagation.md

@mmat11 mmat11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@MrAlias MrAlias left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@MrAlias
MrAlias merged commit 5438915 into open-telemetry:main Nov 24, 2025
56 checks passed

@grcevski grcevski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rafaelroquetto
rafaelroquetto deleted the tcp_opts branch November 24, 2025 23:00
@MrAlias MrAlias added this to the v0.3.0 milestone Dec 3, 2025
@MrAlias MrAlias mentioned this pull request Dec 3, 2025
marctc pushed a commit to grafana/opentelemetry-ebpf-instrumentation that referenced this pull request Dec 9, 2025
* Introduce TCP context propagation

* Update test matrix

* Test format

* Fix test

* Add devdoc

* Remove deprecated option

* Fix docs linter

* Remove magic number

* Fix tests

* Remove stray comment

* Reuse encode_hex

* Remove unused aliases

* Update docs

* Fix formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants