-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(perf): Add Python Snippet for Custom Perf Metrics (#5391)
- Loading branch information
1 parent
28948b5
commit 5e9d673
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/includes/performance/custom-performance-metrics/python.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Adding custom metrics is supported in Sentry's Python SDK version `1.5.12` and above. | ||
|
||
To enable the capturing of custom metrics, you'll need to enable the `custom_measurements` experiment option. | ||
|
||
```python | ||
sentry_sdk.init( | ||
dsn="__DSN__", | ||
_experiments={ | ||
"custom_measurements": True, | ||
}, | ||
) | ||
``` | ||
|
||
To capture in the SDK: | ||
|
||
```python | ||
transaction = Hub.current.scope.transaction; | ||
|
||
# Record amount of memory used | ||
transaction.set_measurement('memory_used', 123, 'byte'); | ||
|
||
# Record time when job was started | ||
transaction.set_measurement('job_start_time', 1.3, 'second'); | ||
|
||
# Record amount of times cache was read | ||
transaction.set_measurement('cache_read_count', 4); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5e9d673
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sentry-docs – ./
sentry-docs.sentry.dev
docs.sentry.io
sentry-docs-git-master.sentry.dev