Skip to content

feat(http): add tracer header filter combinators to HttpClient#6406

Open
Zelys-DFKH wants to merge 1 commit into
Effect-TS:mainfrom
Zelys-DFKH:fix/httpclient-tracer-header-filter-v2
Open

feat(http): add tracer header filter combinators to HttpClient#6406
Zelys-DFKH wants to merge 1 commit into
Effect-TS:mainfrom
Zelys-DFKH:fix/httpclient-tracer-header-filter-v2

Conversation

@Zelys-DFKH

@Zelys-DFKH Zelys-DFKH commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Opening this at @IMax153's request to replace Effect-TS/effect-smol#2132. Now that V4 development has merged back into this repo's main branch, the linked issue lives here as #6363, so I'm bringing the same change over.

What this adds

Three new HttpClient combinators for controlling which headers get captured as OTEL span attributes:

  • withTracerRequestHeadersFilter: filters which request headers are captured
  • withTracerResponseHeadersFilter: filters which response headers are captured
  • withTracerHeadersFilter: applies the same predicate to both

Each takes a Predicate.Predicate<string> that receives the header name (already lower-cased) and returns true to capture it. The default is constTrue, so every header is captured just like today. This is fully backward compatible.

Why

HttpClient currently 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.CurrentRedactedNames only 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's OTEL_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 a tstyche typetest 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

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 15, 2026
@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a71991d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/openapi-generator Patch

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

@IMax153 IMax153 added enhancement New feature or request 4.0 labels Jul 15, 2026
@IMax153
IMax153 requested a review from tim-smart July 15, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 enhancement New feature or request

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

HttpClient: allow filtering HTTP header span attributes (allowlist / predicate)

2 participants