Datadog Lambda Library for Python (2.7, 3.6, 3.7 and 3.8) enables enhanced Lambda metrics, distributed tracing, and custom metric submission from AWS Lambda functions.
IMPORTANT NOTE: AWS Lambda is expected to recieve a breaking change on March 31, 2021. If you are using Datadog Python Lambda layer version 7 or below, please upgrade to the latest.
Follow the installation instructions, and view your function’s enhanced metrics, traces and logs in Datadog.
Once installed, you should be able to submit custom metrics from your Lambda function.
Check out the instructions for submitting custom metrics from AWS Lambda functions.
Once installed, you should be able to view your function’s traces in Datadog, and your function’s logs should be automatically connected to the traces.
For additional details on trace collection, take a look at collecting traces from AWS Lambda functions.
For additional details on trace and log connection, see connecting logs and traces.
For additional details on the tracer, check out the official documentation for Datadog trace client.
Once installed, you should be able to view enhanced metrics for your Lambda function in Datadog.
Check out the official documentation on Datadog Lambda enhanced metrics.
true (recommended) to send custom metrics asynchronously (with no added latency to your Lambda function executions) through CloudWatch Logs with the help of Datadog Forwarder. Defaults to
false. If set to
false, you also need to set
DD_FLUSH_TO_LOG is set to
false (not recommended), the Datadog API Key must be defined by setting one of the following environment variables:
kms:Decryptif using a customer managed CMK)
kms:Decryptif using a SecureString with a customer managed CMK)
You can also supply or override the API key at runtime (not recommended):
# Override DD API Key after importing datadog_lambda packages from datadog import api api._api_key = "MY_API_KEY"
DD_FLUSH_TO_LOG is set to
false (not recommended), and your data need to be sent to the Datadog EU site, you must set
datadoghq.eu. Defaults to
Inject Datadog trace id into logs for correlation. Defaults to
debug enable debug logs from the Datadog Lambda Library. Defaults to
Generate enhanced Datadog Lambda integration metrics, such as,
aws.lambda.enhanced.errors. Defaults to
Your original Lambda handler.
Initialize the Datadog tracer when set to
true. Defaults to
true to merge the X-Ray trace and the Datadog trace, when using both the X-Ray and Datadog tracing. Defaults to
If you encounter a bug with this package, we want to hear about it. Before opening a new issue, search the existing issues to avoid duplicates.
When opening an issue, include the Datadog Lambda Library version, Python version, and stack trace if available. In addition, include the steps to reproduce when appropriate.
You can also open an issue for a feature request.
If you find an issue with this package and have a fix, please feel free to open a pull request following the procedures.
Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2019 Datadog, Inc.