Keep the OTLP export credential on the configured endpoint - #393
Draft
archandatta wants to merge 2 commits into
Draft
archandatta wants to merge 2 commits into
archandatta wants to merge 2 commits into
Conversation
The exporter's bearer credential is set in a RoundTripper so a token that changes after start, the fork-refreshed instance JWT, is resolved per request. A RoundTripper runs on every hop, which means net/http's own cross-host Authorization strip never sees the header and cannot remove it. Pin the credential to the configured endpoint host and stop following redirects. The export target is configured rather than discovered, so a redirect is never something to act on, and a host the check cannot match now sends no credential at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
archandatta
force-pushed
the
archand/kernel-otlp-export/pin-credential-to-endpoint
branch
from
September 16, 2026 14:34
d7e8cc9 to
0bd7f31
Compare
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.
Invariant
The authenticated export client attaches its credential only to requests for
BTEL_OTLP_ENDPOINT. A request to any other host sends no instance bearer token, and the authenticated exporter does not follow redirects away from the configured endpoint.Why
bearerRoundTripperresolves the bearer per request rather than capturing it once, which lets a forked VM export with the fresh instance JWT from its applied identity payload without restarting the process (#316). Because aRoundTripperruns on every hop afternet/httpapplies its redirect-header policy, the credential needs its own explicit destination boundary.Nothing discovers the export target. It is
BTEL_OTLP_ENDPOINT, baked in at provisioning time, so a redirect is never something the authenticated exporter should act on and any host other than that endpoint is not the place the instance credential belongs.What changed
bearerRoundTrippergains ahost, set fromOTLPConfig.Endpoint, and attaches the instance credential only whenreq.URL.Hostmatches it case-insensitively. A mismatch fails closed: no instance bearer token is added.CheckRedirecttohttp.ErrUseLastResponse, so a3xxfrom the endpoint surfaces to the exporter as the response it is.Explicitly unchanged: per-request credential resolution and the fork-refresh behavior it exists for, the request clone in
RoundTrip, batch tuning, theHeadersoption, resource attributes, and the unauthenticated client path whenAuthTokenFuncis unset. WhenAuthTokenFuncis set but returns an empty token, the request remains unauthenticated while the client still rejects redirects. A correctly configured authenticated exporter sends exactly the same request it sent before.A
3xxfrom the endpoint is surfaced by the OTel SDK as a non-retryable failure and counted inkernel_otlp_export_failures_total, where previously the client followed theLocationresponse.Testing
Two new tests, both verified to fail with their respective guard reverted and to pass with it restored.
TestBearerRoundTripper_AuthenticatesOnlyConfiguredHostis table-driven over four cases: the configured host gets the credential, the same host uppercased still gets it, a different host gets nothing, and the same hostname on a different port gets nothing.TestOTLPStorageWriter_DoesNotFollowRedirectsstands up an endpoint that answers302toward a second server, waits for the terminal export failure, and asserts exactly one failed export, zero successful exports, one endpoint request, and zero redirect-target requests. Its cleanup stops the writer and releases the exporter.go test ./lib/events/ -count=1: 42 tests passgo test ./lib/events/ -count=1 -race: passgo vet ./lib/events/: passgo build ./...: passDeployment
This lands in the browser image, so it reaches production on the next image release and version-pin bump rather than at merge.