---
title: "Isar Database Instrumentation"
description: "Learn more about the Sentry Isar Database Instrumentation for the Flutter SDK."
url: https://docs.sentry.io/platforms/dart/guides/flutter/integrations/isar-instrumentation/
---

# Isar Database Instrumentation | Sentry for Flutter

References to "transactions" on this page apply to the default transaction mode. In stream mode, this integration creates service spans instead, and Sentry sends them as they finish. See [Streamed Spans](https://docs.sentry.io/platforms/dart/guides/flutter/tracing/streamed-spans.md) for more information.

This feature is currently in Beta. Beta features are still in progress and may have bugs. We recognize the irony.

*(New in version 7.16.0)*

Isar is a fast cross-platform database for Flutter. The [sentry\_isar](https://pub.dev/packages/sentry_isar) package provides `Isar` support for database instrumentation and allows you to track the performance of your queries.

## [Instrumentation Behaviour](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/isar-instrumentation.md#instrumentation-behaviour)

The created spans attach to the active span. In transaction mode, that's the transaction bound to the scope; in stream mode, it's the span started with `Sentry.startSpan()`. If no span is active, the Isar span won't be sent to Sentry.

## [Prerequisites](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/isar-instrumentation.md#prerequisites)

Before starting, ensure:

1. The Sentry Flutter SDK is initialized. Learn more [here](https://docs.sentry.io/platforms/dart/guides/flutter.md#configure).
2. Tracing is set up. Learn more [here](https://docs.sentry.io/platforms/dart/guides/flutter/tracing.md).

## [Install](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/isar-instrumentation.md#install)

Add the `sentry_isar` dependency to install the Isar database instrumentation.

```yml
dependencies:
sentry_flutter: ^9.26.0
sentry_isar: ^9.26.0
path_provider: ^2.0.0
```

## [Configure](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/isar-instrumentation.md#configure)

Use `SentryIsar` to initialize the instance:

```dart
import 'package:path_provider/path_provider.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_isar/sentry_isar.dart';

import 'user.dart'; // Import your Isar model instead

final dir = await getApplicationDocumentsDirectory();
final isar = await SentryIsar.open(
  [UserSchema],
  directory: dir.path,
);
```

## [Verify](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/isar-instrumentation.md#verify)

### [1. Execute the Code](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/isar-instrumentation.md#1-execute-the-code)

**Transaction Mode (Default)**

```dart
import 'package:path_provider/path_provider.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_isar/sentry_isar.dart';

import 'user.dart'; // Import your Isar model instead

Future<void> runApp() async {
  final tr = Sentry.startTransaction('isarTest', 'db', bindToScope: true);

  final dir = await getApplicationDocumentsDirectory();

  final isar = await SentryIsar.open(
    [UserSchema],
    directory: dir.path,
  );

  final newUser = User()
    ..name = 'Joe Dirt'
    ..age = 36;

  await isar.writeTxn(() async {
    await isar.users.put(newUser); // insert & update
  });

  final existingUser = await isar.users.get(newUser.id); // get

  await isar.writeTxn(() async {
    await isar.users.delete(existingUser!.id); // delete
  });

  await tr.finish(status: const SpanStatus.ok());
}
```

**Stream Mode**

```dart
import 'package:path_provider/path_provider.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_isar/sentry_isar.dart';

import 'user.dart'; // Import your Isar model instead

Future<void> runApp() async {
  await Sentry.startSpan('isarTest', (span) async {
    final dir = await getApplicationDocumentsDirectory();

    final isar = await SentryIsar.open(
      [UserSchema],
      directory: dir.path,
    );

    final newUser = User()
      ..name = 'Joe Dirt'
      ..age = 36;

    await isar.writeTxn(() async {
      await isar.users.put(newUser); // insert & update
    });

    final existingUser = await isar.users.get(newUser.id); // get

    await isar.writeTxn(() async {
      await isar.users.delete(existingUser!.id); // delete
    });
  }, parentSpan: null);
}
```

### [2. View the Transaction on Sentry.io](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/isar-instrumentation.md#2-view-the-transaction-on-sentryio)

To view the recorded transaction, log into [sentry.io](https://sentry.io). Use the left sidebar to navigate to the **Performance** page. Select your project and scroll down to the transactions table to see the just recorded transaction with the name `isarTest`. You can also use the search bar to find the transaction. Click on the transaction to open its **Transaction Summary** page for more performance details.
