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: docs/shipping/Code/node-js.md
+44-3Lines changed: 44 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,18 +56,19 @@ var logger = require('logzio-nodejs').createLogger({
56
56
| Parameter | Description | Required/Default |
57
57
|---|---|---|
58
58
| token | Your Logz.io log shipping token securely directs the data to your [Logz.io account](https://app.logz.io/#/dashboard/settings/manage-tokens/log-shipping). {@include: ../../_include/log-shipping/log-shipping-token.html} | Required |
59
-
| protocol |`http`or `https`. The value of this parameter affects the default of the `port` parameter. |`http`|
59
+
| protocol |`http`, `https`or `udp`. The value of this parameter affects the default of the `port` parameter. |`http`|
60
60
| host | {@include: ../../_include/log-shipping/listener-var.md} Replace `<<LISTENER-HOST>>` with the host [for your region](https://docs.logz.io/docs/user-guide/admin/hosting-regions/account-region/#available-regions). The required port depends whether HTTP or HTTPS is used: HTTP = 8070, HTTPS = 8071. |`listener.logz.io`|
61
-
| port | Destination port. The default port depends on the `protocol` parameter:`8070`(for HTTP) or `8071`(for HTTPS)|`8070` / `8071`|
61
+
| port | Destination port. The default port depends on the `protocol` parameter.`8070` for HTTP, `8071` for HTTPS |`8070` / `8071`|
62
62
| type | {@include: ../../_include/log-shipping/type.md} |`nodejs`|
63
63
| sendIntervalMs | Time to wait between retry attempts, in milliseconds. |`2000` (2 seconds) |
64
64
| bufferSize | Maximum number of messages the logger accumulates before sending them all as a bulk. |`100`|
65
65
| numberOfRetries | Maximum number of retry attempts. |`3`|
66
66
| debug | Set to `true` to print debug messages to the console. |`false`|
67
-
| callback | A callback function to call when the logger encounters an unrecoverable error. The function API is `function(err)`, where `err` is the Error object. | -- |
67
+
| callback | A callback function to call when the logger encounters an unrecoverable error. On success: `callback()`. On error: `callback(error)` where `error` is the Error object. This function enables you to handle errors and successful transmissions independently. | -- |
68
68
| timeout | Read/write/connection timeout, in milliseconds. | -- |
69
69
| extraFields | JSON format. Adds your custom fields to each log. Format: `extraFields : { field_1: "val_1", field_2: "val_2" , ... }`| -- |
70
70
| setUserAgent | Set to false to send logs without the user-agent field in the request header. |`true`|
71
+
| addOtelContext | Add `trace_id`, `span_id`, and `service_name` fields to logs when OpenTelemetry context is available. | Default: `true`|
71
72
72
73
**Code example:**
73
74
@@ -95,6 +96,22 @@ For serverless environments, such as AWS Lambda, Azure Functions, or Google Clou
95
96
logger.sendAndClose();
96
97
```
97
98
99
+
100
+
### Add OpenTelemetry context
101
+
102
+
If you're sending traces with OpenTelemetry instrumentation (auto or manual), you can correlate your logs with the trace context. This ensures your logs include trace data, such as service name, `span_id` and `trace_id` (version >= `2.2.0`).
103
+
104
+
This feature is enabled by default, To disable it, set the `AddOtelContext` param in your handler configuration to `false`, like in this example:
105
+
106
+
```javascript
107
+
var logger =require('logzio-nodejs').createLogger({
@@ -170,6 +187,8 @@ For a complete list of your options, see the configuration parameters below.👇
170
187
| timeout | Read/write/connection timeout, in milliseconds. | -- |
171
188
| extraFields | Adds custom fields to each log in JSON format: `extraFields : { field_1: "val_1", field_2: "val_2" , ... }`| -- |
172
189
| setUserAgent | Set to `false` to send logs without the user-agent field in the request header. Set to `false` if sending data from Firefox browser. |`true`|
190
+
| addOtelContext | Add `trace_id`, `span_id`, and `service_name` fields to logs when OpenTelemetry context is available. | Default: `true`|
191
+
173
192
174
193
### Additional configuration options
175
194
@@ -233,6 +252,28 @@ var obj = {
233
252
logger.log(obj);
234
253
```
235
254
255
+
### Add opentelemetry context
256
+
If you're sending traces with OpenTelemetry instrumentation (auto or manual), you can correlate your logs with the trace context. This ensures your logs include trace data, such as service name, `span_id` and `trace_id` (version >= `5.2.0`).
257
+
258
+
This feature is enabled by default. To disable it, set the `AddOtelContext` param in your handler configuration to `false`, as shown in this example:
0 commit comments