Skip to content

feat: propagate traceparent from bandit callback URLs#196

Merged
myleshorton merged 1 commit intomainfrom
feat/bandit-traceparent
Mar 24, 2026
Merged

feat: propagate traceparent from bandit callback URLs#196
myleshorton merged 1 commit intomainfrom
feat/bandit-traceparent

Conversation

@myleshorton
Copy link
Contributor

Summary

  • Extracts tp query parameter from URL test links and sets it as the traceparent HTTP header
  • Enables contiguous distributed tracing from API config assignment → client URL test → proxy forward → API callback

Context

The bandit system embeds W3C traceparent in callback URLs (?token=XYZ&tp=00-traceID-spanID-01). This change makes the MutableURLTest HTTP client extract and propagate it, so the proxy passes it through to the API's callback handler.

Test plan

  • go vet ./protocol/group/... passes
  • Verify in SigNoz that callback spans appear as children of the config assignment trace

🤖 Generated with Claude Code

Extracts the tp query parameter from URL test links and sets it as
the traceparent HTTP header. This enables contiguous distributed
tracing from the API's config assignment through the client and proxy
to the callback receipt.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 24, 2026 01:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR propagates distributed tracing context embedded in bandit callback/test URLs by extracting a tp query parameter and setting it as the outgoing request’s traceparent header in the MutableURLTest HTTP client, enabling end-to-end trace continuity across URL test → proxy → callback.

Changes:

  • Extract tp from the URL test link’s query string.
  • Set the extracted value as the traceparent HTTP header on the outbound GET request.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +644 to +648
// Propagate embedded trace context so the bandit callback
// appears in the same distributed trace as the config assignment.
if tp := linkURL.Query().Get("tp"); tp != "" {
req.Header.Set("traceparent", tp)
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

tp comes from a URL query parameter and is copied verbatim into an HTTP header. If it contains control characters (or is just not a valid W3C traceparent), Go's HTTP client can fail the request at send time (invalid header value) and an untrusted URL could also attempt header injection. Consider validating/sanitizing the value (e.g., trim spaces, reject any CTLs, and only accept the expected version-traceid-spanid-flags format) before setting traceparent.

Copilot uses AI. Check for mistakes.
Comment on lines +644 to +648
// Propagate embedded trace context so the bandit callback
// appears in the same distributed trace as the config assignment.
if tp := linkURL.Query().Get("tp"); tp != "" {
req.Header.Set("traceparent", tp)
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This new behavior (extract tp from the test URL and propagate it as the traceparent header) is not covered by tests. Since this package already has unit tests for urlTestGroup, consider adding a focused test that asserts a request created by urlTestGET includes the expected header when tp is present (and omits it when absent/invalid).

Copilot uses AI. Check for mistakes.
@myleshorton myleshorton merged commit 821e13a into main Mar 24, 2026
7 checks passed
@myleshorton myleshorton deleted the feat/bandit-traceparent branch March 24, 2026 01:44
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.

2 participants