10000 Add README data · DataDog/datadog-lambda-python@47a622b · GitHub
[go: up one dir, main page]

Skip to content

Commit 47a622b

Browse files
committed
Add README data
1 parent 76c3632 commit 47a622b

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Datadog Lambda Layer for Python (2.7, 3.6, 3.7 and 3.8) enables custom metric su
1010

1111
## IMPORTANT NOTE
1212

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

1515
## Installation
1616

@@ -21,6 +21,7 @@ arn:aws:lambda:<AWS_REGION>:464622532012:layer:Datadog-<PYTHON_RUNTIME>:<VERSION
2121
```
2222

2323
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+
2425
- `Datadog-Python27`
2526
- `Datadog-Python36`
2627
- `Datadog-Python37`
@@ -81,7 +82,7 @@ If `DD_FLUSH_TO_LOG` is set to false (not recommended), the Datadog API Key must
8182
- DD_KMS_API_KEY - the KMS-encrypted API Key, requires the `kms:Decrypt` permission
8283
- 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)
8384

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):
8586

8687
```python
8788
# 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
243244
If your Lambda function is deployed by the Serverless Framework, such a mapping template gets created by default.
244245

245246
## Log and Trace Correlations
247+
246248
By default, the Datadog trace id gets automatically injected into the logs for correlation, if using the standard python `logging` library.
247249

248250
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).
@@ -265,6 +267,35 @@ def lambda_handler(event, context):
265267
})
266268
```
267269

270+
## Datadog Tracer (**Experimental**)
271+
272+
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 X.
275+
1. If you are using the pip package `datadog-lambda-python`, upgrade it to at least version `v0.X.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+
@datadog_lambda_wrapper
286+
def hello(event, context):
287+
return {
288+
"statusCode": 200,
289+
"body": get_message()
290+
}
291+
292+
@tracer.wrap()
293+
def get_message():
294+
return "hello world"
295+
```
296+
297+
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.
298+
268299
## Opening Issues
269300

270301
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)
0