[REG-11] W0.6 - Outbound HTTP client instrumentation - #169
Merged
Conversation
Wraps every third-party HTTP client with otelhttp.NewTransport so each call becomes a child span tagged with peer.service, letting latency and error-rate questions be answered from traces instead of guesswork. - New internal/observability/http_client.go: InstrumentedHTTPClient wraps an existing *http.Client's transport (preserving auth, timeout, redirects, cookie jar) and tags spans with peer.service. Verified retries produce sibling spans (not one merged span) and that no auth headers, tokens, or bodies are ever recorded. - New internal/observability/google_api_client.go: InstrumentedGoogleAPIClient composes instrumentation with google.golang.org/api's own OAuth transport correctly. Plain option.WithHTTPClient combined with an auth option silently drops the SDK's auth-transport construction entirely (confirmed against the library source) - this wraps the RoundTripper as the base transport instead, which the library layers real auth on top of. - Wired: Slack (5 client-construction sites), Teams (graphClient and botfwClient, tagged msgraph/botframework so the two OAuth scopes are never conflated), Telegram (plus threading the ctx these calls were already given but silently discarding), OpenAI, Anthropic, Ollama (peer.service now parameterized on newOpenAIClient since Ollama wraps the same client type), FCM (via the new Google API helper, fixing the auth-bypass bug above), Web Push. - Live-verified against a real Jaeger collector: all nine peer.service values arrive as distinct, correctly tagged spans with no PII on any span.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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.
Closes REG-11
Summary
Every outbound third-party HTTP call now produces a child span tagged with
peer.service, so latency and error questions become measurements instead of guesses.What changed
internal/observability/http_client.go(new):InstrumentedHTTPClientwraps an existing*http.Client's transport withotelhttp.NewTransport, preserving its existing transport (auth, retries), timeout, redirect policy, and cookie jar. Tags every span withpeer.service.internal/observability/google_api_client.go(new):InstrumentedGoogleAPIClientcomposes instrumentation withgoogle.golang.org/api's own OAuth transport correctly. Found and fixed a real bug along the way: passing an instrumented client viaoption.WithHTTPClientalongside an auth option (e.g.option.WithAuthCredentialsJSON) silently bypasses the SDK's auth-transport construction entirely (confirmed againsttransport/http/dial.gosource) - every FCM send would have failed with zero auth token and no error signal. Fixed by wrapping the instrumented RoundTripper as the base transport, which the library then layers real OAuth on top of.slack_service.go,slack_validator.go,slack_members.go,slack_config.go,slack_event_handler.go)graphClientandbotfwClient, taggedmsgraph/botframeworkrespectively so the two OAuth-scoped clients are never conflated in a trace (plus the two standalone helper functions,TestTeamsCredentialsandListTeamMembers, which build their own Graph clients)ctxparameter these functions were already given but silently discarding into the actual HTTP callsnewOpenAIClientnow takes apeerServiceparameter since Ollama wraps the same underlying client type as OpenAI and would otherwise be mistaggedInstrumentedGoogleAPIClient, fixing the auth-bypass bug aboveAcceptance criteria
otelhttp.NewTransportapplied to all outbound clients: Slack, Teams (both clients), Telegram, OpenAI, Anthropic, Ollama, FCM, Web Pushpeer.service(current otelhttp stable semconv names thesehttp.request.method/http.response.status_code, superseding the ticket'shttp.method/http.status_code- verified live, semantically identical)io.LimitReadercap on Teams responses preserved (untouched)Verification
go build ./...,go vet ./...,gofmt -lclean on all touched files-shuffle=onon all touched packagesgolangci-lint run ./...: 0 issuespeer.servicevalues via a throwaway program, confirmed all 9 arrived as distinct, correctly tagged spans with zero PII (no auth/token/body content on any span or span event)