Go std net HTTP/1 clients: avoid injecting the traceparent twice#2752
Conversation
|
I see 5.10 is failing with Probably the new programs need to be added to |
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR addresses duplicate traceparent injection for Go net/http (HTTP/1.x) clients by adding a return uprobe that detects whether the application already serialized a Traceparent header, and skips eBPF injection when present.
Changes:
- Add an entry/return uprobe pair around
net/http.Header.writeSubsetto detect an existingTraceparentand avoid double-injection. - Introduce a privileged integration test plus a small helper binary to validate both “header already present” and “header absent” scenarios.
- Wire the new return probe into the gotracer probe descriptor list.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| pkg/internal/ebpf/gotracer/tphttp_privileged_test.go | Adds privileged end-to-end test that attaches the tracer to a live Go process and asserts Traceparent is not duplicated. |
| pkg/internal/ebpf/gotracer/testdata/tphttpclient/main.go | Adds helper program that runs an HTTP/1 server/client loop and reports how many Traceparent values were received. |
| pkg/internal/ebpf/gotracer/gotracer.go | Registers a return (“End”) probe for net/http.Header.writeSubset to support conditional injection. |
| bpf/gotracer/go_nethttp.c | Implements the new return uprobe logic: stash writer state on entry, scan serialized headers on return, and inject only if missing. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2752 +/- ##
=======================================
Coverage ? 69.76%
=======================================
Files ? 359
Lines ? 51142
Branches ? 0
=======================================
Hits ? 35678
Misses ? 13236
Partials ? 2228
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
grcevski
left a comment
There was a problem hiding this comment.
LGTM! Nice this is the right approach. I'll let you deal with the copilot comments.
Summary
This is the first PR of a series that would fix issue #2732 (duplicate traceparent in SDK instrumented workloads) at different levels/protocol.
This PR fixes the issue for Go standard
netpackage (HTTP/1) clients. It adds a uprobe to the return address of header_writeSubset: when headers are written in the request, we check for a header containingTraceparent:. If it already exists, we abort the context propagation. Otherwise we inject theTraceparent:header.Validation