---
title: "Application Metrics"
description: "Metrics allow you to send, view and query counters, gauges and measurements from your Sentry-configured apps to track application health and drill down into related traces, logs, and errors."
url: https://docs.sentry.io/platforms/dart/guides/flutter/metrics/
---

# Set Up Metrics | Sentry for Flutter

With Sentry's [Application Metrics](https://docs.sentry.io/product/explore/metrics.md), you can send counters, gauges, and distributions from your applications to Sentry. Once in Sentry, these metrics can be viewed alongside relevant errors, and searched using their individual attributes.

## [Requirements](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#requirements)

Metrics are supported in Sentry Flutter SDK version `9.11.0` and above.

## [Usage](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#usage)

### [Metric Types](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#metric-types)

| Type           | Use For                                      |
| -------------- | -------------------------------------------- |
| `count`        | Events (orders, clicks, API calls)           |
| `gauge`        | Current values (queue depth, connections)    |
| `distribution` | Value ranges (response times, payload sizes) |

No setup required beyond SDK initialization.

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

// Count occurrences
Sentry.metrics.count('orders_created', 1);

// Track current values
Sentry.metrics.gauge('active_connections', 42);

// Track distributions
Sentry.metrics.distribution(
  'api_latency',
  187,
  unit: 'millisecond',
);
```

### [Attributes](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#attributes)

#### [Filtering and Grouping](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#filtering-and-grouping)

Attributes let you filter and group metrics in Sentry. Use them for:

* Environment segmentation
* Feature flag tracking
* User tier analysis

Each metric has a **2KB size limit**. If you exceed this, the metric will be dropped.

```dart
Sentry.metrics.count(
  'api_calls',
  1,
  attributes: {
    'endpoint': SentryAttribute.string('/api/orders'),
    'user_tier': SentryAttribute.string('pro'),
    'region': SentryAttribute.string('us-west'),
  },
);
```

#### [Scope Attributes](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#scope-attributes)

Use scope APIs to set attributes that apply to all metrics while the scope is active.

```dart
// Add attributes to the global scope
Sentry.setAttributes({'is_admin': SentryAttribute.bool(true)});

// All scope attributes are added to metrics
Sentry.metrics.count('clicks', 1);
Sentry.metrics.gauge(
  'time_since_refresh',
  4,
  unit: 'second',
);
```

#### [Units](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#units)

For `gauge` and `distribution` metrics, specify a unit to help Sentry display values in a human-readable format.

Common units: `millisecond`, `second`, `byte`, `kilobyte`, `megabyte`. Use `SentryMetricUnit` to conveniently access supported units in Dart. See [supported units](https://develop.sentry.dev/sdk/foundations/data-model/attributes/#units) for the full list.

```dart
Sentry.metrics.distribution(
  'response_time',
  187.5,
  unit: SentryMetricUnit.millisecond,
);

Sentry.metrics.gauge(
  'memory_usage',
  1024,
  unit: SentryMetricUnit.byte,
);
```

## [Options](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#options)

### [beforeSendMetric](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#beforesendmetric)

Filter or modify metrics before sending. Return `null` to drop a metric.

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

await SentryFlutter.init((options) {
  options.dsn = '___PUBLIC_DSN___';
  options.beforeSendMetric = (metric) {
    // Drop specific metrics
    if (metric.attributes.containsKey('debug')) {
      return null;
    }

    // Return the metric to send it
    return metric;
  };
});
```

### [Disable Metrics](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#disable-metrics)

Set `enableMetrics: false` to disable metrics collection entirely.

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

await SentryFlutter.init((options) {
  options.dsn = '___PUBLIC_DSN___';
  options.enableMetrics = false;
});
```

## [Default Attributes](https://docs.sentry.io/platforms/dart/guides/flutter/metrics.md#default-attributes)

Sentry automatically attaches these attributes to every metric:

| Attribute                            | Description                     | Context                     |
| ------------------------------------ | ------------------------------- | --------------------------- |
| `sentry.environment`                 | Environment from SDK config     | Always                      |
| `sentry.release`                     | Release version from SDK config | Always                      |
| `sentry.sdk.name`                    | SDK name                        | Always                      |
| `sentry.sdk.version`                 | SDK version                     | Always                      |
| `os.name`                            | Operating system name           | If available                |
| `os.version`                         | Operating system version        | If available                |
| `device.brand`                       | Device manufacturer             | If available                |
| `device.model`                       | Device model name               | If available                |
| `device.family`                      | Device family                   | If available                |
| `user.id`, `user.name`, `user.email` | User identifiers                | If `sendDefaultPii` enabled |
| `sentry.replay_id`                   | Session replay ID               | If replay available         |
