Skip to content

Commit 54c1145

Browse files
antonpirkergetsantry[bot]shanamatthews
authored
Getting Started: serverless (#7833)
* Getting Started: serverless * style(lint): Auto commit lint changes * Update src/platforms/python/guides/serverless/index.mdx Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com> --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com>
1 parent 4c1b017 commit 54c1145

File tree

1 file changed

+26
-6
lines changed
  • src/platforms/python/guides/serverless

1 file changed

+26
-6
lines changed

src/platforms/python/guides/serverless/index.mdx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ redirect_from:
55
description: "Learn about using Sentry's Python SDK for a serverless environment."
66
---
77

8+
The Serverless integration adds support for the [Serverless Framework](https://www.serverless.com/).
9+
810
It is recommended to use an integration for your particular serverless environment if available, as those are easier to use and capture more useful information:
911

1012
- <Link to="/platforms/python/guides/gcp-functions">
@@ -14,6 +16,16 @@ It is recommended to use an integration for your particular serverless environme
1416

1517
If you use a serverless provider not directly supported by the SDK, you can use this generic integration.
1618

19+
## Install
20+
21+
Install `sentry-sdk` from PyPI:
22+
23+
```bash
24+
pip install --upgrade 'sentry-sdk'
25+
```
26+
27+
## Configure
28+
1729
Apply the `serverless_function` decorator to each function that might throw errors:
1830

1931
<SignInNote />
@@ -23,22 +35,30 @@ import sentry_sdk
2335
from sentry_sdk.integrations.serverless import serverless_function
2436

2537
sentry_sdk.init(
26-
dsn="___PUBLIC_DSN___",
27-
2838
# Set traces_sample_rate to 1.0 to capture 100%
2939
# of transactions for performance monitoring.
30-
# We recommend adjusting this value in production,
3140
traces_sample_rate=1.0,
41+
dsn="___PUBLIC_DSN___",
3242
)
3343

3444
@serverless_function
3545
def my_function(...): ...
3646
```
3747

3848
Use the generic integration by calling the `serverless_function` decorator.
39-
Decorators wrap a function and modify its behavior. Then, deploy and test the
40-
function. Check out Sentry's [sample
41-
apps](https://github.com/getsentry/examples) for detailed examples.
49+
Decorators wrap a function and modify its behavior. Then, deploy and test the function.
50+
51+
## Verify
52+
53+
Wrap a functions with the `serverless_function` that triggers an error:
54+
55+
```python
56+
@serverless_function
57+
def my_function(...):
58+
1/0 # raises an error
59+
```
60+
61+
Now deploy your function. When you now run your function an error event will be sent to [sentry.io](https://sentry.io).
4262

4363
## Behavior
4464

0 commit comments

Comments
 (0)