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

OpenTelemetry instrumentation for `package:get_it`. Wraps async singleton registration and lookup with spans so DI bootstrap cost is visible in your traces.

dartastic_get_it_otel #

OpenTelemetry instrumentation for package:get_it.

final getIt = GetIt.instance;

// App startup: track DI bootstrap cost
getIt.tracedRegisterSingletonAsync<DatabaseService>(() async {
  return DatabaseService(await openDatabase('app.db'));
});
getIt.tracedRegisterSingletonAsync<AuthService>(() async {
  return AuthService(await FirebaseAuth.instance);
});

await getIt.tracedAllReady();

// Test teardown / hot reload
await getIt.tracedReset();

Spans:

  • get_it register_async DatabaseService — covers the async factory's run time, parented to whatever span you're in
  • get_it all_ready GetIt — the total bootstrap wait
  • get_it reset GetIt
  • get_it get_async <T> — for getAsync<T>() resolution
  • get_it unregister <T>

All carry di.system = get_it, di.operation, di.type.

Why no sync get<T>() wrap? #

Synchronous resolution is sub-microsecond on the hot path. A span per getIt<Foo>() would produce gigabytes of low-value trace data. Use the async variants when you want visibility, or wrap individual call sites yourself if you have a specific service whose lookup cost matters.

Suppression: runWithoutGetItInstrumentationAsync.

License #

Apache 2.0

0
likes
130
points
88
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

OpenTelemetry instrumentation for `package:get_it`. Wraps async singleton registration and lookup with spans so DI bootstrap cost is visible in your traces.

License

Apache-2.0 (license)

Dependencies

dartastic_opentelemetry, dartastic_opentelemetry_api, get_it

More

Packages that depend on otel_get_it