Skip to content

Commit 0372bfa

Browse files
tianchuswfunc
andauthored
Add instructions for manual tracer initialization (#122)
* Add instructions for manual tracer initialization * Update README.md Co-authored-by: Stephen Firrincieli <[email protected]> Co-authored-by: Stephen Firrincieli <[email protected]>
1 parent 4676b80 commit 0372bfa

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,26 @@ For additional details on trace collection, take a look at [collecting traces fr
2525

2626
For additional details on trace and log connection, check out the [official documentation for Datadog trace client](https://datadoghq.dev/dd-trace-js/).
2727

28+
### Plugins
29+
2830
The `fs` module is disabled by default. If you want to enable it you have to set the environment variable `DD_TRACE_DISABLED_PLUGINS` to `''` or to a comma-separated list of the plugins you want to disable. See the full list of supported plugins [here](https://docs.datadoghq.com/tracing/compatibility_requirements/nodejs/).
2931

32+
### Tracer Initialization
33+
34+
By default, the Datadog Lambda library automatically initializes the tracer. However, you can follow the steps below to initialize the tracer with [custom settings](https://datadoghq.dev/dd-trace-js/#tracer-settings) in your own function code.
35+
36+
1. Set enviornment variable `DD_TRACE_ENABLED` to `false`, so the Datadog Lambda library does not initialize the tracer.
37+
1. Add the following snippet to the function code to manually initialize the tracer with your desired settings.
38+
```js
39+
const tracer = require('dd-trace').init({
40+
enabled: true,
41+
tags: {
42+
"_dd.origin": "lambda",
43+
},
44+
sampleRate: 0.1 // e.g., keep 10% of traces
45+
});
46+
```
47+
3048
### Trace & Log Correlation
3149

3250
By default, the Datadog trace id gets automatically injected into the logs for correlation, if using `console` or a logging library supported for automatic trace id injection. You have to manually inject the trace id, if using other logging libraries. See additional details on [connecting logs and traces](https://docs.datadoghq.com/tracing/connect_logs_and_traces/nodejs/).

0 commit comments

Comments
 (0)