---
title: "Asset Bundle Instrumentation"
description: "Learn more about the Sentry Asset Bundle Instrumentation for the Flutter SDK."
url: https://docs.sentry.io/platforms/dart/guides/flutter/integrations/asset-bundle-instrumentation/
---

# Asset Bundle Instrumentation | Sentry for Flutter

[AssetBundle](https://api.flutter.dev/flutter/services/AssetBundle-class.html) instrumentation provides insight into how long your app takes to load its assets, such as files.

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

The instrumentation starts a span from an active transaction that's bound to the scope of the following calls:

* `load` and `loadString` - The SDK sets the span `operation` to `file.read`.
* `loadStructuredData` - The SDK sets the span `operation` to `serialize`.

## [Prerequisites](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/asset-bundle-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).

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

Wrap the `runApp` method with a `DefaultAssetBundle` and `SentryAssetBundle`.

```dart
import 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
  await SentryFlutter.init(
    (options) => options.dsn = '___PUBLIC_DSN___',
      appRunner: () => runApp(
        DefaultAssetBundle(
          bundle: SentryAssetBundle(),
          child: MyApp(),
        ),
    ),
  );
}
```

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

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

```dart
final transaction = Sentry.startTransaction(
  'asset-bundle-transaction',
  'load',
  bindToScope: true,
);

final text = await DefaultAssetBundle.of(context).loadString('assets/lorem-ipsum.txt');

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

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

To view the recorded transaction, log into [sentry.io](https://sentry.io) and open your project. Clicking **Performance** will open a page with transactions, where you can select the just recorded transaction with the name `asset-bundle-transaction`.

## [Additional Configuration](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/asset-bundle-instrumentation.md#additional-configuration)

### [Disabling the `loadStructuredData` Feature](https://docs.sentry.io/platforms/dart/guides/flutter/integrations/asset-bundle-instrumentation.md#disabling-the-loadstructureddata-feature)

The `loadStructuredData` is an opt-out feature. The following example shows how to disable it:

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

SentryAssetBundle(enableStructuredDataTracing: false)
```
