Skip to content

Commit 5ffab8e

Browse files
authored
Refresh README (#217)
1 parent dabbcfe commit 5ffab8e

File tree

1 file changed

+25
-54
lines changed

1 file changed

+25
-54
lines changed

README.md

Lines changed: 25 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,78 +6,33 @@
66
[![Slack](https://chat.datadoghq.com/badge.svg?bg=632CA6)](https://chat.datadoghq.com/)
77
[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/DataDog/datadog-lambda-python/blob/main/LICENSE)
88

9-
Datadog Lambda Library for Python (3.6, 3.7, 3.8, and 3.9) enables enhanced Lambda metrics, distributed tracing, and custom metric submission from AWS Lambda functions.
10-
11-
**IMPORTANT NOTE:** AWS Lambda is expected to receive a [breaking change](https://aws.amazon.com/blogs/compute/upcoming-changes-to-the-python-sdk-in-aws-lambda/) on **March 31, 2021**. If you are using Datadog Python Lambda layer version 7 or below, please upgrade to the latest.
9+
Datadog Lambda Library for Python (3.6, 3.7, 3.8, and 3.9) enables [enhanced Lambda metrics](https://docs.datadoghq.com/serverless/enhanced_lambda_metrics), [distributed tracing](https://docs.datadoghq.com/serverless/distributed_tracing), and [custom metric submission](https://docs.datadoghq.com/serverless/custom_metrics) from AWS Lambda functions.
1210

1311
## Installation
1412

1513
Follow the [installation instructions](https://docs.datadoghq.com/serverless/installation/python/), and view your function's enhanced metrics, traces and logs in Datadog.
1614

17-
## Custom Metrics
18-
19-
Once [installed](#installation), you should be able to submit custom metrics from your Lambda function.
20-
21-
Check out the instructions for [submitting custom metrics from AWS Lambda functions](https://docs.datadoghq.com/integrations/amazon_lambda/?tab=python#custom-metrics).
22-
23-
## Tracing
24-
25-
Once [installed](#installation), you should be able to view your function's traces in Datadog, and your function's logs should be automatically connected to the traces.
26-
27-
For additional details on trace collection, take a look at [collecting traces from AWS Lambda functions](https://docs.datadoghq.com/integrations/amazon_lambda/?tab=python#trace-collection).
28-
29-
For additional details on trace and log connection, see [connecting logs and traces](https://docs.datadoghq.com/tracing/connect_logs_and_traces/python/).
30-
31-
For additional details on the tracer, check out the [official documentation for Datadog trace client](http://pypi.datadoghq.com/trace/docs/index.html).
32-
33-
## Enhanced Metrics
34-
35-
Once [installed](#installation), you should be able to view enhanced metrics for your Lambda function in Datadog.
36-
37-
Check out the official documentation on [Datadog Lambda enhanced metrics](https://docs.datadoghq.com/integrations/amazon_lambda/?tab=python#real-time-enhanced-lambda-metrics).
15+
For advanced distributed tracing use cases, check out the [official documentation for Datadog APM client](https://ddtrace.readthedocs.io).
3816

39-
## Advanced Configurations
40-
41-
### Handler Wrapper
42-
43-
In order to instrument individual invocations, the Datadog Lambda library needs to wrap around your Lambda handler function. This is usually achieved by setting your function's handler to the Datadog handler function (`datadog_lambda.handler.handler`) and setting the environment variable `DD_LAMBDA_HANDLER` with your original handler function to be called by the Datadog handler.
44-
45-
If this method doesn't work for you, instead of setting the handler and the `DD_LAMBDA_HANDLER` environment variable, you can apply the Datadog Lambda library wrapper in your function code like below:
46-
47-
```python
48-
from datadog_lambda.wrapper import datadog_lambda_wrapper
49-
50-
@datadog_lambda_wrapper
51-
def my_lambda_handle(event, context):
52-
# your function code
53-
```
17+
To connect traces and logs using a custom logger, see [connecting logs and traces](https://docs.datadoghq.com/tracing/connect_logs_and_traces/python/).
5418

5519
## Environment Variables
5620

57-
### DD_FLUSH_TO_LOG
58-
59-
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](https://github.com/DataDog/datadog-serverless-functions/tree/main/aws/logs_monitoring). Defaults to `false`. If set to `false`, you also need to set `DD_API_KEY` and `DD_SITE`.
60-
6121
### DD_API_KEY
6222

63-
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:
23+
If you are using the [Datadog Lambda Extension](https://docs.datadoghq.com/serverless/libraries_integrations/extension/), the Datadog API Key must be defined by setting one of the following environment variables:
6424

6525
- DD_API_KEY - the Datadog API Key in plain-text, NOT recommended
6626
- DD_KMS_API_KEY - the KMS-encrypted API Key, requires the `kms:Decrypt` permission
6727
- 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)
68-
- 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)
6928

70-
You can also supply or override the API key at runtime (not recommended):
71-
72-
```python
73-
# Override DD API Key after importing datadog_lambda packages
74-
from datadog import api
75-
api._api_key = "MY_API_KEY"
76-
```
29+
If you are using the [Datadog Forwarder](https://github.com/DataDog/datadog-serverless-functions/tree/main/aws/logs_monitoring), you must set the Datadog API Key on the Datadog Forwarder instead of your own Lambda function.
7730

7831
### DD_SITE
7932

80-
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`, `us5.datadoghq.com`, and `ddog-gov.com`. The default is `datadoghq.com`.
33+
If you are using the [Datadog Lambda Extension](https://docs.datadoghq.com/serverless/libraries_integrations/extension/), you must set `DD_SITE` on your Lambda function based on your [Datadog site](https://docs.datadoghq.com/getting_started/site/). The default is `datadoghq.com`.
34+
35+
If you are using the [Datadog Forwarder](https://github.com/DataDog/datadog-serverless-functions/tree/main/aws/logs_monitoring), you must set this on the Datadog Forwarder instead of your own Lambda function.
8136

8237
### DD_LOGS_INJECTION
8338

@@ -93,7 +48,17 @@ Generate enhanced Datadog Lambda integration metrics, such as, `aws.lambda.enhan
9348

9449
### DD_LAMBDA_HANDLER
9550

96-
Your original Lambda handler.
51+
In order to instrument individual invocations, the Datadog Lambda library needs to wrap around your Lambda handler function. This is usually achieved by setting your function's handler to the Datadog handler function (`datadog_lambda.handler.handler`) and setting the environment variable `DD_LAMBDA_HANDLER` with your original handler function to be called by the Datadog handler.
52+
53+
For some advanced use cases, instead of overriding the handler setting and the `DD_LAMBDA_HANDLER` environment variable, you can apply the Datadog Lambda library wrapper in your function code like below:
54+
55+
```python
56+
from datadog_lambda.wrapper import datadog_lambda_wrapper
57+
58+
@datadog_lambda_wrapper
59+
def my_lambda_handle(event, context):
60+
# your function code
61+
```
9762

9863
### DD_TRACE_ENABLED
9964

@@ -121,6 +86,12 @@ Infers spans for:
12186
- S3
12287
- DynamoDB
12388

89+
### DD_FLUSH_TO_LOG (Deprecated)
90+
91+
When the [Datadog Forwarder](https://github.com/DataDog/datadog-serverless-functions/tree/main/aws/logs_monitoring) was launched previously, `DD_FLUSH_TO_LOG` was introduced to control whether to send custom metrics synchronously from your own Lambda function directly to Datadog with added latency (set `DD_FLUSH_TO_LOG` to `false` and you also need to set `DD_API_KEY` and `DD_SITE`) or asynchronously through CloudWatch logs (set `DD_FLUSH_TO_LOG` to `true`).
92+
93+
Now you should consider adopting the [Datadog Lambda Extension](https://docs.datadoghq.com/serverless/libraries_integrations/extension/) for sending custom metrics. When the Datadog Lambda Extension is installed and detected, `DD_FLUSH_TO_LOG` is ignored. If you wish to Defaults to `false`. If set to `false`, you also need to set `DD_API_KEY` and `DD_SITE`.
94+
12495
## Opening Issues
12596

12697
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.

0 commit comments

Comments
 (0)