otel_flutter_riverpod
Flutter overlay for otel_riverpod.
Two things:
-
Re-exports the core
OTelRiverpodObserver+RiverpodSemanticsso a Flutter app only needs one dependency on the Dartastic-Pro Riverpod integration. -
OTelProviderScope— aProviderScopethat auto-installs the OTel observer:void main() async { WidgetsFlutterBinding.ensureInitialized(); await OTel.initialize(serviceName: 'my-app'); runApp(const OTelProviderScope(child: MyApp())); }
That's the entire surface area — the actual instrumentation lives in the core package; this one is a Flutter-shaped on-switch.
Choosing this vs. plain ProviderScope
Use OTelProviderScope when you just want telemetry on:
runApp(const OTelProviderScope(child: MyApp()));
Use a plain ProviderScope directly if you also need overrides,
custom retry, or other ProviderScope arguments — the OTel
observer drops in just as easily:
runApp(
ProviderScope(
overrides: [...],
observers: [OTelRiverpodObserver()],
child: const MyApp(),
),
);
Combining with your own observers
Pass them via observers: and the OTel observer is appended:
OTelProviderScope(
observers: [MyAuditObserver(), MyDevToolsObserver()],
child: const MyApp(),
)
Your observers see events first, then OTel.
Configuration
To customize the OTel observer (record value content, change tracer,
suppress updates, …), construct it explicitly and pass it via
otelObserver::
OTelProviderScope(
otelObserver: OTelRiverpodObserver(
recordValues: true,
valueAttributeMaxLength: 128,
),
child: const MyApp(),
)
See otel_riverpod
for the full attribute reference and the span shape the observer
produces.
Caveats
OTel.initialize()must run beforerunApp— the observer captures aTracerreference at construction time.- The observer is created once in
initStateand reused across rebuilds. Like allProviderScopeinstances, this widget should live at the app root; the underlyingProviderContaineroutlives any individual rebuild.
License
Apache 2.0 — see LICENSE.
Libraries
- otel_flutter_riverpod
- Flutter overlay for
otel_riverpod.