Skip to content
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

fix(@opentelemetry/instrumentation-winston): Add extra details about @opentelemetry/winston-transport scenarios #2302

Merged
merged 8 commits into from
Jun 28, 2024
2 changes: 2 additions & 0 deletions packages/winston-transport/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const logger = winston.createLogger({
});
```

Duplication of logs could happen if @opentelemetry/winston-transport is added as a transport in Winston logger and @opentelemetry/instrumentation-winston is also enabled with disableLogSending config as false.

### Supported versions

- [`winston`](https://www.npmjs.com/package/winston) versions `>=3.0.0 <4`
Expand Down
36 changes: 36 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,42 @@ 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()
]
});
```

Duplication of logs could happen if @opentelemetry/winston-transport is added as a transport in Winston logger and @opentelemetry/instrumentation-winston is also enabled with disableLogSending config as false.
hectorhdzg marked this conversation as resolved.
Show resolved Hide resolved

## Semantic Conventions

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