Sentry for Godot Engine
Learn how to set up Sentry's Godot Engine SDK for error monitoring and performance tracking.
Our SDK for Godot Engine builds on top of existing Sentry SDKs, extending them with Godot-specific features. It gives developers helpful hints for where and why an error or performance issue might have occurred.
Features:
- Native support for automatic crash and error reporting for:
- Windows and Linux using the Native SDK to support C and C++ with minidumps
- macOS 12 Monterey or later using the macOS SDK to support Objective-C, Swift, C and C++
- iOS 15 or later using the iOS SDK to support Objective-C, Swift, C and C++
- Android using the Android SDK to support Java, Kotlin, C and C++
- Web using the JavaScript SDK to support WebAssembly and JavaScript
- Automatically capture Godot runtime errors, such as script and shader errors
- Capture errors from C# (.NET) code, with scope and traces shared across both languages
- GDScript stack traces with optional local and member variable information
- Include surrounding script source code with events when available at runtime
- Structured Logs with searchable attributes that connect to your traces, plus optional capture of Godot log output like
print()statements - Enrich events with tags, breadcrumbs, contexts, and attachments
- Information about user configuration like GPU, CPU, platform and such
- Filter and customize events in
before_sendcallback - Log-file attachments for events
- Scene tree data attachments for events
- Screenshot attachments for events (experimental)
- Release Health to keep track of crash-free users and sessions
- Event throttling to handle spammy errors
On this page, we get you up and running with Sentry's SDK.
Don't already have an account and Sentry project established? Head over to sentry.io, then return to this page.
Sentry captures data through our addon for Godot Engine which you can install in your project.
Download the latest stable version 2.4.0 from GitHub Releases. Extract the addons/sentry folder from the archive into your project.
Ensure that the addon is placed in the addons/sentry folder, preserving the exact casing.
A separate demo project archive is also available on the releases page. It contains a ready-to-run Godot project with examples of common features like error capturing, breadcrumbs, and user feedback. To use it, enter your DSN in Project Settings > Sentry > Options.
Error Monitoring starts working as soon as you set your DSN: the SDK automatically captures crashes and Godot runtime errors, such as script and shader errors. Logs and Application Metrics are enabled by default in SDK 2.0.0 and later, and you'll learn how to send them in Send Logs and Send Application Metrics. This guide also enables Tracing, which requires SDK 2.2.0 or later. To collect User Feedback from players, add the SDK's feedback form or use the feedback API.
The minimum configuration required is the DSN to your project.
To access the project settings in Godot Engine, navigate to Project > Project Settings..., then scroll down the sections list on the left until you find the Sentry section. Enter your DSN in Sentry > Options > DSN.
Your configuration is saved in the project.godot file along with other project settings. With Auto Init turned on (the default), the SDK initializes automatically when your game starts, before any scenes load or scripts run.
To configure the SDK in code instead, for example to define a before_send callback, turn off Auto Init in Project Settings > Sentry > Options and call init() from a script that extends SceneTree. Then enter the script's class name in Project Settings > Application > Run > Main Loop Type. A single init() call from either GDScript or C# initializes the SDK for both languages. See Programmatic Configuration for details.
The snippet also turns on:
- Tracing: via
traces_sample_rate, or Sentry > Options > Tracing > Traces Sample Rate in Project Settings (turn on Advanced Settings to see it). Add spans around operations like level loads with instrumentation. For C#, use the Sentry .NET tracing API. - Scene tree attachments: via
attach_scene_tree, or Sentry > Options > Attach Scene Tree in Project Settings. See Scene Tree for details.
Don't need a feature? Remove its options.
ProjectMainLoop.gdclass_name ProjectMainLoop
extends SceneTree
func _initialize() -> void:
SentrySDK.init(func(options: SentryOptions) -> void:
options.dsn = "___PUBLIC_DSN___"
# Enables Tracing.
# Set to 1.0 to capture 100% of traces.
# We recommend reducing this value in production.
options.traces_sample_rate = 1.0
# Attaches scene tree data to events.
options.attach_scene_tree = true
)
class_name ProjectMainLoop
extends SceneTree
func _initialize() -> void:
SentrySDK.init(func(options: SentryOptions) -> void:
options.dsn = "___PUBLIC_DSN___"
# Enables Tracing.
# Set to 1.0 to capture 100% of traces.
# We recommend reducing this value in production.
options.traces_sample_rate = 1.0
# Attaches scene tree data to events.
options.attach_scene_tree = true
)
using Godot;
using Sentry;
using Sentry.Godot;
[GlobalClass]
public partial class ProjectMainLoop : SceneTree
{
public override void _Initialize()
{
SentrySdk.Init(options =>
{
options.Dsn = "___PUBLIC_DSN___";
// Enables Tracing.
// Set to 1.0 to capture 100% of traces.
// We recommend reducing this value in production.
options.TracesSampleRate = 1.0;
// Attaches scene tree data to events.
options.AttachSceneTree = true;
});
}
}
The official Godot Engine builds only provide export templates without debug information. To get function names, file paths, and line numbers for native crashes, export your game with export templates that contain debug symbols and upload the debug symbols to Sentry.
To see GDScript source code around stack trace frames in exported games, set up Source Context.
Exporting for Android with the Sentry SDK requires Godot's Gradle build. Install the Android build template with Project > Install Android Build Template..., then turn on Use Gradle Build in your Android export preset. See Exporting for Android for the full setup.
C# support requires SDK 2.0.0 or later and the .NET build of Godot Engine 4.5 or later. The addon ships the .NET libraries and adds them to your project's .csproj file when you open the project in the editor. Build your project to restore the NuGet package. See C#/.NET Support for details.
Use SentrySDK.logger to send logs at different levels, such as info, warn, or error. You can pass any attributes you want and search or filter by them later. Logs are generally available in SDK 1.2.0 and later and enabled by default starting with SDK 2.0.0.
To also capture Godot's own log output, such as engine errors and print() statements, set godot_logger.log_mask. It's empty by default.
See Set Up Logs for all available logging methods and configuration options.
SentrySDK.logger.info("Level loaded successfully")
SentrySDK.logger.warn("Item configuration not found")
SentrySDK.logger.debug("Spawning %s with %d units", ["enemies", 5], {
"current_scene": get_tree().current_scene.scene_file_path,
"wave_id": "main_wave_3"
})
SentrySDK.logger.info("Level loaded successfully")
SentrySDK.logger.warn("Item configuration not found")
SentrySDK.logger.debug("Spawning %s with %d units", ["enemies", 5], {
"current_scene": get_tree().current_scene.scene_file_path,
"wave_id": "main_wave_3"
})
SentrySdk.Logger.LogInfo("Level loaded successfully");
SentrySdk.Logger.LogWarning("Item configuration not found");
SentrySdk.Logger.LogDebug(
log =>
{
log.SetAttribute("current_scene", GetTree().CurrentScene.SceneFilePath);
log.SetAttribute("wave_id", "main_wave_3");
},
"Spawning {0} with {1} units", "enemies", 5);
Use SentrySDK.metrics to send counters, gauges, and distributions from your game to Sentry. You can pass any attributes you want and search or filter by them later. Metrics require SDK 2.0.0 or later, where they're enabled by default.
See Set Up Metrics for all available metric types and configuration options.
SentrySDK.metrics.count("match_started")
SentrySDK.metrics.gauge("players_online", lobby.get_player_count())
SentrySDK.metrics.distribution("level_load_time", load_time, SentryUnit.millisecond, {
"scene": get_tree().current_scene.name
})
SentrySDK.metrics.count("match_started")
SentrySDK.metrics.gauge("players_online", lobby.get_player_count())
SentrySDK.metrics.distribution("level_load_time", load_time, SentryUnit.millisecond, {
"scene": get_tree().current_scene.name
})
SentrySdk.Metrics.EmitCounter("match_started", 1);
SentrySdk.Metrics.EmitGauge("players_online", lobby.GetPlayerCount());
SentrySdk.Metrics.EmitDistribution("level_load_time", loadTime, MeasurementUnit.Duration.Millisecond, new Dictionary<string, object>
{
["scene"] = GetTree().CurrentScene.Name.ToString(),
});
Add a Node to your test scene and attach a script with the following content, then run the scene. The script captures a message, so you can confirm that Sentry receives events from your game.
extends Node
func _ready():
SentrySDK.add_breadcrumb(SentryBreadcrumb.create("Just about to welcome the World."))
SentrySDK.capture_message("Hello, World!")
extends Node
func _ready():
SentrySDK.add_breadcrumb(SentryBreadcrumb.create("Just about to welcome the World."))
SentrySDK.capture_message("Hello, World!")
using Godot;
public partial class SentryTest : Node
{
public override void _Ready()
{
SentrySdk.AddBreadcrumb("Just about to welcome the World.");
SentrySdk.CaptureMessage("Hello, World!");
}
}
To view and resolve the recorded message, log into sentry.io and select your project. Select Issues in the sidebar, then select the message's title to open a page where you can see detailed information and mark it as resolved.
At this point, you should have integrated Sentry into your Godot Engine game. Here's what to explore next:
- Explore practical guides on what to monitor, log, track, and investigate after setup.
- Learn how to manually capture errors and messages.
- Add tags, breadcrumbs, context, and attachments, such as screenshots, to enrich your events.
- Track crash-free users and sessions with Releases & Health.
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").