Skip to content

Commit 8ffc69b

Browse files
limbonautclaudeJoshuaMoelanscoolguyzone
authored
docs(godot): Use SentryUnit constants in metrics examples (#16794)
Co-authored-by: Claude <[email protected]> Co-authored-by: JoshuaMoelans <[email protected]> Co-authored-by: Alex Krawiec <[email protected]>
1 parent 5793bfb commit 8ffc69b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

platform-includes/metrics/usage/godot.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ Track current values at a point in time, like a snapshot. Sentry computes aggreg
2828
SentrySDK.metrics.gauge("players_online", lobby.get_player_count())
2929
3030
# With a unit
31-
SentrySDK.metrics.gauge("memory_usage", OS.get_static_memory_usage(), "byte")
31+
SentrySDK.metrics.gauge("memory_usage", OS.get_static_memory_usage(), SentryUnit.byte)
3232
```
3333

3434
### Distributions
3535

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

3838
```GDScript
39-
SentrySDK.metrics.distribution("level_load_time", load_time, "millisecond")
39+
SentrySDK.metrics.distribution("level_load_time", load_time, SentryUnit.millisecond)
4040
```
4141

4242
### Custom Attributes
@@ -46,7 +46,7 @@ Add attributes to filter and group metrics in Sentry:
4646
```GDScript
4747
SentrySDK.metrics.count("enemies_spawned", wave_size, {"level": "castle"})
4848
49-
SentrySDK.metrics.distribution("level_load_time", load_time, "millisecond", {
49+
SentrySDK.metrics.distribution("level_load_time", load_time, SentryUnit.millisecond, {
5050
"scene": get_tree().current_scene.name
5151
})
5252
```
@@ -55,15 +55,15 @@ Attributes support `bool`, `int`, `float`, and `String` data types. Other types
5555

5656
### Units
5757

58-
For gauge and distribution metrics, you can specify a unit as a string to help Sentry display values in a human-readable format. See [supported units](https://develop.sentry.dev/sdk/foundations/data-model/attributes/#units) for the full list.
58+
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](https://develop.sentry.dev/sdk/foundations/data-model/attributes/#units) for the full list.
5959

6060
```GDScript
6161
# Duration units
62-
SentrySDK.metrics.distribution("level_load_time", load_time, "millisecond")
62+
SentrySDK.metrics.distribution("level_load_time", load_time, SentryUnit.millisecond)
6363
6464
# Information units
65-
SentrySDK.metrics.gauge("memory_usage", OS.get_static_memory_usage(), "byte")
65+
SentrySDK.metrics.gauge("memory_usage", OS.get_static_memory_usage(), SentryUnit.byte)
6666
67-
# Custom units
68-
SentrySDK.metrics.distribution("frame_rate", Engine.get_frames_per_second(), "fps")
67+
# Custom units (as strings)
68+
SentrySDK.metrics.gauge("items_in_inventory", item_count, "item")
6969
```

0 commit comments

Comments
 (0)