feat(http): add tracer header filter combinators to HttpClient#6406
Open
Zelys-DFKH wants to merge 1 commit into
Open
feat(http): add tracer header filter combinators to HttpClient#6406Zelys-DFKH wants to merge 1 commit into
Zelys-DFKH wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: a71991d The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Opening this at @IMax153's request to replace Effect-TS/effect-smol#2132. Now that V4 development has merged back into this repo's
mainbranch, the linked issue lives here as #6363, so I'm bringing the same change over.What this adds
Three new
HttpClientcombinators for controlling which headers get captured as OTEL span attributes:withTracerRequestHeadersFilter: filters which request headers are capturedwithTracerResponseHeadersFilter: filters which response headers are capturedwithTracerHeadersFilter: applies the same predicate to bothEach takes a
Predicate.Predicate<string>that receives the header name (already lower-cased) and returnstrueto capture it. The default isconstTrue, so every header is captured just like today. This is fully backward compatible.Why
HttpClientcurrently captures every header value as a span attribute unconditionally. For chatty APIs (Notion, Cloudflare-fronted services, CloudFront, etc.) that means 15-30+ low-signal attributes per span (cf-ray,alt-svc,via, and the like), which bloats trace storage and buries the few attributes that actually matter for debugging.Headers.CurrentRedactedNamesonly redacts values; the attributes are still emitted regardless. This gives callers a way to opt individual headers out entirely, matching the header-capture allowlist knobs already common in other OTEL client instrumentations (Java'sOTEL_INSTRUMENTATION_HTTP_CLIENT_CAPTURE_REQUEST_HEADERS, for example).Testing
Adds four tests to
HttpClient.test.ts(a default-capture-all baseline plus one per combinator) and atstychetypetest block that verifies data-first/data-last usage across all three combinators.Credit
Thanks to @schickling for the well-researched issue #6363, the reproduction repo made this easy to verify, and to @IMax153 for the review on the original Effect-TS/effect-smol#2132.
Fixes #6363