Skip to content

Commit e0e99e2

Browse files
Python: Getting Started chalice (#7828)
* Python: Getting Started chalice * Apply suggestions from code review Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com> --------- Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com>
1 parent 929a271 commit e0e99e2

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

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

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,50 +18,53 @@ pip install --upgrade sentry-sdk[chalice]
1818
<SignInNote />
1919

2020
```python
21-
import sentry_sdk
2221
from chalice import Chalice
2322

23+
import sentry_sdk
2424
from sentry_sdk.integrations.chalice import ChaliceIntegration
2525

26-
2726
sentry_sdk.init(
2827
dsn="___PUBLIC_DSN___",
29-
integrations=[
30-
ChaliceIntegration(),
31-
],
32-
3328
# Set traces_sample_rate to 1.0 to capture 100%
3429
# of transactions for performance monitoring.
35-
# We recommend adjusting this value in production,
3630
traces_sample_rate=1.0,
31+
integrations=[
32+
ChaliceIntegration(),
33+
],
3734
)
3835

3936
app = Chalice(app_name="appname")
4037

4138
```
4239

43-
## Testing
44-
45-
You can create a route that triggers an error for validate your Sentry installation like this:
40+
## Verify
4641

4742
```python
48-
@app.route("/boom")
49-
def boom():
50-
raise Exception("boom goes the dynamite!")
51-
```
43+
from chalice import Chalice
5244

53-
when you enter the route will throw an error that will be captured by Sentry.
45+
sentry_sdk.init(...) # as above
5446

55-
for everything else (like events)
47+
app = Chalice(app_name="helloworld")
5648

57-
```python
5849
@app.schedule(Rate(1, unit=Rate.MINUTES))
59-
def every_hour(event):
60-
raise Exception("only chalice event!")
50+
def every_minute(event):
51+
1/0 # raises an error
52+
53+
@app.route("/")
54+
def index():
55+
1/0 # raises an error
56+
return {"hello": "world"}
6157
```
6258

59+
When you enter the `"/"` route or the scheduled task is run, an error event will be sent to [sentry.io](https://sentry.io).
60+
6361
## Behavior
6462

6563
- Request data is attached to all events: HTTP method, URL, headers, form data, JSON payloads. Sentry excludes raw bodies and multipart file uploads. Sentry also excludes personally identifiable information (such as user ids, usernames, cookies, authorization headers, IP addresses) unless you set send_default_pii to True.
6664

6765
- Each request has a separate scope. Changes to the scope within a view, for example setting a tag, will only apply to events sent as part of the request being handled.
66+
67+
## Supported Versions
68+
69+
- Chalice: 1.16.0+
70+
- Python: 3.6+

0 commit comments

Comments
 (0)