Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
Add timer to sending-metrics-sdk (#1089)
Browse files Browse the repository at this point in the history
* Add timer to sending-metrics-sdk

Documenting missing capability/example to send timers

* Update sending-metrics-sdk.mdx

---------

Co-authored-by: Armin Ronacher <armin.ronacher@active-4.com>
  • Loading branch information
ale-cota and mitsuhiko authored Nov 21, 2023
1 parent 5463ad0 commit f429403
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/docs/delightful-developer-metrics/sending-metrics-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ metrics.gauge(
tags=tags,
)
```
If you want to measure how much time a specific piece of code takes, you can use:

```python
from sentry_sdk import metrics

# Emit a distribution metric of the execution time of the function.
with metrics.timer("my_timer"):
pass

@metrics.timer("my_timer")
def my_function():
pass
```

<Alert title="Note" level="note">
As of now, only the Python SDK is supporting the new metrics features but we are working on supporting metrics in the JavaScript and Rust SDKs next.
Expand Down

1 comment on commit f429403

@vercel
Copy link

@vercel vercel bot commented on f429403 Nov 21, 2023

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:

develop – ./

develop.sentry.dev
develop-git-master.sentry.dev

Please sign in to comment.