Skip to content
Open
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
110 changes: 76 additions & 34 deletions docs/platforms/godot/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,82 @@ This option is turned off by default.

</SdkOption>

<SdkOption name="before_send_log" type="Callable" availableSince="1.2.0">

If assigned, this callback will be called before sending a log message to Sentry.
It can be used to modify the log message or prevent it from being sent.

@limbonaut limbonaut Jun 22, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: Moved it under Logging section to align with metrics.


```gdscript {tabTitle:GDScript} {mdExpandTabs}
func _before_send_log(log_entry: SentryLog) -> SentryLog:
# Filter junk.
if log_entry.body == "Junk message":
return null
# Remove sensitive information from log messages.
log_entry.body = log_entry.body.replace("Bruno", "REDACTED")
# Add custom attributes.
log_entry.set_attribute("current_scene", current_scene.name)
return log_entry
```

```csharp {tabTitle:C#}
// The .NET hook applies to logs emitted from your C# code.
options.SetBeforeSendLog(log =>
{
// Filter junk.
if (log.Message == "Junk message")
{
return null;
}
// Add custom attributes.
log.SetAttribute("current_scene", currentScene.Name);
return log;
});
```

</SdkOption>

## Metrics Options

<SdkOption name="enable_metrics" type="bool" defaultValue="true" availableSince="2.0.0">

If `true`, enables [Sentry's Application Metrics](https://docs.sentry.io/product/explore/metrics/) functionality, allowing you to emit custom counters, gauges, and distributions through `SentrySDK.metrics`. See <PlatformLink to="/metrics/">Set Up Metrics</PlatformLink> for usage details.

This option is turned on by default.

</SdkOption>

<SdkOption name="before_send_metric" type="Callable" availableSince="2.0.0">

If assigned, this callback runs before a metric is sent to Sentry.
It can be used to modify the metric or prevent it from being sent.
It takes a `SentryMetric` as a parameter and returns either the same metric object, with or without modifications, or `null` to discard it.

```gdscript {tabTitle:GDScript} {mdExpandTabs}
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
```

```csharp {tabTitle:C#}
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;
});
```

</SdkOption>

## Godot Logger Options

<SdkOption name="logger_enabled" type="bool" defaultValue="true">
Expand Down Expand Up @@ -350,40 +426,6 @@ This callback isn't available in the .NET layer yet, so it can only be set from

</SdkOption>

<SdkOption name="before_send_log" type="Callable" availableSince="1.2.0">

If assigned, this callback will be called before sending a log message to Sentry.
It can be used to modify the log message or prevent it from being sent.

```gdscript {tabTitle:GDScript} {mdExpandTabs}
func _before_send_log(log_entry: SentryLog) -> SentryLog:
# Filter junk.
if log_entry.body == "Junk message":
return null
# Remove sensitive information from log messages.
log_entry.body = log_entry.body.replace("Bruno", "REDACTED")
# Add custom attributes.
log_entry.set_attribute("current_scene", current_scene.name)
return log_entry
```

```csharp {tabTitle:C#}
// The .NET hook applies to logs emitted from your C# code.
options.SetBeforeSendLog(log =>
{
// Filter junk.
if (log.Message == "Junk message")
{
return null;
}
// Add custom attributes.
log.SetAttribute("current_scene", currentScene.Name);
return log;
});
```

</SdkOption>

## Native Hooks in C#

In C#, hook methods set directly on `options` apply to managed SDK data, such as events and logs from your game's C# code and third-party .NET libraries. However, much of the Godot SDK's processing happens in the native C++ layer, including events and logs captured from the engine, GDScript, and GDExtension code. Native hook methods live under `options.Native`; use these callbacks to inspect, modify, or drop native data before it's sent to Sentry.
Expand Down
10 changes: 5 additions & 5 deletions platform-includes/metrics/options/godot.mdx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
The following configuration options are available for Sentry's [Application Metrics](/product/explore/metrics/) in Godot Engine:

| Option | Description | Default |
| ---------------------- | ------------------------------------------------------------------ | ------- |
| **enable_metrics** | Toggle for the metrics feature (experimental) | `true` |
| **before_send_metric** | Callback to modify or filter metrics before sending (experimental) | None |
| Option | Description | Default |
| ---------------------- | --------------------------------------------------- | ------- |
| **enable_metrics** | Toggle for the metrics feature | `true` |
| **before_send_metric** | Callback to modify or filter metrics before sending | None |

### before_send_metric

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

```gdscript {tabTitle:GDScript} {mdExpandTabs}
SentrySDK.init(func(options: SentryOptions) -> void:
options.experimental.before_send_metric = _before_send_metric
options.before_send_metric = _before_send_metric
)

func _before_send_metric(metric: SentryMetric) -> SentryMetric:
Expand Down
2 changes: 1 addition & 1 deletion platform-includes/metrics/requirements/godot.mdx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Metrics for Godot Engine are supported in Sentry Godot SDK version `1.4.0` and above.
Metrics for Godot Engine are supported in Sentry Godot SDK version `2.0.0` and above (previously experimental since `1.4.0`).
9 changes: 2 additions & 7 deletions platform-includes/metrics/setup/godot.mdx
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
Metrics are enabled by default in the Sentry Godot SDK. No additional setup is required to start sending metrics.

<Alert title="Note">
Adding metrics from GDScript isn't supported on Apple platforms yet (macOS and iOS).
The first attempt to use metrics on these platforms will result in a warning.
</Alert>

### Project Settings Configuration

To disable metrics, navigate to **Project Settings > Sentry > Experimental** and uncheck the **Enable Metrics** option.
To disable metrics, navigate to **Project Settings > Sentry > Options** and uncheck the **Enable Metrics** option.

### Programmatic Configuration

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

```gdscript {tabTitle:GDScript} {mdExpandTabs}
SentrySDK.init(func(options: SentryOptions) -> void:
options.experimental.enable_metrics = false
options.enable_metrics = false
)
```

Expand Down
Loading