Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
64 changes: 61 additions & 3 deletions docs/shipping/Code/node-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,19 @@ var logger = require('logzio-nodejs').createLogger({
| Parameter | Description | Required/Default |
|---|---|---|
| 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 |
| protocol | `http` or `https`. The value of this parameter affects the default of the `port` parameter. | `http` |
| protocol | `http`, `https` or `udp`. The value of this parameter affects the default of the `port` parameter. | `http` |
| 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` |
| port | Destination port. The default port depends on the `protocol` parameter: `8070` (for HTTP) or `8071` (for HTTPS) | `8070` / `8071` |
| port | Destination port. The default port depends on the `protocol` parameter. `8070` for HTTP, `8071` for HTTPS | `8070` / `8071` |
| type | {@include: ../../_include/log-shipping/type.md} | `nodejs` |
| sendIntervalMs | Time to wait between retry attempts, in milliseconds. | `2000` (2 seconds) |
| bufferSize | Maximum number of messages the logger accumulates before sending them all as a bulk. | `100` |
| numberOfRetries | Maximum number of retry attempts. | `3` |
| debug | Set to `true` to print debug messages to the console. | `false` |
| 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. | -- |
| 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. | -- |
| timeout | Read/write/connection timeout, in milliseconds. | -- |
| extraFields | JSON format. Adds your custom fields to each log. Format: `extraFields : { field_1: "val_1", field_2: "val_2" , ... }` | -- |
| setUserAgent | Set to false to send logs without the user-agent field in the request header. | `true` |
| addOtelContext | Add `trace_id`, `span_id`, and `service_name` fields to logs when OpenTelemetry context is available. | Default: `true` |

**Code example:**

Expand Down Expand Up @@ -95,6 +96,22 @@ For serverless environments, such as AWS Lambda, Azure Functions, or Google Clou
logger.sendAndClose();
```


### Add OpenTelemetry context

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`).

This feature is enabled by default, To disable it, set the `AddOtelContext` param in your handler configuration to `false`, like in this example:

```javascript
var logger = require('logzio-nodejs').createLogger({
token: 'token',
type: 'no-otel-context',
addOtelContext: false
});
```


</TabItem>
<TabItem value="winston-logzio" label="winston-logzio">

Expand Down Expand Up @@ -170,6 +187,8 @@ For a complete list of your options, see the configuration parameters below.👇
| timeout | Read/write/connection timeout, in milliseconds. | -- |
| extraFields | Adds custom fields to each log in JSON format: `extraFields : { field_1: "val_1", field_2: "val_2" , ... }` | -- |
| 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` |
| addOtelContext | Add `trace_id`, `span_id`, and `service_name` fields to logs when OpenTelemetry context is available. | Default: `true` |


### Additional configuration options

Expand Down Expand Up @@ -233,6 +252,45 @@ var obj = {
logger.log(obj);
```

### Add opentelemetry context
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`).

This feature is enabled by default. To disable it, set the `AddOtelContext` param in your handler configuration to `false`, as shown in this example:

```javascript
const winston = require('winston');
const LogzioWinstonTransport = require('winston-logzio');

const logzioWinstonTransport = new LogzioWinstonTransport({
level: 'info',
name: 'winston_logzio',
token: '<<SHIPPING-TOKEN>>',
host: '<<LISTENER-HOST>>',
addOtelCotext: false,
});

const logger = winston.createLogger({
format: winston.format.simple(),
transports: [logzioWinstonTransport],
});
```

### Build and test locally

1. Clone the repository:

```bash
git clone https://github.com/logzio/winston-logzio.git
cd winston-logzio
```

2. Build and run tests:

```bash
npm install
npm test
```


</TabItem>
<TabItem value="Typescript" label="winston-logzio Typescript">
Expand Down
1 change: 1 addition & 0 deletions docs/user-guide/explore/trace-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Supported integrations for Trace context:

* [.NET](https://docs.logz.io/docs/shipping/Code/dotnet/#add-trace-context-1)
* [Python](https://docs.logz.io/docs/shipping/Code/Python/#trace-context)
* [Node.js](https://docs.logz.io/docs/shipping/code/node-js/)

Additional integrations will be available in future updates.

Expand Down
Loading