AWS Lambda Container Image
Deprecation Notice
The Python AWS Lambda Container Image is deprecated.
Please instrument your AWS Lambda function in one of the following ways instead:
- Without touching your code: This method can be instrumented from the Sentry product by those who have access to the AWS infrastructure and doesn't require that you make any direct updates to the code. See the AWS Lambda guide.
- By adding the Sentry Lambda Layer to your function manually: While this is a quick way to add Sentry to your AWS Lambda function, it gives you limited configuration possibilities with environment vars. See AWS Lambda Layer.
- By manually adding Sentry to your function code: This method requires that you install the Sentry SDK into your AWS Lambda function packages. While it takes more effort to set up, it gives you full control of your setup and manual instrumentation. See AWS Lambda manual instrumentation.
As an alternative setup method, you can add Sentry to your Container Image. To import Sentry's Layer Image, add the following to your Dockerfile:
Copied
COPY /opt/ /opt
Replace VERSION
with a specific version number (for example, 6). You can see a complete list of available versions in Sentry's Amazon ECR repository.
Set your image’s CMD value to the Sentry Handler:
Copied
CMD ["sentry_sdk.integrations.init_serverless_sdk.sentry_lambda_handler"]
Next, set the following environment variables in AWS:
- Set
SENTRY_INITIAL_HANDLER
to the path of your function handler - Set
SENTRY_DSN
to your Sentry DSN - Set
SENTRY_TRACES_SAMPLE_RATE
to your preferred sampling rate for transactions
Alternatively, you can also set the environment variables in your Dockerfile. Values set in AWS override the values in a Dockerfile if both are provided.
Copied
ENV SENTRY_INITIAL_HANDLER="<PATH_TO_FUNCTION_HANDLER>"
ENV SENTRY_DSN="https://examplePublicKey@o0.ingest.sentry.io/0"
ENV SENTRY_TRACES_SAMPLE_RATE="1.0"
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
- Package:
- pypi:sentry-sdk
- Version:
- 1.45.0
- Repository:
- https://github.com/getsentry/sentry-python
- API Documentation:
- https://getsentry.github.io/sentry-python/