Skip to content

Commit ef639e4

Browse files
authored
Consolidate serverless configurations into one place (#105)
* Update README.md * Update README.md
1 parent 11ed98d commit ef639e4

File tree

1 file changed

+3
-96
lines changed

1 file changed

+3
-96
lines changed

README.md

Lines changed: 3 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -10,104 +10,11 @@ Datadog Lambda Library for Go enables enhanced Lambda metrics, distributed traci
1010

1111
## Installation
1212

13-
Follow the installation instructions [here](https://docs.datadoghq.com/serverless/installation/go/).
13+
Follow the [installation instructions](https://docs.datadoghq.com/serverless/installation/go/), and view your function's enhanced metrics, traces and logs in Datadog.
1414

15-
## Enhanced Metrics
15+
## Configurations
1616

17-
Once [installed](#installation), you should be able to view enhanced metrics for your Lambda function in Datadog.
18-
19-
Check out the official documentation on [Datadog Lambda enhanced metrics](https://docs.datadoghq.com/integrations/amazon_lambda/?tab=go#real-time-enhanced-lambda-metrics).
20-
21-
## Custom Metrics
22-
23-
Once [installed](#installation), you should be able to submit custom metrics from your Lambda function.
24-
25-
Check out the instructions for [submitting custom metrics from AWS Lambda functions](https://docs.datadoghq.com/integrations/amazon_lambda/?tab=go#custom-metrics).
26-
27-
## Tracing
28-
29-
Set the `DD_TRACE_ENABLED` environment variable to `true` to enable Datadog tracing. When Datadog tracing is enabled, the library will inject a span representing the Lambda's execution into the context object. You can then use the included `dd-trace-go` package to create additional spans from the context or pass the context to other services. For more information, see the [dd-trace-go documentation](https://godoc.org/gopkg.in/DataDog/dd-trace-go.v1/ddtrace).
30-
31-
```go
32-
import (
33-
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
34-
httptrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http"
35-
)
36-
37-
func handleRequest(ctx context.Context, ev events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
38-
// Trace an HTTP request
39-
req, _ := http.NewRequestWithContext(ctx, "GET", "https://www.datadoghq.com", nil)
40-
client := http.Client{}
41-
client = *httptrace.WrapClient(&client)
42-
client.Do(req)
43-
44-
// Create a custom span
45-
s, _ := tracer.StartSpanFromContext(ctx, "child.span")
46-
time.Sleep(100 * time.Millisecond)
47-
s.Finish()
48-
}
49-
```
50-
51-
You can also use the injected span to [connect your logs and traces](https://docs.datadoghq.com/tracing/connect_logs_and_traces/go/).
52-
53-
```go
54-
func handleRequest(ctx context.Context, ev events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
55-
currentSpan, _ := tracer.SpanFromContext(ctx)
56-
log.Printf("my log message %v", currentSpan)
57-
}
58-
```
59-
60-
If you are also using AWS X-Ray to trace your Lambda functions, you can set the `DD_MERGE_XRAY_TRACES` environment variable to `true`, and Datadog will merge your Datadog and X-Ray traces into a single, unified trace.
61-
62-
### Trace Context Extraction
63-
64-
To link your distributed traces, datadog-lambda-go looks for the `x-datadog-trace-id`, `x-datadog-parent-id` and `x-datadog-sampling-priority` trace `headers` in the Lambda event payload.
65-
If the headers are found it will set the parent trace to the trace context extracted from the headers.
66-
67-
It is possible to configure your own trace context extractor function if the default extractor does not support your event.
68-
69-
```go
70-
myExtractorFunc := func(ctx context.Context, ev json.RawMessage) map[string]string {
71-
// extract x-datadog-trace-id, x-datadog-parent-id and x-datadog-sampling-priority.
72-
}
73-
74-
cfg := &ddlambda.Config{
75-
TraceContextExtractor: myExtractorFunc,
76-
}
77-
ddlambda.WrapFunction(handler, cfg)
78-
```
79-
80-
A more complete example can be found in the `ddlambda_example_test.go` file.
81-
82-
## Environment Variables
83-
84-
### DD_FLUSH_TO_LOG
85-
86-
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/master/aws/logs_monitoring). Defaults to `false`. If set to `false`, you also need to set `DD_API_KEY` and `DD_SITE`.
87-
88-
### DD_API_KEY
89-
90-
If `DD_FLUSH_TO_LOG` is set to `false` (not recommended), the Datadog API Key must be defined.
91-
92-
### DD_SITE
93-
94-
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`.
95-
96-
### DD_LOG_LEVEL
97-
98-
Set to `debug` enable debug logs from the Datadog Lambda Library. Defaults to `info`.
99-
100-
### DD_ENHANCED_METRICS
101-
102-
Generate enhanced Datadog Lambda integration metrics, such as, `aws.lambda.enhanced.invocations` and `aws.lambda.enhanced.errors`. Defaults to `true`.
103-
104-
### DD_TRACE_ENABLED
105-
106-
Initialize the Datadog tracer when set to `true`. Defaults to `false`.
107-
108-
### DD_MERGE_XRAY_TRACES
109-
110-
If you are using both X-Ray and Datadog tracing, set this to `true` to merge the X-Ray and Datadog traces. Defaults to `false`.
17+
See the [advanced configuration options](https://docs.datadoghq.com/serverless/configuration) to tag your telemetry, capture request/response payloads, filter or scrub sensitive information from logs or traces, and more.
11118

11219
## Opening Issues
11320

0 commit comments

Comments
 (0)