Skip to content

Commit 1e00b11

Browse files
Merge pull request #10 from DataDog/darcy.rayner/add-badge-to-readme
Add badges
2 parents 6bd1672 + 8ac8962 commit 1e00b11

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
@@ -27,15 +32,15 @@ The minor version of the `datadog-lambda` package always match the layer version
2732

2833
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):
2934

30-
* DD_API_KEY or DD_KMS_API_KEY (if encrypted by KMS)
35+
- DD_API_KEY or DD_KMS_API_KEY (if encrypted by KMS)
3136

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

34-
* DD_SITE
39+
- DD_SITE
3540

3641
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).
3742

38-
* DD_FLUSH_TO_LOG
43+
- DD_FLUSH_TO_LOG
3944

4045
### The Serverless Framework
4146

@@ -62,7 +67,6 @@ functions:
6267
DD_API_KEY: <DD_API_KEY>
6368
```
6469
65-
6670
## Basic Usage
6771
6872
```python
@@ -76,10 +80,9 @@ def lambda_handler(event, context):
7680
requests.get("https://www.datadoghq.com")
7781
```
7882
79-
8083
## Custom Metrics
8184
82-
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/).
85+
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/).
8386

8487
**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.
8588

@@ -97,14 +100,14 @@ def lambda_handler(event, context):
97100
```
98101

99102
### VPC
100-
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/).
101103

104+
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/).
102105

103106
## Distributed Tracing
104107

105-
[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.
108+
[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.
106109

107-
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.
110+
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.
108111

109112
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.
110113

@@ -119,7 +122,7 @@ def lambda_handler(event, context):
119122
requests.get("https://www.datadoghq.com")
120123
```
121124

122-
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/).
125+
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/).
123126

124127
### Patching
125128

@@ -150,46 +153,48 @@ aws xray create-sampling-rule --cli-input-json file://datadog-sampling-priority-
150153
```
151154

152155
The file content for `datadog-sampling-priority-1.json`:
156+
153157
```json
154158
{
155-
"SamplingRule": {
156-
"RuleName": "Datadog-Sampling-Priority-1",
157-
"ResourceARN": "*",
158-
"Priority": 9998,
159-
"FixedRate": 1,
160-
"ReservoirSize": 100,
161-
"ServiceName": "*",
162-
"ServiceType": "AWS::APIGateway::Stage",
163-
"Host": "*",
164-
"HTTPMethod": "*",
165-
"URLPath": "*",
166-
"Version": 1,
167-
"Attributes": {
168-
"x-datadog-sampling-priority": "1"
169-
}
159+
"SamplingRule": {
160+
"RuleName": "Datadog-Sampling-Priority-1",
161+
"ResourceARN": "*",
162+
"Priority": 9998,
163+
"FixedRate": 1,
164+
"ReservoirSize": 100,
165+
"ServiceName": "*",
166+
"ServiceType": "AWS::APIGateway::Stage",
167+
"Host": "*",
168+
"HTTPMethod": "*",
169+
"URLPath": "*",
170+
"Version": 1,
171+
"Attributes": {
172+
"x-datadog-sampling-priority": "1"
170173
}
174+
}
171175
}
172176
```
173177

174178
The file content for `datadog-sampling-priority-2.json`:
179+
175180
```json
176181
{
177-
"SamplingRule": {
178-
"RuleName": "Datadog-Sampling-Priority-2",
179-
"ResourceARN": "*",
180-
"Priority": 9999,
181-
"FixedRate": 1,
182-
"ReservoirSize": 100,
183-
"ServiceName": "*",
184-
"ServiceType": "AWS::APIGateway::Stage",
185-
"Host": "*",
186-
"HTTPMethod": "*",
187-
"URLPath": "*",
188-
"Version": 1,
189-
"Attributes": {
190-
"x-datadog-sampling-priority": "2"
191-
}
182+
"SamplingRule": {
183+
"RuleName": "Datadog-Sampling-Priority-2",
184+
"ResourceARN": "*",
185+
"Priority": 9999,
186+
"FixedRate": 1,
187+
"ReservoirSize": 100,
188+
"ServiceName": "*",
189+
"ServiceType": "AWS::APIGateway::Stage",
190+
"Host": "*",
191+
"HTTPMethod": "*",
192+
"URLPath": "*",
193+
"Version": 1,
194+
"Attributes": {
195+
"x-datadog-sampling-priority": "2"
192196
}
197+
}
193198
}
194199
```
195200

@@ -199,7 +204,6 @@ If your Lambda function is triggered by API Gateway via [the non-proxy integrati
199204

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

202-
203207
## Opening Issues
204208

205209
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.
@@ -208,12 +212,10 @@ When opening an issue, include the Datadog Lambda Layer version, Python version,
208212

209213
You can also open an issue for a feature request.
210214

211-
212215
## Contributing
213216

214217
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).
215218

216-
217219
## License
218220

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

0 commit comments

Comments
 (0)