Skip to content

Commit 3c1f47e

Browse files
committed
Add badges
1 parent 8fc9e9b commit 3c1f47e

File tree

1 file changed

+45
-43
lines changed

1 file changed

+45
-43
lines changed

README.md

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# datadog-lambda-layer-python
22

3+
![CircleCI](https://img.shields.io/circleci/build/github/DataDog/datadog-lambda-layer-python)
4+
[![PyPI](https://img.shields.io/pypi/v/datadog-lambda)](https://pypi.org/project/datadog-lambda/)
5+
[![Slack](https://img.shields.io/badge/slack-%23serverless-blueviolet?logo=slack)](https://datadoghq.slack.com/channels/serverless/)
6+
[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/DataDog/datadog-lambda-layer-python/blob/master/LICENSE)
7+
38
Datadog Lambda Layer for Python (2.7, 3.6 and 3.7) enables custom metric submission from AWS Lambda functions, and distributed tracing between serverful and serverless environments.
49

510
## Installation
@@ -18,15 +23,15 @@ arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Python37:1
1823

1924
The Datadog API must be defined as an environment variable via [AWS CLI](https://docs.aws.amazon.com/lambda/latest/dg/env_variables.html) or [Serverless Framework](https://serverless-stack.com/chapters/serverless-environment-variables.html):
2025

21-
* DD_API_KEY or DD_KMS_API_KEY (if encrypted by KMS)
26+
- DD_API_KEY or DD_KMS_API_KEY (if encrypted by KMS)
2227

2328
Set the following Datadog environment variable to `datadoghq.eu` to send your data to the Datadog EU site.
2429

25-
* DD_SITE
30+
- DD_SITE
2631

2732
If your Lambda function powers a performance-critical task (e.g., a consumer-facing API). You can avoid the added latencies of metric-submitting API calls, by setting the following Datadog environment variable to `True`. Custom metrics will be submitted asynchronously through CloudWatch Logs and [the Datadog log forwarder](https://github.com/DataDog/datadog-serverless-functions/tree/master/aws/logs_monitoring).
2833

29-
* DD_FLUSH_TO_LOG
34+
- DD_FLUSH_TO_LOG
3035

3136
### The Serverless Framework
3237

@@ -53,7 +58,6 @@ functions:
5358
DD_API_KEY: <DD_API_KEY>
5459
```
5560
56-
5761
## Basic Usage
5862
5963
```python
@@ -67,10 +71,9 @@ def lambda_handler(event, context):
6771
requests.get("https://www.datadoghq.com")
6872
```
6973
70-
7174
## Custom Metrics
7275
73-
Custom metrics can be submitted using `lambda_metric` and the Lambda handler function needs to be decorated with `@datadog_lambda_wrapper`. The metrics are submitted as [distribution metrics](https://docs.datadoghq.com/graphing/metrics/distributions/).
76+
Custom metrics can be submitted using `lambda_metric` and the Lambda handler function needs to be decorated with `@datadog_lambda_wrapper`. The metrics are submitted as [distribution metrics](https://docs.datadoghq.com/graphing/metrics/distributions/).
7477

7578
**IMPORTANT NOTE:** If you have already been submitting the same custom metric as non-distribution metric (e.g., gauge, count, or histogram) without using the Datadog Lambda Layer, you MUST pick a new metric name to use for `lambda_metric`. Otherwise that existing metric will be converted to a distribution metric and the historical data prior to the conversion will be no longer queryable.
7679

@@ -88,14 +91,14 @@ def lambda_handler(event, context):
8891
```
8992

9093
### VPC
91-
If your Lambda function is associated with a VPC, you need to ensure it has [access to the public internet](https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/).
9294

95+
If your Lambda function is associated with a VPC, you need to ensure it has [access to the public internet](https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/).
9396

9497
## Distributed Tracing
9598

96-
[Distributed tracing](https://docs.datadoghq.com/tracing/guide/distributed_tracing/?tab=python) allows you to propagate a trace context from a service running on a host to a service running on AWS Lambda, and vice versa, so you can see performance end-to-end. Linking is implemented by injecting Datadog trace context into the HTTP request headers.
99+
[Distributed tracing](https://docs.datadoghq.com/tracing/guide/distributed_tracing/?tab=python) allows you to propagate a trace context from a service running on a host to a service running on AWS Lambda, and vice versa, so you can see performance end-to-end. Linking is implemented by injecting Datadog trace context into the HTTP request headers.
97100

98-
Distributed tracing headers are language agnostic, e.g., a trace can be propagated between a Java service running on a host to a Lambda function written in Python.
101+
Distributed tracing headers are language agnostic, e.g., a trace can be propagated between a Java service running on a host to a Lambda function written in Python.
99102

100103
Because the trace context is propagated through HTTP request headers, the Lambda function needs to be triggered by AWS API Gateway or AWS Application Load Balancer.
101104

@@ -110,7 +113,7 @@ def lambda_handler(event, context):
110113
requests.get("https://www.datadoghq.com")
111114
```
112115

113-
Note, the Datadog Lambda Layer is only needed to enable *distributed* tracing between Lambda and non-Lambda services. For standalone Lambda functions, traces can be found in Datadog APM after configuring [the X-Ray integration](https://docs.datadoghq.com/integrations/amazon_xray/).
116+
Note, the Datadog Lambda Layer is only needed to enable _distributed_ tracing between Lambda and non-Lambda services. For standalone Lambda functions, traces can be found in Datadog APM after configuring [the X-Ray integration](https://docs.datadoghq.com/integrations/amazon_xray/).
114117

115118
### Patching
116119

@@ -141,46 +144,48 @@ aws xray create-sampling-rule --cli-input-json file://datadog-sampling-priority-
141144
```
142145

143146
The file content for `datadog-sampling-priority-1.json`:
147+
144148
```json
145149
{
146-
"SamplingRule": {
147-
"RuleName": "Datadog-Sampling-Priority-1",
148-
"ResourceARN": "*",
149-
"Priority": 9998,
150-
"FixedRate": 1,
151-
"ReservoirSize": 100,
152-
"ServiceName": "*",
153-
"ServiceType": "AWS::APIGateway::Stage",
154-
"Host": "*",
155-
"HTTPMethod": "*",
156-
"URLPath": "*",
157-
"Version": 1,
158-
"Attributes": {
159-
"x-datadog-sampling-priority": "1"
160-
}
150+
"SamplingRule": {
151+
"RuleName": "Datadog-Sampling-Priority-1",
152+
"ResourceARN": "*",
153+
"Priority": 9998,
154+
"FixedRate": 1,
155+
"ReservoirSize": 100,
156+
"ServiceName": "*",
157+
"ServiceType": "AWS::APIGateway::Stage",
158+
"Host": "*",
159+
"HTTPMethod": "*",
160+
"URLPath": "*",
161+
"Version": 1,
162+
"Attributes": {
163+
"x-datadog-sampling-priority": "1"
161164
}
165+
}
162166
}
163167
```
164168

165169
The file content for `datadog-sampling-priority-2.json`:
170+
166171
```json
167172
{
168-
"SamplingRule": {
169-
"RuleName": "Datadog-Sampling-Priority-2",
170-
"ResourceARN": "*",
171-
"Priority": 9999,
172-
"FixedRate": 1,
173-
"ReservoirSize": 100,
174-
"ServiceName": "*",
175-
"ServiceType": "AWS::APIGateway::Stage",
176-
"Host": "*",
177-
"HTTPMethod": "*",
178-
"URLPath": "*",
179-
"Version": 1,
180-
"Attributes": {
181-
"x-datadog-sampling-priority": "2"
182-
}
173+
"SamplingRule": {
174+
"RuleName": "Datadog-Sampling-Priority-2",
175+
"ResourceARN": "*",
176+
"Priority": 9999,
177+
"FixedRate": 1,
178+
"ReservoirSize": 100,
179+
"ServiceName": "*",
180+
"ServiceType": "AWS::APIGateway::Stage",
181+
"Host": "*",
182+
"HTTPMethod": "*",
183+
"URLPath": "*",
184+
"Version": 1,
185+
"Attributes": {
186+
"x-datadog-sampling-priority": "2"
183187
}
188+
}
184189
}
185190
```
186191

@@ -190,7 +195,6 @@ If your Lambda function is triggered by API Gateway via [the non-proxy integrati
190195

191196
If your Lambda function is deployed by the Serverless Framework, such a mapping template gets created by default.
192197

193-
194198
## Opening Issues
195199

196200
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.
@@ -199,12 +203,10 @@ When opening an issue, include the Datadog Lambda Layer version, Python version,
199203

200204
You can also open an issue for a feature request.
201205

202-
203206
## Contributing
204207

205208
If you find an issue with this package and have a fix, please feel free to open a pull request following the [procedures](CONTRIBUTING.md).
206209

207-
208210
## License
209211

210212
Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.

0 commit comments

Comments
 (0)