feat(http): add tracer header filter combinators to HttpClient#2132
Open
Zelys-DFKH wants to merge 1 commit intoEffect-TS:mainfrom
Open
feat(http): add tracer header filter combinators to HttpClient#2132Zelys-DFKH wants to merge 1 commit intoEffect-TS:mainfrom
Zelys-DFKH wants to merge 1 commit intoEffect-TS:mainfrom
Conversation
Adds predicate-based filtering of which HTTP headers are recorded as OTEL span attributes on HttpClient spans. Closes Effect-TS#2090. New exports: - TracerRequestHeadersFilter (Context.Reference) - TracerResponseHeadersFilter (Context.Reference) - withTracerRequestHeadersFilter(predicate) - withTracerResponseHeadersFilter(predicate) - withTracerHeadersFilter(predicate) — applies same predicate to both Default is constTrue so existing behavior is unchanged. Follows the same Context.Reference + transformResponse + Effect.provideService pattern as SpanNameGenerator and TracerDisabledWhen. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 1d62110 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.
Type
Description
Closes #2090. The issue describes it well: every request and response header lands in the span, including 15-30+ low-signal CDN headers (
cf-ray,alt-svc,x-amz-cf-id, ...) with no API to restrict them.Headers.CurrentRedactedNamesonly redacts values — the attributes still emit. This adds a predicate-based filter that runs after redaction, so callers can drop headers from spans entirely.Three new combinators:
withTracerRequestHeadersFilter(predicate)— controls which request headers appear on the spanwithTracerResponseHeadersFilter(predicate)— controls which response headers appear on the spanwithTracerHeadersFilter(predicate)— applies the same predicate to bothPlus two
Context.Referenceexports (TracerRequestHeadersFilter,TracerResponseHeadersFilter) for callers who prefer to set the filter viaEffect.provideServicedirectly.The implementation follows the same
Context.Reference+transformResponse+Effect.provideServicepattern asTracerDisabledWhen,TracerPropagationEnabled, andSpanNameGenerator. Default isconstTrue, so existing behavior is unchanged.I went with separate request/response references rather than a single combined
TracerHeaderFilter(as the issue suggested) because the two often warrant different policies — you might want all request headers for debugging but onlyx-request-idandcontent-typefrom responses. The combinedwithTracerHeadersFiltercovers the common case where you want the same predicate for both.Three tests added to
HttpClient.test.ts, one per combinator.This is a port of Effect-TS/effect#6215, redirected here by @tim-smart after Effect v3 entered feature freeze.
Related