---
title: "Chalice"
description: "Learn about using Sentry with Chalice."
url: https://docs.sentry.io/platforms/python/integrations/chalice/
---

# Chalice for Python

## [Install](https://docs.sentry.io/platforms/python/integrations/chalice.md#install)

Install `sentry-sdk` from PyPI:

```bash
pip install sentry-sdk
```

*Other available variations of the above snippet: uv*

## [Configure](https://docs.sentry.io/platforms/python/integrations/chalice.md#configure)

If you have the `chalice` package in your dependencies, the Chalice integration will be enabled automatically when you initialize the Sentry SDK.

Error Monitoring\[ ]Tracing\[ ]Profiling

```python
import sentry_sdk

sentry_sdk.init(
    dsn="https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
    # Check https://docs.sentry.io/platforms/python/data-management/data-collected/ to configure what data is collected
    data_collection={
        "user_info": True,
    },
    # ___PRODUCT_OPTION_START___ performance
    # Set traces_sample_rate to 1.0 to capture 100%
    # of service spans for tracing.
    traces_sample_rate=1.0,
    # ___PRODUCT_OPTION_END___ performance
    # ___PRODUCT_OPTION_START___ profiling
    # To collect profiles for all profile sessions,
    # set `profile_session_sample_rate` to 1.0.
    profile_session_sample_rate=1.0,
    # Profiles will be automatically collected while
    # there is an active span.
    profile_lifecycle="trace",
    # ___PRODUCT_OPTION_END___ profiling
)
```

## [Verify](https://docs.sentry.io/platforms/python/integrations/chalice.md#verify)

```python
from chalice import Chalice

sentry_sdk.init(...)  # as above

app = Chalice(app_name="helloworld")

@app.schedule(Rate(1, unit=Rate.MINUTES))
def every_minute(event):
    1 / 0  # raises an error

@app.route("/")
def index():
    1 / 0  # raises an error
    return {"hello": "world"}
```

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

## [Behavior](https://docs.sentry.io/platforms/python/integrations/chalice.md#behavior)

* Request data is attached to all events: HTTP method, URL, headers, form data, JSON payloads. Sentry excludes raw bodies and multipart file uploads. Personally identifiable information (such as user IDs, usernames, cookies, and IP addresses) is also attached, with sensitive values like authorization headers scrubbed. Use the [`data_collection` option](https://docs.sentry.io/platforms/python/configuration/options.md#data_collection) to configure which categories to collect. In SDK versions prior to `3.0`, Sentry excludes this information unless you use `data_collection` or 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.

## [Supported Versions](https://docs.sentry.io/platforms/python/integrations/chalice.md#supported-versions)

* Chalice:

  * 1.16.0+ (SDK <3.0)
  * 1.22.0+ (SDK 3.0+)

* Python:

  * 3.6+ (SDK <3.0)
  * 3.7+ (SDK 3.0+)

---

Find other pages: [Sitemap](https://docs.sentry.io/sitemap.md) lists every page with a one-line summary, and [llms.txt](https://docs.sentry.io/llms.txt) gives an overview with guidance for agents.
