AWS Lambda

(New in version 0.3.5)

Create a deployment package on your local machine and install the required dependencies in the deployment package. For more information, see Building an AWS Lambda deployment package for Python.

Install our Python SDK using pip:

$ pip install --upgrade sentry-sdk

You can use the AWS Lambda integration for the Python SDK like this:

import sentry_sdk
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration


def my_function(event, context):

Create the deployment package in .zip format and upload it to AWS Lambda as a Lambda function. Checkout Sentry's aws sample apps for detailed examples.


With the AWS Lambda integration enabled, the Python SDK will:

  • Automatically report all uncaught exceptions from your lambda functions including a link to the cloudwatch logs, the function details and sys.argv for the function. You can add more context as described here

  • 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.
On this page