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
+48-5Lines changed: 48 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -87,11 +87,8 @@ If you set the value of this variable to "true" then the Lambda layer will incre
87
87
88
88
### DD_LOGS_INJECTION
89
89
90
-
By default, the Datadog trace id gets automatically injected into the logs for correlation, if using `console` or a logging library supported for [automatic](https://docs.datadoghq.com/tracing/connect_logs_and_traces/?tab=nodejs#automatic-trace-id-injection) trace id injection.
91
-
92
-
See instructions for [manual](https://docs.datadoghq.com/tracing/connect_logs_and_traces/?tab=nodejs#manual-trace-id-injection) trace id injection, if using other logging libraries.
93
-
94
-
Set the environment variable `DD_LOGS_INJECTION` to `false` to disable this feature.
90
+
Controlls whether or not the Datadog Trace ID is injected into log lines. See [DD_LOGS_INJECTION](#DD_LOGS_INJECTION-environment-variable) under
91
+
the Trace & Log Correlation section below.
95
92
96
93
## Usage
97
94
@@ -136,6 +133,52 @@ sendDistributionMetric(
136
133
137
134
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/).
138
135
136
+
## Trace & Log Correlation
137
+
138
+
### Using the Datadog Tracer
139
+
140
+
If you are using the [Datadog Tracer](#datadog-tracer-experimental), follow [these instructions](https://docs.datadoghq.com/tracing/connect_logs_and_traces/nodejs/#automatic-trace-id-injection)
141
+
to set up automatic trace-log correlation.
142
+
143
+
### Without using the Datadog Tracer
144
+
145
+
In order to correlate logs emitted by your Lambda with specific invocations, it
146
+
is necessary to add the AWS Request ID to your logs. This is done automatically
147
+
for `console.log()`, but you will have to implement this for other logging libraries.
148
+
149
+
The AWS Request ID is available in the context that is passed to your lambda handler,
150
+
as `context.awsRequestId`. It should be included in your log line as `lambda.request_id`.
151
+
152
+
For example, using the [Pino](https://getpino.io/) logger:
By default, the Datadog trace id gets automatically injected into the logs for correlation, if using `console` or a logging library supported for [automatic](https://docs.datadoghq.com/tracing/connect_logs_and_traces/?tab=nodejs#automatic-trace-id-injection) trace id injection.
176
+
177
+
See instructions for [manual](https://docs.datadoghq.com/tracing/connect_logs_and_traces/?tab=nodejs#manual-trace-id-injection) trace id injection, if using other logging libraries.
178
+
179
+
Set the environment variable `DD_LOGS_INJECTION` to `false` to disable this feature.
180
+
181
+
139
182
## Distributed Tracing
140
183
141
184
[Distributed tracing](https://docs.datadoghq.com/tracing/guide/distributed_tracing/?tab=nodejs) 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.
0 commit comments