Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(perf): Add Python Snippet for Custom Perf Metrics #5391

Merged
merged 3 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/includes/performance/custom-performance-metrics/python.mdx
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);
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ title: Performance Metrics
sidebar_order: 20
supported:
- javascript
- python
notSupported:
- javascript.cordova
- javascript.electron
- react-native
- dotnet
- python
- go
- java
- android
Expand All @@ -31,12 +31,17 @@ description: "Learn how to attach performance metrics to your transactions."

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

<PlatformSection notSupported={["python"]}>

<PlatformContent includePath="performance/automatic-performance-metrics" />

</PlatformSection>

## Custom Metrics

<Note>

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).
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).

</Note>

Expand Down