Performance Metrics for Flutter

Learn how to attach performance metrics to your transactions or spans.

Sentry's SDKs support sending performance metrics data to Sentry. These are numeric values attached to transactions or spans that are aggregated and displayed in Sentry.

If configured, the Flutter SDK automatically collects the following performance metrics:

Sentry supports custom performance measurements on transactions: you define measurements that matter to your application (for example, memory usage, query time, or user action counts) and send them with the transaction from your SDK. They appear in Dashboards, Trace Explorer, and transaction trace detail. You can define up to 10 custom measurements per transaction; any additional ones are truncated. Configure and send them in your SDK; supported platforms:

To set a performance measurement, you need to supply the following:

  • name (string)
  • value (any numeric type - float, integer, etc.)
  • unit (string, defaults to the string none if omitted)

Sentry supports adding arbitrary custom units, but we recommend using one of the supported units listed below.

Adding custom measurements is supported in Sentry's Dart/Flutter SDK version 6.11.0 and above.

  • Transaction mode: Use setMeasurement on the active span.
  • Stream mode: There's no dedicated measurement API (and no public way to fetch the active span), so record the values as attributes on a span you create.

To use the Transaction Mode tab, set options.traceLifecycle = SentryTraceLifecycle.static during SDK initialization.

Copied
import 'package:sentry/sentry.dart';

await Sentry.startSpan('my-operation', (span) async {
  // Record custom measurements as span attributes.
  span.setAttribute('memoryUsed', SentryAttribute.int(123));
  span.setAttribute('ui.footerComponent.render', SentryAttribute.double(1.3));
  span.setAttribute('localStorageRead', SentryAttribute.int(4));
});

Units augment measurement values by giving meaning to what otherwise might be abstract numbers. Adding units also allows Sentry to offer controls - unit conversions, filters, and so on - based on those units. For values that are unitless, you can supply an empty string or none.

  • nanosecond
  • microsecond
  • millisecond
  • second
  • minute
  • hour
  • day
  • week

  • bit
  • byte
  • kilobyte
  • kibibyte
  • megabyte
  • mebibyte
  • gigabyte
  • gibibyte
  • terabyte
  • tebibyte
  • petabyte
  • pebibyte
  • exabyte
  • exbibyte

  • ratio
  • percent

If you want to explore further, you can find details about supported units in our event ingestion documentation.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").