Skip to main content

The Datadog AWS Lambda Library

Project description

datadog-lambda-python

build PyPI PyPI - Python Version Slack License

Datadog Lambda Library for Python (3.8, 3.9, 3.10, 3.11, and 3.12) 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 Set to false to disable Cold Start Tracing. 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

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

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datadog_lambda-5.91.0.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

datadog_lambda-5.91.0-py3-none-any.whl (43.8 kB view details)

Uploaded Python 3

File details

Details for the file datadog_lambda-5.91.0.tar.gz.

File metadata

  • Download URL: datadog_lambda-5.91.0.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.8.10 Linux/5.15.0-1053-aws

File hashes

Hashes for datadog_lambda-5.91.0.tar.gz
Algorithm Hash digest
SHA256 cdb35ce0a730233a886d37163aeb58c736b6d6e152e5236e2eca19cca5a187f4
MD5 e9c5d585479087b35e45c1322df105bb
BLAKE2b-256 640c3a0873e5e3ae01403ed73e1aa5d4cd2485ec58e3b2aa69bff5d9dfe337f6

See more details on using hashes here.

File details

Details for the file datadog_lambda-5.91.0-py3-none-any.whl.

File metadata

  • Download URL: datadog_lambda-5.91.0-py3-none-any.whl
  • Upload date:
  • Size: 43.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.8.10 Linux/5.15.0-1053-aws

File hashes

Hashes for datadog_lambda-5.91.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d7d2235f306e64ccd9f02dc54b4412be1914e643f5b92113f8fa9cfe2d176d3
MD5 5c986e785823f04f67568dd1d68d3317
BLAKE2b-256 b6fde2569aba497e2f02fa87d4c1061eeee5c6bf4ff643bb3b245fb0ad2d662e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page