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
This library is provided both as an AWS Lambda Layer, and a NPM package. If you want to get off the ground quickly and don't need to
14
-
bundle your dependencies locally, the Lambda Layer method is the recommended approach.
13
+
This library is provided both as an AWS Lambda Layer, and a NPM package. If you want to get off the ground quickly and don't need to bundle your dependencies locally, the Lambda Layer method is the recommended approach.
15
14
16
15
### NPM method
17
16
@@ -61,6 +60,8 @@ functions:
61
60
DD_API_KEY: xxx
62
61
```
63
62
63
+
Alternatively, consider using [serverless-plugin-datadog](https://github.com/DataDog/serverless-plugin-datadog). The plugin can take care of adding lambda layers to your functions, and wrapping your handlers.
64
+
64
65
## Environment Variables
65
66
66
67
You can set the following environment variables via the AWS CLI or Serverless Framework
@@ -90,9 +91,28 @@ If you set the value of this variable to "true" then the Lambda layer will incre
90
91
Controlls whether or not the Datadog Trace ID is injected into log lines. See [DD_LOGS_INJECTION](#DD_LOGS_INJECTION-environment-variable) under
91
92
the Trace & Log Correlation section below.
92
93
94
+
### DD_LAMBDA_HANDLER
95
+
96
+
For use with the [redirected handler](#Redirected-Handler) method. Location of your original lambda handler.
97
+
98
+
### DD_TRACE_ENABLED
99
+
100
+
When used with the [redirected handler](#Redirected-Handler) method, will auto initialize the tracer when set to true.
101
+
93
102
## Usage
94
103
95
-
Datadog needs to be able to read headers from the incoming Lambda event.
104
+
Datadog needs to be able to read headers from the incoming Lambda event. To do this, you must wrap your handler function with our library. We provide some easy ways of wrapping your handlers.
105
+
106
+
### Redirected Handler
107
+
108
+
We provide a swap in replacement handler, with zero required code changes.
109
+
110
+
1. Set the environment variable `DD_LAMBDA_HANDLER` to your regular handler location, eg. `myfunc.handler`.
111
+
2. If using the layer, set your handler to `/opt/nodejs/node_modules/datadog-lambda-js/handler.handler`. If using installing your code as a library, use `node_modules/datadog-lambda-js/handler.handler`
112
+
113
+
### Manual Wrap
114
+
115
+
You might find it more convenient to wrap your handlers manually.
0 commit comments