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
34 changes: 34 additions & 0 deletions docs/platforms/unreal/metrics/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: Set Up Metrics
sidebar_title: Metrics
description: "Metrics allow you to send, view and query counters, gauges and distributions from your Unreal Engine game to track application health and drill down into related traces, logs, and errors."
sidebar_order: 5700
beta: true
---

With Sentry Metrics, you can send counters, gauges, and distributions from your Unreal Engine game 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" />

## Setup

<PlatformContent includePath="metrics/setup" />

## Usage

<PlatformContent includePath="metrics/usage" />

## Options

<PlatformContent includePath="metrics/options" />

## Default Attributes

<PlatformContent includePath="metrics/default-attributes" />
8 changes: 8 additions & 0 deletions docs/product/explore/metrics/getting-started/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ To set up Sentry Metrics, use the links below for supported SDKs. After it's bee
url="/platforms/go/metrics/"
/>

### Gaming

- <LinkWithPlatformIcon
platform="unreal"
label="Unreal Engine"
url="/platforms/unreal/metrics/"
/>

## Upcoming SDKs

We're actively working on adding Metrics functionality to additional SDKs. Check out these GitHub issues for the latest updates:
Expand Down
5 changes: 5 additions & 0 deletions platform-includes/metrics/default-attributes/unreal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The Unreal Engine SDK automatically attaches the following attributes to every metric:

<Include name="metrics/default-attributes/core" />

<Include name="metrics/default-attributes/user" />
42 changes: 42 additions & 0 deletions platform-includes/metrics/options/unreal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
The following configuration options are available for Sentry Metrics in Unreal Engine:

| Option | Description | Default |
|--------|-------------|---------|
| **Enable Metrics** | Master toggle for the metrics feature | `false` |
| **Before Metric Handler** | Handler to modify or filter metrics before sending | None |

### Before-Metric Handler

To filter metrics or modify them before they are sent to Sentry, create a custom before-metric handler class:

```cpp
UCLASS()
class UCustomMetricFilter : public USentryBeforeMetricHandler
{
GENERATED_BODY()
public:
virtual USentryMetric* HandleBeforeMetric_Implementation(USentryMetric* Metric) override
{
// Drop metrics with specific names
if (Metric->GetName().Contains(TEXT("debug")))
{
return nullptr; // Return null to prevent sending
}

// Modify metric attributes
Metric->SetAttribute(TEXT("build"), FSentryVariant(TEXT("production")));

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

Configure the handler in project settings under **Hooks > Custom `beforeMetric` event handler**, or set it programmatically:

```cpp
SentrySubsystem->InitializeWithSettings(FConfigureSettingsNativeDelegate::CreateLambda([=](USentrySettings* Settings)
{
Settings->EnableMetrics = true;
Settings->BeforeMetricHandler = UCustomMetricFilter::StaticClass();
}));
```
1 change: 1 addition & 0 deletions platform-includes/metrics/requirements/unreal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Metrics for Unreal Engine are supported in Sentry Unreal Engine SDK version `1.7.0` and above.
24 changes: 24 additions & 0 deletions platform-includes/metrics/setup/unreal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
To enable metrics in your Unreal Engine project, you need to configure the Sentry SDK with metrics enabled.

### Project Settings Configuration

1. Open your project settings: **Project Settings > Plugins > Sentry**
2. Check the **Enable Metrics** option

### Programmatic Configuration

Alternatively, you can enable metrics programmatically when initializing the SDK:

```cpp
#include "SentrySubsystem.h"

void ConfigureSentryWithMetrics()
{
USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();

SentrySubsystem->InitializeWithSettings(FConfigureSettingsNativeDelegate::CreateLambda([=](USentrySettings* Settings)
{
Settings->EnableMetrics = true;
}));
}
```
71 changes: 71 additions & 0 deletions platform-includes/metrics/usage/unreal.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Once metrics are enabled, you can emit metrics using the Sentry subsystem.

### Metric Types

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

### Counters

Track the number of times something happens:

```cpp
#include "SentrySubsystem.h"

USentrySubsystem* SentrySubsystem = GEngine->GetEngineSubsystem<USentrySubsystem>();

SentrySubsystem->AddCount(TEXT("api.requests"), 1);
```

### Gauges

Track current values that can go up or down:

```cpp
SentrySubsystem->AddGauge(TEXT("active_connections"), 42, USentryUnitHelper::MakeSentryUnit(ESentryUnit::None));
```

### Distributions

Track a range of values (e.g., response times):

```cpp
SentrySubsystem->AddDistribution(TEXT("response.time"), 150.5f, USentryUnitHelper::MakeSentryUnit(ESentryUnit::Millisecond));
```

### Custom Attributes

Add attributes to filter and group metrics in Sentry:

```cpp
TMap<FString, FSentryVariant> Attributes;
Attributes.Add(TEXT("endpoint"), FSentryVariant(TEXT("/api/orders")));
Attributes.Add(TEXT("region"), FSentryVariant(TEXT("us-west")));

SentrySubsystem->AddCountWithAttributes(TEXT("api.calls"), 1, Attributes);
```

All metric methods have a `WithAttributes` variant:
- `AddCountWithAttributes()`
- `AddDistributionWithAttributes()`
- `AddGaugeWithAttributes()`

### Units

For gauge and distribution metrics, specify a unit to help Sentry display values in a human-readable format. The SDK provides the `ESentryUnit` enum with predefined units for duration, information, and fraction categories:

```cpp
// Using predefined units
SentrySubsystem->AddGauge(TEXT("memory.usage"), 1024.0f, USentryUnitHelper::MakeSentryUnit(ESentryUnit::Byte));
SentrySubsystem->AddDistribution(TEXT("latency"), 42.5f, USentryUnitHelper::MakeSentryUnit(ESentryUnit::Millisecond));

// Using a custom unit
SentrySubsystem->AddDistribution(TEXT("frame.rate"), 60.0f, USentryUnitHelper::MakeSentryCustomUnit(TEXT("fps")));
```

### Blueprint Support

You can also emit metrics from Blueprints by calling the **Add Count**, **Add Distribution**, or **Add Gauge** nodes on the Sentry subsystem. Use the **Make Sentry Unit** node to specify measurement units.