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(python): Add Typer integration docs #12174

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/platforms/python/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
| <LinkWithPlatformIcon platform="python.asyncio" label="asyncio" url="/platforms/python/integrations/asyncio" /> | |
| <LinkWithPlatformIcon platform="python.pure_eval" label="Enhanced Locals" url="/platforms/python/integrations/pure_eval" /> | |
| <LinkWithPlatformIcon platform="python.gnu_backtrace" label="GNU Backtrace" url="/platforms/python/integrations/gnu_backtrace" /> | |
| <LinkWithPlatformIcon platform="python.rust_tracing" label="Rust Tracing" url="/platforms/python/integrations/rust_tracing" /> | |
| <LinkWithPlatformIcon platform="python.rust_tracing" label="Rust Tracing" url="/platforms/python/integrations/rust_tracing" /> | |
| <LinkWithPlatformIcon platform="python.socket" label="Socket" url="/platforms/python/integrations/socket" /> | |
| <LinkWithPlatformIcon platform="python.sys_exit" label="sys.exit" url="/platforms/python/integrations/sys_exit" /> | |
| <LinkWithPlatformIcon platform="python.tryton" label="Tryton" url="/platforms/python/integrations/tryton" /> | |
| <LinkWithPlatformIcon platform="python.typer" label="Typer" url="/platforms/python/integrations/typer" /> | |
| <LinkWithPlatformIcon platform="python.wsgi" label="WSGI" url="/platforms/python/integrations/wsgi" /> | |

### Default Integrations
Expand Down
52 changes: 52 additions & 0 deletions docs/platforms/python/integrations/typer/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: Typer
description: Learn how to use Sentry to capture Typer exceptions.
---

The `TyperIntegration` captures exceptions raised when using [Typer CLI](https://typer.tiangolo.com/) applications.

## Install

Install Typer and the Sentry Python SDK.

```bash
pip install --upgrade "sentry-sdk" typer
```

## Configure

To enable the `TyperIntegration`, add it to the `integrations` list of your `sentry_sdk.init`.

```python
import sentry_sdk
from sentry_sdk.integrations.typer import TyperIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[TyperIntegration()],
)
```

## Verify

Create a small CLI application:

```python
import typer
import sentry_sdk
from sentry_sdk.integrations.typer import TyperIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[TyperIntegration()],
)

def main():
1 / 0

if __name__ == "__main__":
typer.run(main)
```

When you run this, Sentry will capture the `ZeroDivisionError` from the `main()`
function and you'll be able to see it on [sentry.io](https://sentry.io).
Loading