otel_drift 0.2.0 copy "otel_drift: ^0.2.0" to clipboard
otel_drift: ^0.2.0 copied to clipboard

OpenTelemetry instrumentation for package:drift. A drift QueryInterceptor emitting db.system.name=sqlite CLIENT spans per statement, plus traced call-site helpers.

otel_drift #

OpenTelemetry instrumentation for package:drift.

Auto-instrumentation #

Wrap the QueryExecutor you open your database with (drift >= 2.14):

class AppDatabase extends _$AppDatabase {
  AppDatabase(File file)
      : super(NativeDatabase.createInBackground(file)
            .interceptWith(OTelDriftInterceptor()));
}

Every statement drift runs — select / insert / update / delete / custom / batch, plus transaction commit and rollback — gets a CLIENT span:

  • name: drift <operation>
  • db.system.name = sqlite, db.operation.name = <operation>
  • db.operation.batch.size on batches
  • db.query.text only with OTelDriftInterceptor(captureQueryText: true) — off by default, statements can embed sensitive literals

Call-site helpers #

For spans labelled with the intent (which table, which operation) rather than the generated SQL, wrap DAO calls:

final user = await tracedDriftQuery<User>(
  operation: 'select',
  table: 'users',
  invoke: () => (db.select(db.users)..where((u) => u.id.equals(id)))
      .getSingle(),
);

await tracedDriftTransaction(() async {
  await db.into(db.users).insert(...);
  await db.into(db.orders).insert(...);
});

These add db.collection.name = <table> and name the span drift <operation> <table>.

Suppression: runWithoutDriftInstrumentation / runWithoutDriftInstrumentationAsync.

License #

Apache 2.0

0
likes
160
points
82
downloads

Documentation

API reference

Publisher

verified publisherdartastic.io

Weekly Downloads

OpenTelemetry instrumentation for package:drift. A drift QueryInterceptor emitting db.system.name=sqlite CLIENT spans per statement, plus traced call-site helpers.

Homepage
Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

dartastic_opentelemetry, dartastic_opentelemetry_api, drift

More

Packages that depend on otel_drift