Skip to content

Commit e40a830

Browse files
committed
feat(python): Add Typer integration docs
1 parent a672ed0 commit e40a830

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

docs/platforms/python/integrations/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,11 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
116116
| <LinkWithPlatformIcon platform="python.asyncio" label="asyncio" url="/platforms/python/integrations/asyncio" /> | |
117117
| <LinkWithPlatformIcon platform="python.pure_eval" label="Enhanced Locals" url="/platforms/python/integrations/pure_eval" /> | |
118118
| <LinkWithPlatformIcon platform="python.gnu_backtrace" label="GNU Backtrace" url="/platforms/python/integrations/gnu_backtrace" /> | |
119-
| <LinkWithPlatformIcon platform="python.rust_tracing" label="Rust Tracing" url="/platforms/python/integrations/rust_tracing" /> | |
119+
| <LinkWithPlatformIcon platform="python.rust_tracing" label="Rust Tracing" url="/platforms/python/integrations/rust_tracing" /> | |
120120
| <LinkWithPlatformIcon platform="python.socket" label="Socket" url="/platforms/python/integrations/socket" /> | |
121121
| <LinkWithPlatformIcon platform="python.sys_exit" label="sys.exit" url="/platforms/python/integrations/sys_exit" /> | |
122122
| <LinkWithPlatformIcon platform="python.tryton" label="Tryton" url="/platforms/python/integrations/tryton" /> | |
123+
| <LinkWithPlatformIcon platform="python.typer" label="Typer" url="/platforms/python/integrations/typer" /> | |
123124
| <LinkWithPlatformIcon platform="python.wsgi" label="WSGI" url="/platforms/python/integrations/wsgi" /> | |
124125

125126
### Default Integrations
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Typer
3+
description: Learn how to use Sentry to capture Typer exceptions.
4+
---
5+
6+
The `TyperIntegration` captures exceptions raised when using Typer CLI applications.
7+
8+
## Install
9+
10+
```bash
11+
pip install --upgrade "sentry-sdk"
12+
```
13+
14+
## Configure
15+
16+
To enable the `TyperIntegration`, add it to the `integrations` list of your `sentry_sdk.init`.
17+
18+
<SignInNote />
19+
20+
```python
21+
import sentry_sdk
22+
from sentry_sdk.integrations.typer import TyperIntegration
23+
24+
sentry_sdk.init(
25+
dsn="___PUBLIC_DSN___",
26+
integrations=[TyperIntegration()],
27+
)
28+
```
29+
30+
31+
## Verify
32+
33+
Create a small CLI application:
34+
35+
```python
36+
import typer
37+
import sentry_sdk
38+
from sentry_sdk.integrations.typer import TyperIntegration
39+
40+
sentry_sdk.init(
41+
dsn="___PUBLIC_DSN___",
42+
integrations=[TyperIntegration()],
43+
)
44+
45+
def main():
46+
1 / 0
47+
48+
if __name__ == "__main__":
49+
typer.run(main)
50+
```
51+
52+
When you run this, Sentry will capture the `ZeroDivisionError` from the `main()`
53+
function and you will be able to see it on [sentry.io](https://sentry.io).

0 commit comments

Comments
 (0)