Repository navigation
Conversation
agentClient now wraps its transport in otelhttp.NewTransport with only the TraceContext propagator. Each provider call becomes an HTTP client span of the agent's request, and the provider receives traceparent and tracestate, so a gateway that traces (the llm-serving-pack's AI Gateway) continues the same trace. baggage never goes out: the transport does not use the server's TraceContext+Baggage propagators. The guard, ResponseHeaderTimeout and the absence of a whole-request timeout are unchanged. TestAgentCallCarriesOnlyTraceContext drives the real Proxy and agentClient against a fake provider and asserts the exact header set for six cases: telemetry on or off, with a valid, missing or malformed incoming traceparent, streamed and not. Each case gets its own tracer provider through the handler rather than the global one. Docs: a contract entry for the headers a model call carries to the provider, two patterns, and a paragraph in the admin configuration page. Refs nebari-dev/llm-serving-pack#315, nebari-dev/llm-serving-pack#148
This branch was successfully deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Slice 4: Tapas model calls carry W3C trace context
Every model call the agent proxy makes now carries
traceparentandtracestate, neverbaggage, and shows up as a standard HTTP client span. Streaming, timeouts and the fixed header set are otherwise unchanged. This is the Tapas side of gateway tracing in the LLM serving pack: once the pack's AI Gateway exports spans, a Tapas agent's model call becomes one trace with the Tapas server span, the Tapas client span and the gateway span.Design: gateway and vLLM OpenTelemetry tracing (nebari-dev/llm-serving-pack#315, traces #148). The spec and plan are kept locally; this PR is Slice 4 of 8. The
agent-session-idpass-through is not in this PR; it lands with its first sender in #127.Contracts touched: the headers a model call from
agentproxycarries to the provider;aisettings.agentClient(timeout, guard) *http.Client(same signature, wrapped transport).Depends on: none.
What changes
agentClientwraps today's transport (guarded or not) inotelhttp.NewTransportwith onlypropagation.TraceContext{}. The server handler uses TraceContext plus Baggage, so passing the propagator explicitly is what keepsbaggage, which can name the caller, from reaching the provider.traceparentis continued with Tapas's own client span id, and a call without one starts its own trace. With telemetry off, an agent's validtraceparentandtracestatego on as they came, and a call without one sends no trace context.agentproxyis untouched. It still sets onlyContent-Type,Authorizationand, for a stream,Accept.Validation
go test -count=1 ./internal/ai/... ./internal/telemetry/...go test -count=1 ./internal/gateway/...make testinternal/files TestDecodeListingByteCap(local go1.27.4) andtest/imagetag(shasumnot installed here)go vet ./...golangci-lintreports 91 issues, the same count as main, none on new linesTestAgentCallCarriesOnlyTraceContextruns the realProxyandagentClientagainst a fake provider. The agent request carries its own token, a cookie,baggageand a custom header. For six cases (telemetry on or off; a valid, missing or malformed incomingtraceparent; streamed or not) it asserts the exact set of header names the provider receives, thatAuthorizationis the configured key, the trace and span ids, and the stream body. Switching the transport to TraceContext plus Baggage fails every case.Open item
The comment at
internal/ai/agentproxy/agentproxy.go:198("Only these headers go out") no longer lists everything sent, because the transport now adds the trace headers. I left the file alone, since the design keepsagentproxyunchanged. We should decide whether to update that comment here or in #127.