otel_sqflite 0.1.0 copy "otel_sqflite: ^0.1.0" to clipboard
otel_sqflite: ^0.1.0 copied to clipboard

OpenTelemetry instrumentation for `package:sqflite` / `sqflite_common`. Extensions on DatabaseExecutor wrapping query, insert, update, delete and rawQuery with `db.*` spans.

otel_sqflite #

OpenTelemetry instrumentation for package:sqflite / package:sqflite_common.

final db = await openDatabase('app.db');

final users = await db.tracedQuery('users', where: 'active = ?', whereArgs: [1]);
final id = await db.tracedInsert('users', {'name': 'Alice'});
await db.tracedUpdate('users', {'name': 'Alicia'}, where: 'id = ?', whereArgs: [id]);
await db.tracedDelete('users', where: 'id = ?', whereArgs: [id]);

final rows = await db.tracedRawQuery(
  'SELECT * FROM users WHERE created > ?',
  [DateTime.now().subtract(Duration(days: 7)).millisecondsSinceEpoch],
);

await db.tracedExecute('CREATE INDEX idx_users_name ON users(name)');

Each call emits a CLIENT span:

  • name: sqlite <op> [<table>]
  • db.system.name = sqlite
  • db.operation.name = query / insert / update / delete / raw_query / execute
  • db.collection.name = <table> (when applicable)
  • db.query.text = <sql> (for raw operations)

The extension is on DatabaseExecutor, so the same methods work inside db.transaction((txn) async { await txn.tracedInsert(...); }).

Suppression: runWithoutSqfliteInstrumentationAsync.

Caveats #

  • For tracedRawQuery / tracedExecute, the raw SQL string is recorded as db.query.text. If you concatenated parameter values into the SQL string (instead of using ? placeholders), those values land in the trace. Use bound parameters.

License #

Apache 2.0

0
likes
160
points
68
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

OpenTelemetry instrumentation for `package:sqflite` / `sqflite_common`. Extensions on DatabaseExecutor wrapping query, insert, update, delete and rawQuery with `db.*` spans.

Homepage
Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

dartastic_opentelemetry, dartastic_opentelemetry_api, sqflite_common

More

Packages that depend on otel_sqflite