Skip to content

Commit 5e9d673

Browse files
authored
feat(perf): Add Python Snippet for Custom Perf Metrics (#5391)
1 parent 28948b5 commit 5e9d673

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Adding custom metrics is supported in Sentry's Python SDK version `1.5.12` and above.
2+
3+
To enable the capturing of custom metrics, you'll need to enable the `custom_measurements` experiment option.
4+
5+
```python
6+
sentry_sdk.init(
7+
dsn="__DSN__",
8+
_experiments={
9+
"custom_measurements": True,
10+
},
11+
)
12+
```
13+
14+
To capture in the SDK:
15+
16+
```python
17+
transaction = Hub.current.scope.transaction;
18+
19+
# Record amount of memory used
20+
transaction.set_measurement('memory_used', 123, 'byte');
21+
22+
# Record time when job was started
23+
transaction.set_measurement('job_start_time', 1.3, 'second');
24+
25+
# Record amount of times cache was read
26+
transaction.set_measurement('cache_read_count', 4);
27+
```

src/platforms/common/performance/instrumentation/performance-metrics.mdx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ title: Performance Metrics
33
sidebar_order: 20
44
supported:
55
- javascript
6+
- python
67
notSupported:
78
- javascript.cordova
89
- javascript.electron
910
- react-native
1011
- dotnet
11-
- python
1212
- go
1313
- java
1414
- android
@@ -31,12 +31,17 @@ description: "Learn how to attach performance metrics to your transactions."
3131

3232
Sentry's SDKs support sending performance metrics data to Sentry. These are numeric values attached to transactions that are aggregated and displayed in Sentry.
3333

34+
<PlatformSection notSupported={["python"]}>
35+
3436
<PlatformContent includePath="performance/automatic-performance-metrics" />
3537

38+
</PlatformSection>
39+
3640
## Custom Metrics
41+
3742
<Note>
3843

39-
organization can set custom metrics in the SDK, the ability to see the data generated by these metrics is in beta and is only available if your organization is participating in its limited release. Features in beta are still in-progress and may have bugs. We recognize the irony. If you’re interested in participating, [join the waitlist](https://sentry.io/for/performance/#updates-signup).
44+
Although you can set custom metrics in the SDK, the ability to see the data generated by these metrics is in beta and is only available if your organization is participating in its limited release. Features in beta are still in-progress and may have bugs. We recognize the irony. If you’re interested in participating, [join the waitlist](https://sentry.io/for/performance/#updates-signup).
4045

4146
</Note>
4247

0 commit comments

Comments
 (0)