diff --git a/docs/platforms/godot/configuration/options.mdx b/docs/platforms/godot/configuration/options.mdx index 0ecf1e7d0cf5a..05c92eca37ed7 100644 --- a/docs/platforms/godot/configuration/options.mdx +++ b/docs/platforms/godot/configuration/options.mdx @@ -182,6 +182,82 @@ This option is turned off by default. + + +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; +}); +``` + + + +## Metrics Options + + + +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 Set Up Metrics for usage details. + +This option is turned on by default. + + + + + +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; +}); +``` + + + ## Godot Logger Options @@ -350,40 +426,6 @@ This callback isn't available in the .NET layer yet, so it can only be set from - - -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; -}); -``` - - - ## 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. diff --git a/platform-includes/metrics/options/godot.mdx b/platform-includes/metrics/options/godot.mdx index ff4b9fdadfdf1..4ae44c86a12d5 100644 --- a/platform-includes/metrics/options/godot.mdx +++ b/platform-includes/metrics/options/godot.mdx @@ -1,9 +1,9 @@ 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 @@ -11,7 +11,7 @@ To filter metrics or modify them before they are sent to Sentry, you can use the ```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: diff --git a/platform-includes/metrics/requirements/godot.mdx b/platform-includes/metrics/requirements/godot.mdx index 67548f5162cfd..eef240539e721 100644 --- a/platform-includes/metrics/requirements/godot.mdx +++ b/platform-includes/metrics/requirements/godot.mdx @@ -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`). diff --git a/platform-includes/metrics/setup/godot.mdx b/platform-includes/metrics/setup/godot.mdx index 64465d84fb607..581422b09b05d 100644 --- a/platform-includes/metrics/setup/godot.mdx +++ b/platform-includes/metrics/setup/godot.mdx @@ -1,13 +1,8 @@ Metrics are enabled by default in the Sentry Godot SDK. No additional setup is required to start sending metrics. - - 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. - - ### 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 @@ -15,7 +10,7 @@ Alternatively, you can disable metrics programmatically when initializing the SD ```gdscript {tabTitle:GDScript} {mdExpandTabs} SentrySDK.init(func(options: SentryOptions) -> void: - options.experimental.enable_metrics = false + options.enable_metrics = false ) ```