Skip to content

fix(nodejs): bundle @opentelemetry/winston-transport so winston logs are exported - #2666

Open
vasireddy99 wants to merge 2 commits into
open-telemetry:mainfrom
vasireddy99:nodejs-winston-transport
Open

vasireddy99 wants to merge 2 commits into
open-telemetry:mainfrom
vasireddy99:nodejs-winston-transport

Conversation

@vasireddy99

@vasireddy99 vasireddy99 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2065

What's wrong

The Node layer ships @opentelemetry/instrumentation-winston, but winston log records are never exported.

The instrumentation loads @opentelemetry/winston-transport lazily, with require() inside a try/catch, when it patches winston.createLogger. That package is only a devDependency of instrumentation-winston, so it is never installed into the layer and webpack can't bundle it.

Testing

I ran the tests locally on Node 20.18 with --experimental-require-module.

…are exported

The layer ships @opentelemetry/instrumentation-winston, but log sending
never worked. The instrumentation loads @opentelemetry/winston-transport
lazily with require() inside a try/catch, and that package is only a
devDependency of the instrumentation, so it was never installed into the
layer and webpack could not bundle it ("Can't resolve
'@opentelemetry/winston-transport'"). At runtime the require threw, the
instrumentation logged a diag warning hidden at the default log level,
and no winston log records were ever exported. Trace context injection
into winston records was unaffected, which made the gap easy to miss.

Add @opentelemetry/winston-transport as a layer dependency. Use ^0.32.0,
which depends on @opentelemetry/api-logs ^0.222.0 like the layer does, so
only one api-logs copy is installed and the transport sees the logger
provider the layer registers.

Add a wrapper test that enables the winston instrumentation, logs through
a real winston logger and asserts the record reaches the layer's logger
provider. It fails without the transport with the same warning users see.

Fixes open-telemetry#2065

Signed-off-by: Vasi Vasireddy <pvasir@amazon.com>
@github-actions github-actions Bot added the javascript Pull requests that update Javascript code label Oct 13, 2026
@vasireddy99
vasireddy99 marked this pull request as ready for review October 13, 2026 20:42
@vasireddy99
vasireddy99 requested a review from a team as a code owner October 13, 2026 20:42

@thompson-tomo thompson-tomo left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same feedback as #2517

I am little bit confused. If i look at https://www.npmjs.com/package/@opentelemetry/winston-transport it mentions

If using @opentelemetry/instrumenation-winston package there is no need to instantiate the transport as the instrumentation will take care of that.

If i then look at the docs for the instrumentation it doesn't use the transport package https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation-winston.

Looking at the changes here i can't see what difference the additional package is making to what is released.

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

Labels

javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Winston Instrumentation Race Condition in AWS Lambda Layer

2 participants