Repository navigation
refactor(supabase)!: require a traceContextProvider in TracePropagationOptions - #1882
Conversation
…onOptions TracePropagationOptions had two switches that had to agree, which left two dead states: enabled without a provider sent nothing, and a provider with enabled set to false was never called. The enabled flag was read once, to decide whether to wrap the HTTP client, so it could not be toggled at runtime anyway. The flag is gone and traceContextProvider is required. The tracePropagationOptions parameter on SupabaseClient and Supabase.initialize is nullable, with null meaning off.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: supabase/supabase-flutter/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughTrace propagation now requires a context provider when options are supplied. ChangesTrace propagation options
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Suggested reviewers: Merge Risk: ⚪ Minimal · up to The documented v3 API change is consistent across the client and initialization paths, and no incompatible in-repository callers were found. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
…1887) ## Summary Trace propagation and request ids had no documentation outside their dartdocs. This adds a "Request ids and tracing" section to the `supabase_flutter` README, plus a short pointer to it from the `supabase` README. It covers the current API: the options shape from #1882 and `requestId` from #1885. The section starts with the request id, because most people need it and it needs no setup, and covers tracing after it: - **Request id on a failure**: `requestId` on `SupabaseException`, what to do with it (log explorer, support), that `toString()` includes it, the `sb-request-id`/`x-request-id` fallback, and when it is `null`. - **Trace propagation**: opt-in through `TracePropagationOptions`, with recipes for Sentry (`formatAsW3CHeader(span.toSentryTrace())` plus baggage), OpenTelemetry (the global propagator into a map, then `TraceContext.fromCarrier`), and `TraceContext.w3c` for other tracing tools. - Which hosts receive the headers (third-party hosts never do), that realtime broadcasts over HTTP carry them but the WebSocket does not, and how sampling works with `respectSamplingDecision`. ## Testing The Sentry, OpenTelemetry, `TraceContext.w3c` and `requestId` snippets were compiled in a scratch project against this branch's packages, `sentry` 9.22.0 and `opentelemetry` 0.18.11, and `dart analyze` reports no issues. ## Not in this PR The ticket also asks for an entry in the Dart reference spec in supabase/supabase. That repository only has `supabase_dart_v1.yml` and `supabase_dart_v2.yml`, and both features only exist in 3.0.0, so the entry has to go into a v3 spec once one exists. Part of SDK-1939. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Added guidance on using request IDs from client exceptions to locate corresponding server logs across authentication, database, storage, and functions requests. * Documented optional trace propagation for correlating requests with traces, including Sentry and OpenTelemetry examples. * Clarified how request IDs are selected or may be unavailable, and described trace-header validation, destination restrictions, and sampling behavior. * Noted that traced requests may forward trace headers across redirects to another host on VM clients. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
TracePropagationOptionshad two switches that had to agree, which left two dead states:enabled: truewithout a provider sent nothing, and a provider withenabled: falsewas never called.enabledwas read exactly once, to decide whether to wrap the HTTP client, so it could not be toggled at runtime anyway.This collapses the two into one:
TracePropagationOptions.enabledis gone andtraceContextProvideris required.tracePropagationOptionsparameter onSupabaseClientandSupabase.initializeis nullable and defaults tonull, which means off.TracePropagationClientno longer warns about a missing provider, since that state cannot be constructed anymore. The malformedtraceparentwarning is unchanged.Breaking change
supabaseandsupabase_flutterare at3.0.0-dev.7, so this lands before 3.0.0 ships.MIGRATION.mdgets a section under v3 andsdk-compliance.yamldrops the removed symbol.Testing
melos analyzeandmelos formatare clean.dart testinpackages/supabaseandflutter testinpackages/supabase_flutterpass. The test for the warning on a missing provider is removed with the state it covered, and the disabled-client test now passes no options.capability-matrix-v1.9.0tooling.Closes SDK-1938.
Summary by CodeRabbit
TracePropagationOptions; theenabledflag is no longer available.