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
30 changes: 30 additions & 0 deletions docs/platforms/android/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: 4500
sidebar_section: features
beta: true
---

With Sentry Metrics, you can send counters, gauges, distributions, and sets 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. Please reach out on [GitHub](https://github.com/getsentry/sentry-javascript/discussions/18055) if you have feedback or questions. Features in beta are still in-progress and may have bugs. We recognize the irony.
</Alert>

## Requirements

<PlatformContent includePath="metrics/requirements" />

## Usage

<PlatformContent includePath="metrics/usage" />

## Options

<PlatformContent includePath="metrics/options" />

## Default Attributes

<PlatformContent includePath="metrics/default-attributes" />
2 changes: 1 addition & 1 deletion docs/platforms/java/common/crons/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Set Up Crons
sidebar_title: Crons
description: "Sentry Crons allows you to monitor the uptime and performance of any scheduled, recurring job in your application."
sidebar_order: 5
sidebar_order: 6
sidebar_section: features
---

Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/java/common/feature-flags/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Set Up Feature Flags
sidebar_title: Feature Flags
sidebar_order: 7
sidebar_order: 8
sidebar_section: features
description: With Feature Flags, Sentry tracks feature flag evaluations in your application, keeps an audit log of feature flag changes, and reports any suspicious updates that may have caused an error.
---
Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/java/common/gradle/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Gradle
description: Learn about using the Sentry Gradle Plugin.
sidebar_order: 8
sidebar_order: 9
sidebar_section: features
og_image: /og-images/platforms-java-common-gradle.png
---
Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/java/common/maven/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Maven
description: "Learn about using the Sentry Maven Plugin."
sidebar_order: 9
sidebar_order: 10
sidebar_section: features
---

Expand Down
30 changes: 30 additions & 0 deletions docs/platforms/java/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: 4
sidebar_section: features
beta: true
---

With Sentry Metrics, you can send counters, gauges, distributions, and sets 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. Please reach out on [GitHub](https://github.com/getsentry/sentry/discussions/102275) if you have feedback or questions. Features in beta are still in-progress and may have bugs. We recognize the irony.
</Alert>

## Requirements

<PlatformContent includePath="metrics/requirements" />

## Usage

<PlatformContent includePath="metrics/usage" />

## Options

<PlatformContent includePath="metrics/options" />

## Default Attributes

<PlatformContent includePath="metrics/default-attributes" />
2 changes: 1 addition & 1 deletion docs/platforms/java/common/opentelemetry/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: OpenTelemetry Support
sdk: sentry.java.opentelemetry-agent
description: "Using OpenTelemetry with Sentry."
sidebar_order: 10
sidebar_order: 11
sidebar_section: features
---

Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/java/common/profiling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Set Up Java Profiling
sidebar_title: Profiling
description: "Learn how to enable profiling in your app if it is not already set up."
sidebar_order: 4
sidebar_order: 5
sidebar_section: features
supported:
- java
Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/java/common/user-feedback/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Set Up User Feedback
sidebar_title: User Feedback
description: "Learn more about collecting user feedback when an event occurs. Sentry pairs the feedback with the original event, giving you additional insight into issues."
sidebar_order: 6
sidebar_order: 7
sidebar_section: features
---

Expand Down
26 changes: 26 additions & 0 deletions docs/product/explore/metrics/getting-started/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,32 @@ To set up Sentry Metrics, use the links below for supported SDKs. After it's bee
url="/platforms/javascript/guides/wasm/metrics/"
/>

### Java

- <LinkWithPlatformIcon
platform="java"
label="Java"
url="/platforms/java/metrics/"
/>
- <LinkWithPlatformIcon
platform="java.spring"
label="Spring"
url="/platforms/java/guides/spring/metrics/"
/>
- <LinkWithPlatformIcon
platform="java.spring-boot"
label="Spring Boot"
url="/platforms/java/guides/spring-boot/metrics/"
/>

### Mobile

- <LinkWithPlatformIcon
platform="android"
label="Android"
url="/platforms/android/metrics/"
/>

### Python

- <LinkWithPlatformIcon
Expand Down
20 changes: 20 additions & 0 deletions platform-includes/metrics/default-attributes/android.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
By default the SDK will attach the following attributes to a metric:

- `environment`: The environment set in the SDK if defined. This is sent from the SDK as `sentry.environment`.
- `release`: The release set in the SDK if defined. This is sent from the SDK as `sentry.release`.
- `sdk.name`: The name of the SDK that sent the metric. This is sent from the SDK as `sentry.sdk.name`.
- `sdk.version`: The version of the SDK that sent the metric. This is sent from the SDK as `sentry.sdk.version`.

### User Attributes

If user information is available in the current scope, the following attributes are added to the log:

- `user.id`: The user ID.
- `user.name`: The username.
- `user.email`: The email address.

### Replay Attributes

If replay information is available in the current scope, the following attributes are added to the log:

- `sentry.replay_id`: The ID of the replay.
20 changes: 20 additions & 0 deletions platform-includes/metrics/default-attributes/java.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
By default the SDK will attach the following attributes to a metric:

- `environment`: The environment set in the SDK if defined. This is sent from the SDK as `sentry.environment`.
- `release`: The release set in the SDK if defined. This is sent from the SDK as `sentry.release`.
- `sdk.name`: The name of the SDK that sent the metric. This is sent from the SDK as `sentry.sdk.name`.
- `sdk.version`: The version of the SDK that sent the metric. This is sent from the SDK as `sentry.sdk.version`.

### User Attributes

If user information is available in the current scope, the following attributes are added to the log:

- `user.id`: The user ID.
- `user.name`: The username.
- `user.email`: The email address.

### Server Attributes

The SDK will attach the following:

- `server.address`: The address of the server that sent the metric. Equivalent to `server_name` that gets attached to Sentry errors.
85 changes: 85 additions & 0 deletions platform-includes/metrics/options/android.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
The Sentry Android SDK provides several options to configure how metrics are captured and sent to Sentry.

### Filtering and Modifying Metrics

Use the `getMetrics().beforeSend` callback to filter or modify metrics before they're sent to Sentry. This is useful for:

- Removing sensitive data from metric attributes
- Dropping metrics you don't want to send
- Adding or modifying attributes

The callback receives a metric object and must return either a modified metric or `null` to drop it.

```java {tabTitle: Java}
import io.sentry.android.core.SentryAndroid;
import io.sentry.android.core.SentryAndroidOptions;
import io.sentry.SentryAttributeType;
import io.sentry.SentryLogEventAttributeValue;

SentryAndroid.init(context,
options -> {
// ...
options.getMetrics().setBeforeSend((metric, hint) -> {
// Drop metrics with specific attributes
if (metric.getAttributes().containsKey("dropmetric")) {
return null;
}

// Modify metric attributes
metric.setAttribute("processed", new SentryLogEventAttributeValue(SentryAttributeType.BOOLEAN, true));
return metric;
});
}
);
```
```kotlin {tabTitle: Kotlin}
import io.sentry.android.core.SentryAndroid
import io.sentry.android.core.SentryAndroidOptions
import io.sentry.SentryAttributeType
import io.sentry.SentryLogEventAttributeValue

SentryAndroid.init(context) { options ->
// ...
options.metrics.setBeforeSend { metric, hint ->
// Drop metrics with specific attributes
if (metric.attributes.containsKey("dropmetric")) {
return@setBeforeSend null
}

// Modify metric attributes
metric.setAttribute(
"processed",
SentryLogEventAttributeValue(SentryAttributeType.BOOLEAN, true)
)
metric
}
}
```

### Disabling Metrics

If you want to disable metrics collection entirely, you can do so by disabling the `metrics.enabled` flag:

```xml {tabTitle: XML}
<meta-data android:name="io.sentry.metrics.enabled" android:value="false" />
```
```java {tabTitle: Java}
import io.sentry.android.core.SentryAndroid;
import io.sentry.android.core.SentryAndroidOptions;

SentryAndroid.init(context,
options -> {
// ...
options.getMetrics().setEnabled(false);
}
);
```
```kotlin {tabTitle: Kotlin}
import io.sentry.android.core.SentryAndroid
import io.sentry.android.core.SentryAndroidOptions

SentryAndroid.init { options ->
// ...
options.metrics.setEnabled(false)
}
```
78 changes: 78 additions & 0 deletions platform-includes/metrics/options/java.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
The Sentry Java SDK provides several options to configure how metrics are captured and sent to Sentry.

### Filtering and Modifying Metrics

Use the `getMetrics().beforeSend` callback to filter or modify metrics before they're sent to Sentry. This is useful for:

- Removing sensitive data from metric attributes
- Dropping metrics you don't want to send
- Adding or modifying attributes

The callback receives a metric object and must return either a modified metric or `null` to drop it.

```java {tabTitle: Java}
import io.sentry.Sentry;
import io.sentry.SentryAttributeType;
import io.sentry.SentryLogEventAttributeValue;

Sentry.init(
options -> {
// ...
options.getMetrics().setBeforeSend((metric, hint) -> {
// Drop metrics with specific attributes
if (metric.getAttributes().containsKey("dropmetric")) {
return null;
}

// Modify metric attributes
metric.setAttribute("processed", new SentryLogEventAttributeValue(SentryAttributeType.BOOLEAN, true));
return metric;
});
}
);
```
```kotlin {tabTitle: Kotlin}
import io.sentry.Sentry
import io.sentry.SentryAttributeType
import io.sentry.SentryLogEventAttributeValue

Sentry.init { options ->
// ...
options.metrics.setBeforeSend { metric, hint ->
// Drop metrics with specific attributes
if (metric.attributes.containsKey("dropmetric")) {
return@setBeforeSend null
}

// Modify metric attributes
metric.setAttribute(
"processed",
SentryLogEventAttributeValue(SentryAttributeType.BOOLEAN, true)
)
metric
}
}
```

### Disabling Metrics

If you want to disable metrics collection entirely, you can do so by disabling the `metrics.enabled` flag:

```java {tabTitle: Java}
import io.sentry.Sentry;

Sentry.init(
options -> {
// ...
options.getMetrics().setEnabled(false);
}
);
```
```kotlin {tabTitle: Kotlin}
import io.sentry.Sentry

Sentry.init { options ->
// ...
options.metrics.setEnabled(false)
}
```
Loading
Loading