Skip to content

Commit

Permalink
docs(@opentelemetry/instrumentation-winston): Add extra details about…
Browse files Browse the repository at this point in the history
… @opentelemetry/winston-transport scenarios (#2302)
  • Loading branch information
hectorhdzg authored Jun 28, 2024
1 parent 626ecc5 commit 85ca5f1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/winston-transport/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const logger = winston.createLogger({
});
```

> [!IMPORTANT]
> Logs will be duplicated if `@opentelemetry/winston-transport` is added as a transport in `winston` and `@opentelemetry/instrumentation-winston` is configured with `disableLogSending: false`.
### Supported versions

- [`winston`](https://www.npmjs.com/package/winston) versions `>=3.0.0 <4`
Expand Down
37 changes: 37 additions & 0 deletions plugins/node/opentelemetry-instrumentation-winston/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,43 @@ logHook: (span, record) => {

Log injection can be disabled with the `disableLogCorrelation: true` option.

### Using OpenTelemetryTransportV3 without instrumentation

[@opentelemetry/winston-transport](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/winston-transport) package exports the Winston transport class that is used to send records to the
OpenTelemetry Logs SDK. It can be used directly when configuring a Winston logger.
For example:

```js
const logsAPI = require('@opentelemetry/api-logs');
const {
LoggerProvider,
SimpleLogRecordProcessor,
ConsoleLogRecordExporter,
} = require('@opentelemetry/sdk-logs');
const { OpenTelemetryTransportV3 } = require('@opentelemetry/winston-transport');
const winston = require('winston');


// To start a logger, you first need to initialize the Logger provider.
const loggerProvider = new LoggerProvider();
// Add a processor to export log record
loggerProvider.addLogRecordProcessor(
new SimpleLogRecordProcessor(new ConsoleLogRecordExporter())
);
logsAPI.logs.setGlobalLoggerProvider(loggerProvider);

const logger = winston.createLogger({
level: 'info',
transports: [
new winston.transports.Console(),
new OpenTelemetryTransportV3()
]
});
```

> [!IMPORTANT]
> Logs will be duplicated if `@opentelemetry/winston-transport` is added as a transport in `winston` and `@opentelemetry/instrumentation-winston` is configured with `disableLogSending: false`.
## Semantic Conventions

This package does not currently generate any attributes from semantic conventions.
Expand Down

0 comments on commit 85ca5f1

Please sign in to comment.