Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/platforms/dart/common/features/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ Sentry's Dart SDK enables automatic reporting of errors and exceptions, and iden
- <PlatformLink to="/enriching-events/breadcrumbs/#automatic-breadcrumbs">Dart SDK</PlatformLink>.
- <PlatformLink to="/integrations/logging">Logging Integration</PlatformLink>.
- <PlatformLink to="/integrations/dio">Dio Integration</PlatformLink>.
- <PlatformLink to="/enriching-events/attachments/">Attachments</PlatformLink> enrich your event by storing additional files, such as config or log files.
- <PlatformLink to="/user-feedback/">User Feedback</PlatformLink> provides the ability to collect user information when an event occurs.
- <PlatformLink to="/enriching-events/attachments/">Attachments</PlatformLink> enrich
your event by storing additional files, such as config or log files.
- <PlatformLink to="/user-feedback/">User Feedback</PlatformLink> provides the
ability to collect user information when an event occurs.
- <Link to="/product/insights/overview">Tracing</Link> creates transactions for:
- <PlatformLink to="/integrations/http-integration/#performance-monitoring-for-http-requests">HTTP requests</PlatformLink>.
- <PlatformLink to="/integrations/dio/#performance-monitoring-for-http-requests">Dio HTTP library</PlatformLink>.
- <PlatformLink to="/integrations/file">File I/O Integration</PlatformLink>.
- <PlatformLink to="/metrics/">Metrics</PlatformLink> allow you to send
counters, gauges, and distributions to track application health alongside
errors and traces.
30 changes: 30 additions & 0 deletions docs/platforms/dart/common/metrics/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Set Up Metrics
sidebar_title: 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."
sidebar_order: 5756
beta: true
---

With Sentry Metrics, 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.

<Alert>
This feature is currently in open beta. Features in beta are still in progress
and may have bugs.
</Alert>

## Requirements

<PlatformContent includePath="metrics/requirements" />

## Usage

<PlatformContent includePath="metrics/usage" />

## Options

<PlatformContent includePath="metrics/options" />

## Default Attributes

<PlatformContent includePath="metrics/default-attributes" />
48 changes: 28 additions & 20 deletions docs/platforms/dart/guides/flutter/features/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,43 @@ Sentry's Flutter SDK enables automatic reporting of errors and exceptions, and i
**Features:**

- Under the hood the SDK relies on <Link to="/platforms/dart">Sentry's Dart SDK</Link>:
- You need at least Dart `3.5.0` and Flutter `3.24.0`.
- This SDK includes all the <Link to="/platforms/dart/features">Features of Sentry's Dart SDK</Link>.
- You need at least Dart `3.5.0` and Flutter `3.24.0`.
- This SDK includes all the <Link to="/platforms/dart/features">Features of Sentry's Dart SDK</Link>.
- Automatic native crash error tracking (using both <Link to="/platforms/android">Android</Link> and <Link to="/platforms/apple/guides/ios">iOS</Link>), including:
- Java, Kotlin, C, and C++ code for Android.
- ObjC, Swift, and C for iOS.
- Java, Kotlin, C, and C++ code for Android.
- ObjC, Swift, and C for iOS.
- Automatic detection of <Link to="/platforms/android/configuration/app-not-respond">Application Not Responding (ANR)</Link> on Android and <Link to="/platforms/apple/guides/ios/configuration/app-hangs/">App Hangs</Link> on iOS.
- Offline storage of events.
- Events <PlatformLink to="/enriching-events/context">enriched</PlatformLink> with device data.
- Breadcrumbs automatically captured:
- by the <PlatformLink to="/enriching-events/breadcrumbs/#automatic-breadcrumbs">Flutter SDK</PlatformLink>.
- via the Native SDKs <Link to="/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs">Automatic Breadcrumbs for Android</Link> and <Link to="/platforms/apple/enriching-events/breadcrumbs/#automatic-breadcrumbs">Automatic Breadcrumbs for iOS</Link>.
- as well as `http` with the <Link to="/platforms/dart/enriching-events/breadcrumbs/#automatic-breadcrumbs">Dart SDK</Link>.
- by the <PlatformLink to="/enriching-events/breadcrumbs/#automatic-breadcrumbs">Flutter SDK</PlatformLink>.
- via the Native SDKs <Link to="/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs">Automatic Breadcrumbs for Android</Link> and <Link to="/platforms/apple/enriching-events/breadcrumbs/#automatic-breadcrumbs">Automatic Breadcrumbs for iOS</Link>.
- as well as `http` with the <Link to="/platforms/dart/enriching-events/breadcrumbs/#automatic-breadcrumbs">Dart SDK</Link>.
- Integrations for sqflite, routing and more. For a complete list, see <PlatformLink to="/integrations">integrations</PlatformLink>.
- <Link to="/product/releases/health">Release Health</Link> tracks crash free users and sessions.
- <PlatformLink to="/enriching-events/attachments">Attachments</PlatformLink> that can enrich your event by storing additional files, such as config or log files.
- <Link to="/product/releases/health">Release Health</Link> tracks crash free
users and sessions.
- <PlatformLink to="/enriching-events/attachments">Attachments</PlatformLink> that
can enrich your event by storing additional files, such as config or log
files.
- <PlatformLink to="/tracing">Tracing</PlatformLink> that can track:
- <PlatformLink to="/integrations/app-start-instrumentation">App start time</PlatformLink>.
- <PlatformLink to="/integrations/routing-instrumentation/#time-to-initial-display">Time to Initial Display and Time to Full Display</PlatformLink>.
- <PlatformLink to="/integrations/slow-and-frozen-frames-instrumentation">Slow and Frozen Frames</PlatformLink>.
- <PlatformLink to="/integrations/user-interaction-instrumentation">User Interaction</PlatformLink> which include clicks, long clicks, taps and so on.
- For a complete list see <PlatformLink to="/tracing/instrumentation/automatic-instrumentation">automatic instrumentations</PlatformLink>.
- <PlatformLink to="/user-feedback">User Feedback</PlatformLink>, providing the ability to collect user feedback when an unexpected event occurs.
- <PlatformLink to="/integrations/app-start-instrumentation">App start time</PlatformLink>
- <PlatformLink to="/integrations/routing-instrumentation/#time-to-initial-display">Time to Initial Display and Time to Full Display</PlatformLink>
- <PlatformLink to="/integrations/slow-and-frozen-frames-instrumentation">Slow and Frozen Frames</PlatformLink>
- <PlatformLink to="/integrations/user-interaction-instrumentation">User Interaction</PlatformLink> which include clicks, long clicks, taps and so on.
- For a complete list see <PlatformLink to="/tracing/instrumentation/automatic-instrumentation">automatic instrumentations</PlatformLink>.
- <PlatformLink to="/user-feedback">User Feedback</PlatformLink>, providing the
ability to collect user feedback when an unexpected event occurs.
- <PlatformLink to="/enriching-events/screenshots">Screenshot</PlatformLink> and <PlatformLink to="/enriching-events/viewhierarchy">View Hierarchy</PlatformLink> attachments for errors.
- <PlatformLink to="/profiling">Profiling</PlatformLink> collects detailed information about your code at the function level.
- Profiling is currently supported on **iOS** and **macOS**.
- It captures profiles across multiple language layers, including native languages (such as Swift and Objective-C) as well as Dart.
- <PlatformLink to="/profiling">Profiling</PlatformLink> collects detailed
information about your code at the function level.
- Profiling is currently supported on **iOS** and **macOS**.
- It captures profiles across multiple language layers, including native languages (such as Swift and Objective-C) as well as Dart.
- <PlatformLink to="/data-management/debug-files/source-context">Source Context</PlatformLink> shows snippets of code around the location of stack frames.
- <PlatformLink to="/upload-debug">Sentry Dart Plugin</PlatformLink> makes uploading debug symbols easy and automatic.
- <PlatformLink to="/upload-debug">Sentry Dart Plugin</PlatformLink> makes
uploading debug symbols easy and automatic.
- <PlatformLink to="/metrics">Metrics</PlatformLink> allow you to send counters,
gauges, and distributions to track application health alongside errors and
traces.

**Web Limitations:**

Expand All @@ -55,4 +64,3 @@ Sentry supports Flutter on Linux and Windows as well, with the following limitat
- [Release Health](/product/releases/health/) isn't supported.

When running on macOS, you can expect the same feature set as on iOS.

15 changes: 15 additions & 0 deletions platform-includes/metrics/default-attributes/dart.flutter.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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 |
12 changes: 12 additions & 0 deletions platform-includes/metrics/default-attributes/dart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
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 |
| `user.id`, `user.name`, `user.email` | User identifiers | If `sendDefaultPii` enabled |
| `sentry.replay_id` | Session replay ID | If replay available |
53 changes: 53 additions & 0 deletions platform-includes/metrics/options/dart.flutter.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<SplitLayout>
<SplitSection>
<SplitSectionText>

### beforeSendMetric

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

</SplitSectionText>
<SplitSectionCode>

```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;
};
});
```

</SplitSectionCode>
</SplitSection>

<SplitSection>
<SplitSectionText>

### Disable Metrics

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

</SplitSectionText>
<SplitSectionCode>

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

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

</SplitSectionCode>
</SplitSection>
</SplitLayout>
54 changes: 54 additions & 0 deletions platform-includes/metrics/options/dart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<SplitLayout>
<SplitSection>
<SplitSectionText>

### beforeSendMetric

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

</SplitSectionText>
<SplitSectionCode>

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

await Sentry.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;
};
});
```

</SplitSectionCode>
</SplitSection>

<SplitSection>
<SplitSectionText>

### Disable Metrics

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

</SplitSectionText>
<SplitSectionCode>

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

// Disable metrics
await Sentry.init((options) {
options.dsn = '___PUBLIC_DSN___';
options.enableMetrics = false;
});
```

</SplitSectionCode>
</SplitSection>
</SplitLayout>
1 change: 1 addition & 0 deletions platform-includes/metrics/requirements/dart.flutter.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Metrics are supported in Sentry Flutter SDK version `9.11.0` and above.
1 change: 1 addition & 0 deletions platform-includes/metrics/requirements/dart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Metrics are supported in Sentry Dart SDK version `9.11.0` and above.
128 changes: 128 additions & 0 deletions platform-includes/metrics/usage/dart.flutter.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<SplitLayout>
<SplitSection>
<SplitSectionText>

### 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.

</SplitSectionText>
<SplitSectionCode>

```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',
);
```

</SplitSectionCode>
</SplitSection>
</SplitLayout>

### Attributes

<SplitLayout>
<SplitSection>
<SplitSectionText>

#### 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.

</SplitSectionText>
<SplitSectionCode>

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

</SplitSectionCode>
</SplitSection>

<SplitSection>
<SplitSectionText>

#### Scope Attributes

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

</SplitSectionText>
<SplitSectionCode>

```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',
);
```

</SplitSectionCode>
</SplitSection>

<SplitSection>
<SplitSectionText>

#### 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/telemetry/attributes/#units) for the full list.

</SplitSectionText>
<SplitSectionCode>

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

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

</SplitSectionCode>
</SplitSection>
</SplitLayout>
Loading