Chalice

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(),
    ],

    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    # We recommend adjusting this value in production,
    traces_sample_rate=1.0,
)

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.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").