File tree Expand file tree Collapse file tree 2 files changed +54
-1
lines changed
docs/platforms/python/integrations Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -117,10 +117,11 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
117117| <LinkWithPlatformIcon platform = " python.asyncio" label = " asyncio" url = " /platforms/python/integrations/asyncio" /> | |
118118| <LinkWithPlatformIcon platform = " python.pure_eval" label = " Enhanced Locals" url = " /platforms/python/integrations/pure_eval" /> | |
119119| <LinkWithPlatformIcon platform = " python.gnu_backtrace" label = " GNU Backtrace" url = " /platforms/python/integrations/gnu_backtrace" /> | |
120- | <LinkWithPlatformIcon platform = " python.rust_tracing" label = " Rust Tracing" url = " /platforms/python/integrations/rust_tracing" /> | |
120+ | <LinkWithPlatformIcon platform = " python.rust_tracing" label = " Rust Tracing" url = " /platforms/python/integrations/rust_tracing" /> | |
121121| <LinkWithPlatformIcon platform = " python.socket" label = " Socket" url = " /platforms/python/integrations/socket" /> | |
122122| <LinkWithPlatformIcon platform = " python.sys_exit" label = " sys.exit" url = " /platforms/python/integrations/sys_exit" /> | |
123123| <LinkWithPlatformIcon platform = " python.tryton" label = " Tryton" url = " /platforms/python/integrations/tryton" /> | |
124+ | <LinkWithPlatformIcon platform = " python.typer" label = " Typer" url = " /platforms/python/integrations/typer" /> | |
124125| <LinkWithPlatformIcon platform = " python.wsgi" label = " WSGI" url = " /platforms/python/integrations/wsgi" /> | |
125126
126127### Default Integrations
Original file line number Diff line number Diff line change 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] ( https://typer.tiangolo.com/ ) applications.
7+
8+ ## Install
9+
10+ Install Typer and the Sentry Python SDK.
11+
12+ ``` bash
13+ pip install --upgrade " sentry-sdk" typer
14+ ```
15+
16+ ## Configure
17+
18+ To enable the ` TyperIntegration ` , add it to the ` integrations ` list of your ` sentry_sdk.init ` .
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+ ## Verify
31+
32+ Create a small CLI application:
33+
34+ ``` python
35+ import typer
36+ import sentry_sdk
37+ from sentry_sdk.integrations.typer import TyperIntegration
38+
39+ sentry_sdk.init(
40+ dsn = " ___PUBLIC_DSN___" ,
41+ integrations = [TyperIntegration()],
42+ )
43+
44+ def main ():
45+ 1 / 0
46+
47+ if __name__ == " __main__" :
48+ typer.run(main)
49+ ```
50+
51+ When you run this, Sentry will capture the ` ZeroDivisionError ` from the ` main() `
52+ function and you'll be able to see it on [ sentry.io] ( https://sentry.io ) .
You can’t perform that action at this time.
0 commit comments