This repository was archived by the owner on Aug 5, 2026. It is now read-only.
otel: inject traceparent on cdc→chart-inspector outbound call - #13
Merged
Conversation
The cdc's outbound GET {server}/resources call to chart-inspector used a
bare http.DefaultClient with no otelhttp instrumentation and no traceparent
injection, so the chart-inspector server span was never linked to the active
reconcile span by HTTP header (it relied solely on the annotation path).
Wrap the client transport with otelhttp.NewTransport(http.DefaultTransport)
so the request injects the W3C traceparent header (continuing the active
reconcile span) and emits a client span, and thread the reconcile ctx through
RBACGen.Generate → ChartInspector.Resources via http.NewRequestWithContext so
the span/headers actually propagate. Also stop mutating the shared
http.DefaultClient global.
Default-off: the otelhttp transport is a cheap pass-through when no global
tracer provider is registered; the W3C propagator is installed unconditionally
by the runtime, so the link is established only when tracing is active.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FzZJtQ4bEMHuK4CvF6eBuL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes the cdc→chart-inspector trace-propagation gap. The cdc's outbound
GET {server}/resourcescall to chart-inspector (internal/chartinspector/chartinspector.go) used a barehttp.DefaultClientwith nootelhttpinstrumentation and notraceparentinjection — so the chart-inspector server span was never linked to the active reconcile span by HTTP header (it relied solely on the annotation path). (Note:internal/tools/traceris a debug RoundTripper, not OTel — untouched.)Fix
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttpNewTransport(http.DefaultTransport), so the request injects the W3Ctraceparentheader (continuing the active reconcile span) and emits a client span.ctxthroughRBACGen.Generate→ChartInspector.Resourcesand build the request withhttp.NewRequestWithContext(ctx, ...)so the span/headers actually propagate. The metrics wrappers now pass the real reconcile ctx instead ofcontext.Background().http.DefaultClientglobal (latent bug) — construct a dedicated client.otelhttp v0.61.0as a direct dep (already ingo.sum, matching the OTel train);go mod tidy.Default-off
The
otelhttptransport is a cheap pass-through when no global tracer provider is registered. The W3C propagator is installed unconditionally by the runtime, so the cdc→chart-inspector link is established only when tracing is active — the off-path stays effectively no-op.Verify
go build ./...,go vet ./..., and the affected unit tests (internal/chartinspector,internal/rbacgen) all pass.🤖 Generated with Claude Code