Set Up Metrics for Godot EngineNEW

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.

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

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

TypeUse For
CounterEvents (matches started, items purchased)
GaugeCurrent values (players online, memory usage)
DistributionValue ranges (load times, frame times)

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

Copied
# 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"})

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

Copied
SentrySDK.metrics.gauge("players_online", lobby.get_player_count())

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

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

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

Add attributes to filter and group metrics in Sentry:

Copied
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
})

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

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.

Copied
# 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")

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 for the full list.

Copied
# 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")

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. See 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 attached to every metric. These aren't added to manually emitted metrics.

AttributeDescription
gpu.nameGPU model name; omitted in headless mode
cpu.coresLogical CPU core count reported by Godot
ram.gbPhysical RAM reported by the OS, in GiB; unavailable on Web
res.x, res.yRoot viewport target width and height in pixels, before window stretching and after 3D scaling; omitted in headless mode
sceneFull 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.

Available since: v2.4.0

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

MetricTypeDescription
game.perf.frame_timeDistribution (ms)Sampled elapsed time between process callbacks
game.perf.fpsGaugeEngine-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.

Available since: v2.4.0

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

MetricTypeDescription
game.perf.render.draw_callsGaugeDraw calls in the last rendered frame
game.perf.render.primitivesGaugeVertices or indices rendered in the last frame, including depth and shadow passes
game.perf.render.video_mem_usedGauge (bytes)Total video memory used, including texture, buffer, and other allocations
game.perf.render.texture_mem_usedGauge (bytes)Texture memory used
game.perf.render.buffer_mem_usedGauge (bytes)Render buffer memory used

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.

MetricTypeDescription
game.perf.used_memoryGauge (bytes)RAM used by the game process
game.perf.object_countGaugeInstantiated objects, including nodes
game.perf.node_countGaugeNodes in the scene tree, including its root

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.

MetricTypeDescription
game.perf.net.num_peersGaugeConnected remote peers, excluding this instance; server and mesh only
game.perf.net.pingGauge (ms)Client round-trip time to the server
game.perf.net.ping_peer_avgGauge (ms)Average peer round-trip time; server and mesh only
game.perf.net.ping_peer_maxGauge (ms)Highest peer round-trip time; server and mesh only
game.perf.net.packet_loss_ratioGauge (ratio)ENet's estimated outgoing packet-loss ratio toward the server; client only
game.perf.net.in_rateGauge (bytes)Bytes received per second; client and server only
game.perf.net.out_rateGauge (bytes)Bytes sent per second; client and server only
game.perf.net.in_packetsGaugeUDP datagrams received per second; client and server only
game.perf.net.out_packetsGaugeUDP 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.

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.

OptionDefaultAvailable SinceDescription
enable_frame_metricsfalse2.4.0Collect frame time and FPS
enable_rendering_metricsfalse2.4.0Collect rendering metrics
enable_memory_metricsfalse2.4.0Collect memory, object, and node metrics
enable_network_metricsfalse2.5.0Collect network metrics
frame_metrics_interval_sec1.02.4.0Frame collection interval, in seconds
rendering_metrics_interval_sec1.02.4.0Rendering collection interval, in seconds
memory_metrics_interval_sec60.02.4.0Memory collection interval, in seconds
network_metrics_interval_sec10.02.5.0Network collection interval, in seconds

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

Copied
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
)

The following configuration options are available for Sentry's Application Metrics in Godot Engine:

OptionDescriptionDefault
before_send_metricCallback to modify or filter metrics before sendingNone

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

Copied
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

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.

The Godot SDK automatically attaches the following attributes to every 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.

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.
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").