DEV Community

Masatoshi Tsushima
Masatoshi Tsushima

Posted on

Monitoring Performance of Drift in Flutter App with Sentry

Drift

sqflite is introduced in the official cookbook to persist data. But Drift (a.k.a moor) is another strong option to use SQLite in Flutter app.

Sentry

Sentry is well known as error tracking tool, but also you can use to monitor performance. Competitors are Datadog/New Relic/Firebase Crashlytics.

Drift & Sentry

Unfortunately, however, there is no library available for linking Sentry with Drift. I made it with reference to sentry_sqflite.

Usage

LazyDatabase _openConnection() {
  return LazyDatabase(() async {
    final dbFolder = await getApplicationDocumentsDirectory();
    final file = File(p.join(dbFolder.path, 'db.sqlite'));
    // Use .addSentry() to wrap QueryExecutor
    return NativeDatabase.createInBackground(file).addSentry();
  });
}
Enter fullscreen mode Exit fullscreen mode

Finally, it is the measurement result:

Image description

Top comments (0)