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_send callback
  • 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.

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:

Don't need a feature? Remove its options.

ProjectMainLoop.gd
Copied
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
	)

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.

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

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.

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

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.

Copied
extends Node

func _ready():
	SentrySDK.add_breadcrumb(SentryBreadcrumb.create("Just about to welcome the World."))
	SentrySDK.capture_message("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:

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").