Chalice

(New in version 0.17.4)

Install

Install sentry-sdk from PyPI:

Copied
pip install --upgrade sentry-sdk[chalice]

Configure

Copied
import sentry_sdk
from chalice import Chalice

from sentry_sdk.integrations.chalice import ChaliceIntegration


sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
    integrations=[ChaliceIntegration()]
)

app = Chalice(app_name="appname")

Testing

You can create a route that triggers an error for validate your Sentry installation like this:

Copied
@app.route("/boom")
def boom():
    raise Exception("boom goes the dynamite!")

when you enter the route will throw an error that will be captured by Sentry.

for everything else (like events)

Copied
@app.schedule(Rate(1, unit=Rate.MINUTES))
def every_hour(event):
    raise Exception("only chalice event!")

Behavior

  • 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.

  • 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.

You can edit this page on GitHub.