Skip to main content

The Datadog AWS Lambda Layer

Project description

datadog-lambda-python

build PyPI PyPI - Python Version Slack License

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 January 30, 2021. If you are using Datadog Python Lambda layer version 7 or below, please upgrade to the latest.

Installation

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

Custom Metrics

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.

Tracing

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.

Enhanced Metrics

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.

Environment Variables

DD_FLUSH_TO_LOG

Set to 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_API_KEY and DD_SITE.

DD_API_KEY

If 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:

  • DD_API_KEY - the Datadog API Key in plain-text, NOT recommended
  • DD_KMS_API_KEY - the KMS-encrypted API Key, requires the kms:Decrypt permission
  • DD_API_KEY_SECRET_ARN - the Secret ARN to fetch API Key from the Secrets Manager, requires the secretsmanager:GetSecretValue permission (and kms:Decrypt if using a customer managed CMK)
  • DD_API_KEY_SSM_NAME - the Parameter Name to fetch API Key from the Systems Manager Parameter Store, requires the ssm:GetParameter permission (and kms:Decrypt if 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_SITE

If DD_FLUSH_TO_LOG is set to false (not recommended), you must set DD_SITE. Possible values are datadoghq.com, datadoghq.eu, us3.datadoghq.com and ddog-gov.com. The default is datadoghq.com.

DD_LOGS_INJECTION

Inject Datadog trace id into logs for correlation. Defaults to true.

DD_LOG_LEVEL

Set to debug enable debug logs from the Datadog Lambda Library. Defaults to info.

DD_ENHANCED_METRICS

Generate enhanced Datadog Lambda integration metrics, such as, aws.lambda.enhanced.invocations and aws.lambda.enhanced.errors. Defaults to true.

DD_LAMBDA_HANDLER

Your original Lambda handler.

DD_TRACE_ENABLED

Initialize the Datadog tracer when set to true. Defaults to false.

DD_MERGE_XRAY_TRACES

Set to true to merge the X-Ray trace and the Datadog trace, when using both the X-Ray and Datadog tracing. Defaults to 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.

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-2.28.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distributions

datadog_lambda-2.28.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

datadog_lambda-2.28.0-py2-none-any.whl (19.3 kB view details)

Uploaded Python 2

File details

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

File metadata

  • Download URL: datadog_lambda-2.28.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.2

File hashes

Hashes for datadog_lambda-2.28.0.tar.gz
Algorithm Hash digest
SHA256 35d9ccbd97e044ceb4a16ae210e5eca8f092372ff5fef69579aeb9d862d229d3
MD5 13d570360bec0c76ea0b4ebe0e39fae3
BLAKE2b-256 18427d213181252492dccd50702610b31f036bb947c785216431d41ae9cc9bf8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: datadog_lambda-2.28.0-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.2

File hashes

Hashes for datadog_lambda-2.28.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5116796c858793ed54adb1a14b86bf3cba3e6874d7238fe41e78c6a647c35199
MD5 5494c531b5b46eb8407f54b006035fb9
BLAKE2b-256 8ebd243f47ac79acbc9a51577c1492be19f45a8d005cc0d87facb5dd0632b624

See more details on using hashes here.

File details

Details for the file datadog_lambda-2.28.0-py2-none-any.whl.

File metadata

  • Download URL: datadog_lambda-2.28.0-py2-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.2

File hashes

Hashes for datadog_lambda-2.28.0-py2-none-any.whl
Algorithm Hash digest
SHA256 742f04b009542102e2d896dc80c0d30eb9a9946e9fd3dd4c6cfa642d34b1d4fc
MD5 a7c36d6ca5a521c5b261d33a80f61d29
BLAKE2b-256 d770a197847f0b5e69452a0d265dac35edc03ef50227b94eaef88898b953c5da

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