Skip to content

Document how to apply the wrapper in code #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ By default, the Datadog trace id gets automatically injected into the logs for c

Set the environment variable `DD_LOGS_INJECTION` to `false` to disable this feature.

## Handler wrapper

In order to instrument individual invocations, the Datadog Lambda library needs to wrap around your Lambda handler function. This is usually achieved by pointing your function's handler setting to the provided Datadog handler function and passing the original handler function through an environment variable to be called by the Datadog handler.

If this method doesn't work for you, instead of overriding the handler and setting the `DD_LAMBDA_HANDLER` environment variable, you can apply the Datadog Lambda library wrapper in your function code like below:

```js
const { datadog } = require("datadog-lambda-js");
const tracer = require('dd-trace').init({});

module.exports.myHandler = datadog(myHandler, {
// my function code
});
```

## Custom logger

You can use your own logger to log layer error and debug logs instead of default `console`
Expand Down