You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-2Lines changed: 34 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Datadog Lambda Layer for Python (2.7, 3.6, 3.7 and 3.8) enables custom metric su
10
10
11
11
## IMPORTANT NOTE
12
12
13
-
AWS Lambda is expected to recieve a [breaking change](https://aws.amazon.com/blogs/compute/upcoming-changes-to-the-python-sdk-in-aws-lambda/) on **January 30, 2021**. If you are using Datadog Python Lambda layer version 7 or below, please upgrade to version 11.
13
+
AWS Lambda is expected to recieve a [breaking change](https://aws.amazon.com/blogs/compute/upcoming-changes-to-the-python-sdk-in-aws-lambda/) on **January 30, 2021**. If you are using Datadog Python Lambda layer version 7 or below, please upgrade to version 11.
Replace `<AWS_REGION>` with the AWS region where your Lambda function is published to. Replace `<PYTHON_RUNTIME>` with one of the following that matches your Lambda's Python runtime:
24
+
24
25
-`Datadog-Python27`
25
26
-`Datadog-Python36`
26
27
-`Datadog-Python37`
@@ -81,7 +82,7 @@ If `DD_FLUSH_TO_LOG` is set to false (not recommended), the Datadog API Key must
81
82
- DD_KMS_API_KEY - the KMS-encrypted API Key, requires the `kms:Decrypt` permission
82
83
- 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)
83
84
84
-
You can also supply or override the API key at runtime (not recommended):
85
+
You can also supply or override the API key at runtime (not recommended):
85
86
86
87
```python
87
88
# Override DD API Key after importing datadog_lambda packages
@@ -243,6 +244,7 @@ If your Lambda function is triggered by API Gateway via [the non-proxy integrati
243
244
If your Lambda function is deployed by the Serverless Framework, such a mapping template gets created by default.
244
245
245
246
## Log and Trace Correlations
247
+
246
248
By default, the Datadog trace id gets automatically injected into the logs for correlation, if using the standard python `logging` library.
247
249
248
250
If you use a custom logger handler to log in json, you can inject the ids using the helper function `get_correlation_ids` [manually](https://docs.datadoghq.com/tracing/connect_logs_and_traces/?tab=python#manual-trace-id-injection).
You can now trace Lambda functions using Datadog APM's tracing libraries ([dd-trace-py](https://github.com/DataDog/dd-trace-py)).
273
+
274
+
1. If you are using the Lambda layer, upgrade it to at least version 15.
275
+
1. If you are using the pip package `datadog-lambda-python`, upgrade it to at least version `v2.15.0`.
276
+
1. Install (or update to) the latest version of [Datadog forwarder Lambda function](https://docs.datadoghq.com/integrations/amazon_web_services/?tab=allpermissions#set-up-the-datadog-lambda-function). Ensure the trace forwarding layer is attached to the forwarder, e.g., ARN for Python 2.7 `arn:aws:lambda:<AWS_REGION>:464622532012:layer:Datadog-Trace-Forwarder-Python27:4`.
277
+
1. Set the environment variable `DD_TRACE_ENABLED` to true on your function.
278
+
1. Instrument your function using `dd-trace`.
279
+
280
+
```py
281
+
from datadog_lambda.metric import lambda_metric
282
+
from datadog_lambda.wrapper import datadog_lambda_wrapper
283
+
284
+
from ddtrace import tracer
285
+
286
+
@datadog_lambda_wrapper
287
+
def hello(event, context):
288
+
return {
289
+
"statusCode": 200,
290
+
"body": get_message()
291
+
}
292
+
293
+
@tracer.wrap()
294
+
def get_message():
295
+
return "hello world"
296
+
```
297
+
298
+
You can also use `dd-trace` and the X-Ray tracer together and merge the traces into one, using the environment variable `DD_MERGE_XRAY_TRACES` to true on your function.
299
+
268
300
## Opening Issues
269
301
270
302
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