otel_flutter_riverpod 0.1.0-beta.1 copy "otel_flutter_riverpod: ^0.1.0-beta.1" to clipboard
otel_flutter_riverpod: ^0.1.0-beta.1 copied to clipboard

Flutter overlay for `otel_riverpod`. Re-exports the OTel provider observer and adds an `OTelProviderScope` widget that installs it on the root container with one line.

otel_flutter_riverpod #

Flutter overlay for otel_riverpod.

Two things:

  1. Re-exports the core OTelRiverpodObserver + RiverpodSemantics so a Flutter app only needs one dependency on the Dartastic-Pro Riverpod integration.

  2. OTelProviderScope — a ProviderScope that 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 before runApp — the observer captures a Tracer reference at construction time.
  • The observer is created once in initState and reused across rebuilds. Like all ProviderScope instances, this widget should live at the app root; the underlying ProviderContainer outlives any individual rebuild.

License #

Apache 2.0 — see LICENSE.

0
likes
150
points
4
downloads

Documentation

API reference

Publisher

verified publisherdartastic.io

Weekly Downloads

Flutter overlay for `otel_riverpod`. Re-exports the OTel provider observer and adds an `OTelProviderScope` widget that installs it on the root container with one line.

Homepage
Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

dartastic_opentelemetry, dartastic_opentelemetry_api, flutter, flutter_riverpod, otel_riverpod

More

Packages that depend on otel_flutter_riverpod