feat(supabase): W3C/OpenTelemetry trace context propagation#2163
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@supabase/auth-js
@supabase/functions-js
@supabase/postgrest-js
@supabase/realtime-js
@supabase/storage-js
@supabase/supabase-js
commit: |
38b0bee to
0490747
Compare
96c4e64 to
a289e5e
Compare
Implements automatic trace context propagation for distributed tracing across all Supabase services. When enabled, the SDK automatically attaches trace context headers (traceparent, tracestate, baggage) to outgoing requests, enabling end-to-end request tracing from client applications through Supabase services. - Created shared package for trace context utilities - Implements W3C Trace Context specification parsing - Supports OpenTelemetry API integration with graceful fallback - Provides URL target validation (string, RegExp, function matchers) - Includes 63 unit tests with 85%+ coverage - Updated fetchWithAuth to inject trace headers automatically - Added TracePropagationOptions configuration API - Updated SupabaseClient to support trace propagation - Added Realtime WebSocket trace context via query parameters - Added 9 integration tests for trace propagation scenarios - Added comprehensive documentation to README - **Auto-detection**: Automatically detects active trace context from OpenTelemetry API - **Custom extractors**: Support for custom tracing systems - **Security-first**: Only propagates to Supabase domains by default - **Configurable targets**: Support for custom allowed domains - **Sampling aware**: Respects upstream sampling decisions - **Zero breaking changes**: Fully backward compatible - `auto` (default): Automatically detect and propagate trace context - `off`: Disable trace propagation - `manual`: Only propagate manually set headers - All builds pass (nx build supabase-js) - All type checks pass - 63 unit tests pass in trace-propagation package - 95 unit tests pass in supabase-js (including new tests) - 85%+ code coverage across all modules Related: Linear SDK-578 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Rename @supabase/trace-propagation to @supabase/tracing for consistency with naming conventions across the codebase. Changes: - Rename packages/shared/trace-propagation to packages/shared/tracing - Update package name from @supabase/trace-propagation to @supabase/tracing - Update all imports in supabase-js package - Update workspace configuration - Rename test-trace-propagation to test-tracing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove the customExtractor option from trace propagation configuration. Users should rely on OpenTelemetry API for trace context extraction. Changes: - Remove customExtractor field from TracePropagationOptions interface - Remove customExtractor parameter from extractTraceContext function - Update all code that used customExtractor - Remove custom extractor tests - Update documentation in READMEs Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Simplify trace propagation API by changing from string-based mode
('auto' | 'off' | 'manual') to a simple boolean flag (enabled).
Changes:
- Replace TracePropagationMode type with boolean enabled field
- Remove mode field from TracePropagationOptions interface
- Add enabled?: boolean field (defaults to true)
- Update all code to check enabled flag instead of mode
- Remove 'manual' mode functionality
- Update tests to use boolean flag
- Update documentation in README
BREAKING CHANGE: The tracePropagation.mode option has been replaced with
tracePropagation.enabled. Update from { mode: 'auto' } to { enabled: true }
and from { mode: 'off' } to { enabled: false }.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove the ability for users to customize which domains receive trace context headers. Trace propagation is now restricted to Supabase domains only (*.supabase.co, *.supabase.in, localhost) for security. Changes: - Remove targets field from TracePropagationOptions interface - Remove TracePropagationTarget import from types - Update code to always use default Supabase domains - Remove custom targets test case - Update documentation to reflect fixed target domains BREAKING CHANGE: The tracePropagation.targets option has been removed. Trace context is now only propagated to Supabase domains for security. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove trace context propagation for Realtime WebSocket connections. Trace propagation is now only applied to HTTP requests (REST API, Storage, Functions, Auth) and not to WebSocket connections. Changes: - Remove trace context extraction from _initRealtimeClient - Remove extractTraceContext import from SupabaseClient.ts - Simplify Realtime client initialization Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
a289e5e to
75b40da
Compare
82371b1 to
8fd3f59
Compare
This PR updates `@supabase/supabase-js` to v2.106.0. **Source**: supabase-js-stable-release --- ## Release Notes ## v2.106.0 ## 2.106.0 (2026-05-18) ### 🚀 Features - **supabase:** W3C/OpenTelemetry trace context propagation ([#2163](supabase/supabase-js#2163)) ### 🩹 Fixes - **auth:** return null user and session for email_change single-confirmation verifyOtp ([#2378](supabase/supabase-js#2378)) - **release:** mark @supabase/tracing private and snapshot it for JSR ([#2370](supabase/supabase-js#2370)) - **storage:** make StreamDownloadBuilder implement Promise and memoize executor ([#2367](supabase/supabase-js#2367)) ### ❤️ Thank You - Claude Sonnet 4.5 - Guilherme Souza - Katerina Skroumpelou @mandarini - oniani1 This PR was created automatically. Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
|
This PR breaks the build on react native ios builds (metro bundler), specifically this I believe a |
|
Working on it! @Tofandel |
This PR updates @supabase/*-js libraries to version 2.106.0. **Source**: supabase-js-stable-release **Changes**: - Updated @supabase/supabase-js to 2.106.0 - Updated @supabase/auth-js to 2.106.0 - Updated @supabase/realtime-js to 2.106.0 - Updated @supabase/postgest-js to 2.106.0 - Refreshed pnpm-lock.yaml --- ## Release Notes ## v2.106.0 ## 2.106.0 (2026-05-18) ### 🚀 Features - **supabase:** W3C/OpenTelemetry trace context propagation ([#2163](supabase/supabase-js#2163)) ### 🩹 Fixes - **auth:** return null user and session for email_change single-confirmation verifyOtp ([#2378](supabase/supabase-js#2378)) - **release:** mark @supabase/tracing private and snapshot it for JSR ([#2370](supabase/supabase-js#2370)) - **storage:** make StreamDownloadBuilder implement Promise and memoize executor ([#2367](supabase/supabase-js#2367)) ### ❤️ Thank You - Claude Sonnet 4.5 - Guilherme Souza - Katerina Skroumpelou @mandarini - oniani1 This PR was created automatically. Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
|
Ref: #2380 |
Summary
Adds opt-in W3C / OpenTelemetry trace context propagation for HTTP requests to Supabase services (Auth, Storage, PostgREST, Functions). Enables end-to-end distributed tracing from client applications through Supabase services.
Design principles:
*.supabase.co,*.supabase.in, localhost) so trace context never leaks to third-party services.@opentelemetry/apivia runtime dynamic import; if it's not installed, the SDK silently no-ops.SupabaseClientOptions.fetchWithAuthinjection point covers Auth, Storage, PostgREST, and Functions.How to opt in
The simplest form is a boolean:
Once enabled, requests issued inside an active OTel span automatically carry
traceparent/tracestate/baggage:For advanced configuration, pass an object:
TracePropagationOptionsChanges
New package:
@supabase/tracing(internal)Shared package in
packages/shared/tracing/providing:extractTraceContext()— extracts W3Ctraceparent,tracestate, andbaggagefrom the active OpenTelemetry context. The dynamic import to@opentelemetry/apiis cached at module scope (one resolution per process) and routed through a variable specifier with bundler-ignore comments so webpack / turbopack / vite / rollup don't try to statically resolve the optional peer dep at build time.parseTraceParent()— validates and parses W3C traceparent format.shouldPropagateToTarget()— URL validation against allowed targets (string exact, wildcard, RegExp, or function matcher). Accepts either a string or a pre-parsedURLto avoid double-parsing on the hot path.getDefaultPropagationTargets()— returns the allowlist for a given project URL: the exact project hostname, the wildcard strings*.supabase.co/*.supabase.in, and the localhost loopback addresses. Wildcards are linear-time string suffix checks (no regex, no ReDoS surface).@supabase/supabase-jsSupabaseClient.ts— threadstracePropagationsettings through tofetchWithAuth.fetch.ts— whenenabledis true, propagation targets are computed once at client construction (not per request). When disabled (the default), the per-request path skips all tracing work behind a single truthy check.types.ts— addstracePropagation?: TracePropagationOptions | booleantoSupabaseClientOptions.helpers.ts—applySettingDefaultsnormalizesboolean→{ enabled }and falls back to the disabled-by-default object.Architecture
Per-request overhead
import()is cached after the first attempt.propagation.inject(). Negligible compared to a typical 5–50 ms network RTT.Testing
packages/shared/tracing/test/.packages/core/supabase-js/test/unit/fetch.test.ts(covers default-off, boolean shorthand, non-Supabase domains, sampling decisions, existing-header preservation).Test plan
References
🤖 Generated with Claude Code