MCPcopy Index your code
hub / github.com/docker/docker-agent / WrapWithOTel

Function WrapWithOTel

pkg/httpclient/client.go:82–87  ·  view source on GitHub ↗

WrapWithOTel returns rt wrapped with otelhttp when OpenTelemetry has been enabled via `SetOTelEnabled` (called by `initOTelSDK`), or rt unchanged otherwise. Gating avoids per-request span allocation on the no-OTel path and stops sending a `traceparent` header to upstream LLM providers that have no u

(rt http.RoundTripper)

Source from the content-addressed store, hash-verified

80// that build their own transports outside of `NewHTTPClient` can opt
81// into the same gating without duplicating the check.
82func WrapWithOTel(rt http.RoundTripper) http.RoundTripper {
83 if !otelEnabled.Load() {
84 return rt
85 }
86 return otelhttp.NewTransport(rt)
87}
88
89// TracedDefaultClient returns an `http.Client` equivalent to
90// `http.DefaultClient` but with the default transport wrapped via

Callers 5

createHTTPClientMethod · 0.92
CallToolMethod · 0.92
NewHTTPClientFunction · 0.85
TracedDefaultClientFunction · 0.85
TracedClientFunction · 0.85

Calls 1

LoadMethod · 0.80

Tested by

no test coverage detected