AWS Lambda instrumentation for Python
Compatibility
The supported runtime versions are Python 3.8, 3.9, 3.10, and 3.11.
Most of the Python Library features are supported in the AWS Lambda environment. The exceptions are:
- Custom transaction naming via the SDK
- Trigger trace
Add layer
Ensure the otelcol layer is already added and configured.
The layer ARN is listed in the SolarWinds Observability Summary Release Notes. Be sure to choose the AWS Region and architecture that correspond to your Lambda function.
An example of adding the arm64 Python instrumentation layer to your function (in the us-east-1 region) using AWS CLI v2:
The --layers
argument replaces what is set for the function, so any existing layers should be specified in the argument.
aws lambda update-function-configuration --function-name <your-function-name> --layers 'arn:aws:lambda:us-east-1:851060098468:layer:solarwinds-apm-python-arm64-1_6_0:1' ...
Configure
Set the required environment variables listed below in your Lambda function’s configuration settings. Recommended and useful optional settings are also listed.
Environment variable | Description | Requirement |
---|---|---|
AWS_LAMBDA_EXEC_WRAPPER
|
This must be set to enable the instrumentation extension. |
Required |
SW_APM_TRANSACTION_NAME
|
<transaction-name> Telemetry from the Lambda function will be associated with this Transaction under the SolarWinds Observability SaaS Service. If unset, the Transaction name defaults to the Lambda function name. |
Recommended |
SW_APM_DEBUG_LEVEL
|
This may be useful for diagnostic purposes or for reducing logging to AWS CloudWatch. |
Optional |
The other standard Python Library configuration options that are supported in the AWS Lambda environment are listed below.
- Logging output filepath
- Tracing mode
- Tracing mode per transaction (Enable or disable tracing for specific requests)
- Disable the library
- Disable specific instrumentation libraries
- Customize OpenTelemetry propagators
- Customize OpenTelemetry service name
- Customize OpenTelemetry resource attributes (Note that only the OTEL_SERVICE_NAME environment variable should be used to set the Lambda function’s service name.)
- Config file location
- Trace context in logs
- Custom logging format
- Trace context in queries
- Customize trace context in queries