Skip to content

Commit

Permalink
feat(perf): Add Python Snippet for Custom Perf Metrics (#5391)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Aug 9, 2022
1 parent 28948b5 commit 5e9d673
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
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

1 comment on commit 5e9d673

@vercel
Copy link

@vercel vercel bot commented on 5e9d673 Aug 9, 2022

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

Please sign in to comment.