Skip to content

feat: Clarify the duplicate logging workaround #2831

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vordimous
Copy link

Which problem is this PR solving?

  • I spent a few days trying to figure out how to stop duplicate logs from happening while needing to use the OpenTelemetryTransportV3 to format my payload correctly.

Short description of the changes

  • This adds some clarity and an example how to correctly disable the default logger in the auto instrumentation.

@vordimous vordimous requested a review from a team as a code owner May 18, 2025 17:54
@github-actions github-actions bot requested a review from seemk May 18, 2025 17:54
@pichlermarc pichlermarc requested a review from trentm July 2, 2025 16:51
Comment on lines +142 to +157
> Logs will be duplicated if `@opentelemetry/winston-transport` is added as a transport in `winston` and `@opentelemetry/instrumentation-winston` is configured with `disableLogSending: false`. You must import `winston` after you have called `registerInstrumentations`.
> ```js
>const { WinstonInstrumentation } = require('@opentelemetry/instrumentation-winston');
>const { registerInstrumentations } = require('@opentelemetry/instrumentation');
>registerInstrumentations({
> instrumentations: [
> new WinstonInstrumentation({
> // Disable the duplicate logging from the auto instrumentation
> disableLogSending: true
> }),
> ],
>});
>// Winston import must be after the WinstonInstrumentation creation
>const { OpenTelemetryTransportV3 } = require('@opentelemetry/winston-transport');
>const winston = require('winston');
> ```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vordimous How about this wording:

Suggested change
> Logs will be duplicated if `@opentelemetry/winston-transport` is added as a transport in `winston` and `@opentelemetry/instrumentation-winston` is configured with `disableLogSending: false`. You must import `winston` after you have called `registerInstrumentations`.
> ```js
>const { WinstonInstrumentation } = require('@opentelemetry/instrumentation-winston');
>const { registerInstrumentations } = require('@opentelemetry/instrumentation');
>registerInstrumentations({
> instrumentations: [
> new WinstonInstrumentation({
> // Disable the duplicate logging from the auto instrumentation
> disableLogSending: true
> }),
> ],
>});
>// Winston import must be after the WinstonInstrumentation creation
>const { OpenTelemetryTransportV3 } = require('@opentelemetry/winston-transport');
>const winston = require('winston');
> ```
> Logs will be **duplicated** if `OpenTelemetryTransportV3` is explicitly added as a Winston logger transport **and** `@opentelemetry/instrumentation-winston` is active with the [Log sending](#log-sending) feature (the default). If you are both using `OpenTelemetryTransportV3` and instrumentation-winston, be sure to either disable instrumentation-winston completely, or disable its Log sending feature (`disableLogSending: false`). For examle:
>
> ```js
> const { WinstonInstrumentation } = require('@opentelemetry/instrumentation-winston');
> const { registerInstrumentations } = require('@opentelemetry/instrumentation');
> registerInstrumentations({
> instrumentations: [
> new WinstonInstrumentation({
> disableLogSending: true
> }),
> ],
> });
> const { OpenTelemetryTransportV3 } = require('@opentelemetry/winston-transport');
> // Winston import must be after the WinstonInstrumentation creation
> const winston = require('winston');
>
> // ...
> const logger = winston.createLogger(...);
> ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants