Skip to main content

datadog-lambda-python

build PyPI PyPI - Python Version Slack License

Datadog Lambda Library for Python (3.8, 3.9, 3.10, 3.11, 3.12, 3.13, and 3.14) enables enhanced Lambda metrics, distributed tracing, and custom metric submission from AWS Lambda functions.

Installation

Follow the installation instructions, and view your function's enhanced metrics, traces and logs in Datadog.

Configuration

Follow the configuration instructions to tag your telemetry, capture request/response payloads, filter or scrub sensitive information from logs or traces, and more.

For additional tracing configuration options, check out the official documentation for Datadog trace client.

Besides the environment variables supported by dd-trace-py, the datadog-lambda-python library added following environment variables.

Environment Variables Description Default Value
DD_ENCODE_AUTHORIZER_CONTEXT When set to true for Lambda authorizers, the tracing context will be encoded into the response for propagation. Supported for NodeJS and Python. true
DD_DECODE_AUTHORIZER_CONTEXT When set to true for Lambdas that are authorized via Lambda authorizers, it will parse and use the encoded tracing context (if found). Supported for NodeJS and Python. true
DD_COLD_START_TRACING When true (default), tracing occurs during cold start which creates many child spans. When false, only one cold start span is created. Used in NodeJS and Python. true
DD_MIN_COLD_START_DURATION Sets the minimum duration (in milliseconds) for a module load event to be traced via Cold Start Tracing. Number. 3
DD_COLD_START_TRACE_SKIP_LIB optionally skip creating Cold Start Spans for a comma-separated list of libraries. Useful to limit depth or skip known libraries. ddtrace.internal.compat,ddtrace.filters
DD_CAPTURE_LAMBDA_PAYLOAD Captures incoming and outgoing AWS Lambda payloads in the Datadog APM spans for Lambda invocations. false
DD_CAPTURE_LAMBDA_PAYLOAD_MAX_DEPTH Determines the level of detail captured from AWS Lambda payloads, which are then assigned as tags for the aws.lambda span. It specifies the nesting depth of the JSON payload structure to process. Once the specified maximum depth is reached, the tag's value is set to the stringified value of any nested elements beyond this level.
For example, given the input payload:
{
"lv1" : {
"lv2": {
"lv3": "val"
}
}
}
If the depth is set to 2, the resulting tag's key is set to function.request.lv1.lv2 and the value is {\"lv3\": \"val\"}.
If the depth is set to 0, the resulting tag's key is set to function.request and value is {\"lv1\":{\"lv2\":{\"lv3\": \"val\"}}}
10
DD_EXCEPTION_REPLAY_ENABLED When set to true, the Lambda will run with Error Tracking Exception Replay enabled, capturing local variables. false
DD_DSM_EXCHANGE_NAME If you are using Datadog Data Streams Monitoring and propagating context through Amazon Event Bridge, this variable specifies the name of the EventBridge EventBus. The name of the bus is not passed through in the event payload and therefore cannot be automatically inferred at consume time. false

Opening Issues

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.

Lambda Profiling Beta

Datadog's Continuous Profiler is now available in beta for Python in version 4.62.0 and layer version 62 and above. This optional feature is enabled by setting the DD_PROFILING_ENABLED environment variable to true. During the beta period, profiling is available at no additional cost.

The Continuous Profiler works by spawning a thread which periodically wakes up and takes a snapshot of the CPU and Heap of all running python code. This can include the profiler itself. If you want the Profiler to ignore itself, set DD_PROFILING_IGNORE_PROFILER to true.

Major Version Notes

6.x / Layer version 95+

  • The release changed how Lambda's traceID is hashed if the incoming payload contains Step Functions context object. This change only affects those who uses inject Step Functions context object into Lambda payload.

5.x / Layer version 86+

  • Python3.7 support has been deprecated by AWS, and support removed from this library.

4.x / Layer version 61+

  • Python3.6 support has been deprecated by AWS, and support removed from this library.
  • dd-trace upgraded from 0.61 to 1.4, full release notes are available here
    • get_correlation_ids() has been changed to get_log_correlation_context(), which now returns a dictionary containing the active span_id, trace_id, as well as service and env.

Contributing

If you find an issue with this package and have a fix, please feel free to open a pull request following the procedures.

Community

For product feedback and questions, join the #serverless channel in the Datadog community on Slack.

License

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.

Metadata

Release files for datadog_lambda 8.129.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datadog_lambda 8.129.0
File Size Uploaded
datadog_lambda-8.129.0.tar.gz 53.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datadog_lambda 8.129.0
File Interpreter ABI Platform
datadog_lambda-8.129.0-py3-none-any.whl Python 3 none any Details

Total release size: 115.5 kB

Release files / datadog_lambda-8.129.0.tar.gz

Download URL datadog_lambda-8.129.0.tar.gz
Size 53.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5593a539c04fd4655a87ac164d7eb3a35db01b53e0b5264e555d7565dc86c6cc
BLAKE2b-256 checksum
How to use checksums
7b076ac1ff74f94271ba2025406dd6fe72f721bc5dba34515f8faefe28eadc4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.8.10 Linux/6.8.0-1066-aws

Release files / datadog_lambda-8.129.0-py3-none-any.whl

Download URL datadog_lambda-8.129.0-py3-none-any.whl
Size 61.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4b08a08a538cd0bcd216e5a29f93465a40a4b65793eab00b49524685aed7a83
BLAKE2b-256 checksum
How to use checksums
7b9e4f3c4b185f4617c6f818a087b4ad20f50f4342f975b41d8ebd1c7b738e25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.8.10 Linux/6.8.0-1066-aws

Release history Release notifications | RSS feed

This release

8.129.0 This release

2 release files

6.98.0

2 release files

6.97.0

2 release files

6.96.0

2 release files

5.93.0

2 release files

5.92.0

2 release files

5.91.0

2 release files

5.90.0

2 release files

5.87.0

2 release files

5.86.0

2 release files

5.84.0

2 release files

5.83.0

2 release files

4.82.0

2 release files

4.81.0

2 release files

4.80.0

2 release files

4.79.0

2 release files

4.77.0

2 release files

4.75.0

2 release files

4.74.0

2 release files

4.73.0

2 release files

4.72.0

2 release files

4.71.0

2 release files

4.70.0

2 release files

4.69.0

2 release files

4.68.0

2 release files

4.67.0

2 release files

4.66.0

2 release files

4.63.0

2 release files

4.62.0

2 release files

4.61.0

2 release files

3.60.0

2 release files

3.59.0

2 release files

3.57.0

2 release files

3.55.0

2 release files

3.54.0

2 release files

3.53.0

2 release files

3.52.0

2 release files

3.48.0

2 release files

3.47.0

2 release files

3.46.0

2 release files

3.45.0

2 release files

3.43.0

2 release files

3.42.0

2 release files

3.41.0

2 release files

3.40.0

2 release files

3.38.0

2 release files

3.37.0

2 release files

3.35.0

2 release files

3.34.0

2 release files

3.33.0

2 release files

3.31.0

2 release files

2.30.0

2 release files

2.29.0

2 release files

2.24.0

2 release files

2.21.0

2 release files

2.19.0

3 release files

2.18.0

2 release files

2.17.0

2 release files

2.13.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page