---
title: "Application Metrics"
description: "Metrics allow you to send, view, and query counters, gauges, and distributions from your Godot Engine game to track application health and drill down into related traces, logs, and errors."
url: https://docs.sentry.io/platforms/godot/metrics/
---

# Set Up Metrics for Godot Engine

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

Metrics for Godot Engine are supported in Sentry Godot SDK version `2.0.0` and above (previously experimental since `1.4.0`).

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

Once metrics are enabled and the SDK is initialized, you can emit metrics using `SentrySDK.metrics`.

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

| Type           | Use For                                       |
| -------------- | --------------------------------------------- |
| `Counter`      | Events (matches started, items purchased)     |
| `Gauge`        | Current values (players online, memory usage) |
| `Distribution` | Value ranges (load times, frame times)        |

### [Counters](https://docs.sentry.io/platforms/godot/metrics.md#counters)

Track the number of times something happens. Each increment adds to a cumulative total:

**GDScript**

```gdscript
# Increment by 1 (default)
SentrySDK.metrics.count("match_started")

# Increment by a specific amount with attributes
SentrySDK.metrics.count("in_app_purchase", 1, {"item": "sword_of_fire"})
```

**C#**

```csharp
// Increment by 1
SentrySdk.Metrics.EmitCounter("match_started", 1);

// Increment by a specific amount with attributes
SentrySdk.Metrics.EmitCounter("in_app_purchase", 1, new Dictionary<string, object>
{
    ["item"] = "sword_of_fire",
});
```

### [Gauges](https://docs.sentry.io/platforms/godot/metrics.md#gauges)

Track current values at a point in time, like a snapshot. Sentry computes aggregates like min, max, avg, sum, and count:

**GDScript**

```gdscript
SentrySDK.metrics.gauge("players_online", lobby.get_player_count())

# With a unit
SentrySDK.metrics.gauge("memory_usage", OS.get_static_memory_usage(), SentryUnit.byte)
```

**C#**

```csharp
SentrySdk.Metrics.EmitGauge("players_online", lobby.GetPlayerCount());

// With a unit
SentrySdk.Metrics.EmitGauge("memory_usage", (long)OS.GetStaticMemoryUsage(), MeasurementUnit.Information.Byte);
```

### [Distributions](https://docs.sentry.io/platforms/godot/metrics.md#distributions)

Record numeric values to compute statistical aggregates such as p50, p95, avg, min, and max:

**GDScript**

```gdscript
SentrySDK.metrics.distribution("level_load_time", load_time, SentryUnit.millisecond)
```

**C#**

```csharp
SentrySdk.Metrics.EmitDistribution("level_load_time", loadTime, MeasurementUnit.Duration.Millisecond);
```

### [Custom Attributes](https://docs.sentry.io/platforms/godot/metrics.md#custom-attributes)

Add attributes to filter and group metrics in Sentry:

**GDScript**

```gdscript
SentrySDK.metrics.count("enemies_spawned", wave_size, {"level": "castle"})

SentrySDK.metrics.distribution("level_load_time", load_time, SentryUnit.millisecond, {
	"scene": get_tree().current_scene.name
})
```

**C#**

```csharp
SentrySdk.Metrics.EmitCounter("enemies_spawned", waveSize, new Dictionary<string, object>
{
    ["level"] = "castle",
});

SentrySdk.Metrics.EmitDistribution("level_load_time", loadTime, MeasurementUnit.Duration.Millisecond, new Dictionary<string, object>
{
    ["scene"] = GetTree().CurrentScene.Name,
});
```

Attributes support `bool`, `int`, `float`, and `String` data types. Other types will be converted to strings.

### [Global Attributes](https://docs.sentry.io/platforms/godot/metrics.md#global-attributes)

You can set global attributes that are automatically included in all metrics and logs. This is useful for attaching contextual information that should appear on every metric entry.

**GDScript**

```gdscript
# Set global attributes that apply to all metrics and logs
SentrySDK.set_attribute("level", "castle")
SentrySDK.set_attribute("difficulty", "hard")

# All subsequent metrics will include these attributes
SentrySDK.metrics.count("enemy_defeated")

# Clear when returning to the main menu
SentrySDK.remove_attribute("level")
```

**C#**

```csharp
SentrySdk.Init(options =>
{
    options.SetBeforeSendMetric(metric =>
    {
        metric.SetAttribute("level", "castle");
        metric.SetAttribute("difficulty", "hard");
        return metric;
    });
});

// All subsequent metrics will include these attributes
SentrySdk.Metrics.EmitCounter("enemy_defeated", 1);
```

The C# SDK doesn't have a scope-level attribute API yet. The before-send hook is the closest equivalent: it applies attributes to every metric.

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

For gauge and distribution metrics, you can specify a unit to help Sentry display values in a human-readable format. The `SentryUnit` singleton provides predefined constants for common units. See [supported units](https://develop.sentry.dev/sdk/foundations/data-model/attributes/#units) for the full list.

**GDScript**

```gdscript
# Duration units
SentrySDK.metrics.distribution("level_load_time", load_time, SentryUnit.millisecond)

# Information units
SentrySDK.metrics.gauge("memory_usage", OS.get_static_memory_usage(), SentryUnit.byte)

# Custom units (as strings)
SentrySDK.metrics.gauge("items_in_inventory", item_count, "item")
```

**C#**

```csharp
// Duration units
SentrySdk.Metrics.EmitDistribution("level_load_time", loadTime, MeasurementUnit.Duration.Millisecond);

// Information units
SentrySdk.Metrics.EmitGauge("memory_usage", (long)OS.GetStaticMemoryUsage(), MeasurementUnit.Information.Byte);
```

## [Automatic Metrics](https://docs.sentry.io/platforms/godot/metrics.md#automatic-metrics)

Automatic metrics help you compare frame performance, rendering load, memory use, and multiplayer connectivity across devices and scenes. Automatic metrics are disabled by default and independent of metrics you send manually.

Enable automatic metrics in the **Project Settings** under **Sentry** > **Auto Metrics**, or configure `options.auto_metrics` during [programmatic initialization](https://docs.sentry.io/platforms/godot/configuration/options.md#programmatic-configuration). See [Options](https://docs.sentry.io/platforms/godot/metrics.md#options) for available settings.

Collection pauses when the application loses focus or the operating system pauses it. Headless applications ignore focus changes but still respect OS pause. `SceneTree.paused` and `Engine.time_scale` don't affect collection.

Automatic metrics include the following attributes when available, in addition to the [default attributes](https://docs.sentry.io/platforms/godot/metrics.md#default-attributes) attached to every metric. These aren't added to manually emitted metrics.

| Attribute        | Description                                                                                                                                     |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `gpu.name`       | GPU model name; omitted in headless mode                                                                                                        |
| `cpu.cores`      | Logical CPU core count reported by Godot                                                                                                        |
| `ram.gb`         | Physical RAM reported by the OS, in GiB; unavailable on Web                                                                                     |
| `res.x`, `res.y` | Root viewport target width and height in pixels, before window stretching and after 3D scaling; omitted in headless mode                        |
| `scene`          | Full resource path of the current scene, such as `res://levels/forest.tscn`; falls back to the scene node name if no resource path is available |

Use these attributes to group performance data by hardware, resolution, or scene.

### [Frame Time and FPS](https://docs.sentry.io/platforms/godot/metrics.md#frame-time-and-fps)

Available since: `v2.4.0`

Use frame metrics to track frame duration and frame rate across players' devices.

| Metric                 | Type              | Description                                    |
| ---------------------- | ----------------- | ---------------------------------------------- |
| `game.perf.frame_time` | Distribution (ms) | Sampled elapsed time between process callbacks |
| `game.perf.fps`        | Gauge             | Engine-reported frames per second              |

The SDK randomly selects one frame from each collection interval and reports its frame time, including time spent waiting for VSync or frame limiting. Sampling may miss brief hitches.

### [Rendering](https://docs.sentry.io/platforms/godot/metrics.md#rendering)

Available since: `v2.4.0`

Rendering metrics help identify scenes with high rendering load or video memory use.

| Metric                              | Type          | Description                                                                       |
| ----------------------------------- | ------------- | --------------------------------------------------------------------------------- |
| `game.perf.render.draw_calls`       | Gauge         | Draw calls in the last rendered frame                                             |
| `game.perf.render.primitives`       | Gauge         | Vertices or indices rendered in the last frame, including depth and shadow passes |
| `game.perf.render.video_mem_used`   | Gauge (bytes) | Total video memory used, including texture, buffer, and other allocations         |
| `game.perf.render.texture_mem_used` | Gauge (bytes) | Texture memory used                                                               |
| `game.perf.render.buffer_mem_used`  | Gauge (bytes) | Render buffer memory used                                                         |

### [Memory](https://docs.sentry.io/platforms/godot/metrics.md#memory)

Available since: `v2.4.0`

Memory metrics help track process memory use and growth in object and node counts. Process memory usage is unavailable on Web; object and node counts are still collected.

| Metric                   | Type          | Description                                 |
| ------------------------ | ------------- | ------------------------------------------- |
| `game.perf.used_memory`  | Gauge (bytes) | RAM used by the game process                |
| `game.perf.object_count` | Gauge         | Instantiated objects, including nodes       |
| `game.perf.node_count`   | Gauge         | Nodes in the scene tree, including its root |

### [Network](https://docs.sentry.io/platforms/godot/metrics.md#network)

Available since: `v2.5.0`

Network metrics help diagnose multiplayer latency and traffic volume. Network metrics use only the default `SceneTree` multiplayer API; custom multiplayer APIs assigned to subtrees aren't monitored. Client, server, and mesh sessions are supported. No network metrics are emitted without an active multiplayer connection.

Peer counts work across all transports. All other measurements require ENet.

| Metric                            | Type          | Description                                                                |
| --------------------------------- | ------------- | -------------------------------------------------------------------------- |
| `game.perf.net.num_peers`         | Gauge         | Connected remote peers, excluding this instance; server and mesh only      |
| `game.perf.net.ping`              | Gauge (ms)    | Client round-trip time to the server                                       |
| `game.perf.net.ping_peer_avg`     | Gauge (ms)    | Average peer round-trip time; server and mesh only                         |
| `game.perf.net.ping_peer_max`     | Gauge (ms)    | Highest peer round-trip time; server and mesh only                         |
| `game.perf.net.packet_loss_ratio` | Gauge (ratio) | ENet's estimated outgoing packet-loss ratio toward the server; client only |
| `game.perf.net.in_rate`           | Gauge (bytes) | Bytes received per second; client and server only                          |
| `game.perf.net.out_rate`          | Gauge (bytes) | Bytes sent per second; client and server only                              |
| `game.perf.net.in_packets`        | Gauge         | UDP datagrams received per second; client and server only                  |
| `game.perf.net.out_packets`       | Gauge         | UDP datagrams sent per second; client and server only                      |

Ping includes Godot's network-processing delays, so it reflects latency experienced by the game rather than network delay alone. Traffic rates include ENet protocol traffic and retransmissions; packet rates count UDP datagrams, not RPCs or game messages.

Traffic collection resets ENet's shared byte and packet counters. Other code reading and resetting those counters affects these measurements, and vice versa.

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

Configure these properties on `options.auto_metrics`, or use the corresponding settings in the **Project Settings** under **Sentry > Auto Metrics**. Each interval applies only when the corresponding metrics are enabled.

| Option                           | Default | Available Since | Description                               |
| -------------------------------- | ------- | --------------- | ----------------------------------------- |
| `enable_frame_metrics`           | `false` | 2.4.0           | Collect frame time and FPS                |
| `enable_rendering_metrics`       | `false` | 2.4.0           | Collect rendering metrics                 |
| `enable_memory_metrics`          | `false` | 2.4.0           | Collect memory, object, and node metrics  |
| `enable_network_metrics`         | `false` | 2.5.0           | Collect network metrics                   |
| `frame_metrics_interval_sec`     | `1.0`   | 2.4.0           | Frame collection interval, in seconds     |
| `rendering_metrics_interval_sec` | `1.0`   | 2.4.0           | Rendering collection interval, in seconds |
| `memory_metrics_interval_sec`    | `60.0`  | 2.4.0           | Memory collection interval, in seconds    |
| `network_metrics_interval_sec`   | `10.0`  | 2.5.0           | Network collection interval, in seconds   |

For example, enable automatic metrics and adjust the memory interval during initialization:

**GDScript**

```GDScript
SentrySDK.init(func(options: SentryOptions) -> void:
    options.auto_metrics.enable_frame_metrics = true
    options.auto_metrics.enable_rendering_metrics = true
    options.auto_metrics.enable_memory_metrics = true
    options.auto_metrics.enable_network_metrics = true
    options.auto_metrics.memory_metrics_interval_sec = 30.0
)
```

**C#**

```csharp
SentrySdk.Init(options =>
{
    options.AutoMetrics.EnableFrameMetrics = true;
    options.AutoMetrics.EnableRenderingMetrics = true;
    options.AutoMetrics.EnableMemoryMetrics = true;
    options.AutoMetrics.EnableNetworkMetrics = true;
    options.AutoMetrics.MemoryMetricsIntervalSec = 30.0;
});
```

The following configuration options are available for Sentry's [Application Metrics](https://docs.sentry.io/product/metrics.md) in Godot Engine:

| Option                   | Description                                         | Default |
| ------------------------ | --------------------------------------------------- | ------- |
| **before\_send\_metric** | Callback to modify or filter metrics before sending | None    |

### [before\_send\_metric](https://docs.sentry.io/platforms/godot/metrics.md#before_send_metric)

To filter metrics or modify them before they are sent to Sentry, you can use the `before_send_metric` option:

**GDScript**

```gdscript
SentrySDK.init(func(options: SentryOptions) -> void:
	options.before_send_metric = _before_send_metric
)

func _before_send_metric(metric: SentryMetric) -> SentryMetric:
	# Drop debug-only metrics in release builds.
	if not OS.is_debug_build() and metric.name.begins_with("debug."):
		return null
	# Enrich with runtime context.
	metric.set_attribute("current_scene", get_tree().current_scene.name)
	return metric
```

**C#**

```csharp
SentrySdk.Init(options =>
{
    options.SetBeforeSendMetric(metric =>
    {
        // Drop debug-only metrics in release builds.
        if (!OS.IsDebugBuild() && metric.Name.StartsWith("debug."))
        {
            return null;
        }
        // Enrich with runtime context.
        metric.SetAttribute("current_scene", GetTree().CurrentScene.Name);
        return metric;
    });
});
```

The `before_send_metric` callback receives a `SentryMetric` object, and should return either the same metric object (with or without modifications) or `null` to discard it.

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

The Godot SDK automatically attaches the following attributes to every metric:

### [Core Attributes](https://docs.sentry.io/platforms/godot/metrics.md#core-attributes)

* `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](https://docs.sentry.io/platforms/godot/metrics.md#user-attributes)

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

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