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

[instrumentation-winston] LogRecord traceId and spanId values are not getting set correctly #2010

Open
hectorhdzg opened this issue Mar 14, 2024 · 1 comment
Assignees
Labels
bug Something isn't working pkg:instrumentation-winston priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Comments

@hectorhdzg
Copy link
Member

Specific repro code provided by @trentm available here

This issue is related to auto generation of Logs when using Winston instrumentation
#1837

@trentm
Copy link
Contributor

trentm commented Mar 14, 2024

I started trying to see if I could find an easy fix for this, but I didn't get to one.

My next idea was to see if instrumentation-winston could automatically add a Winston formatter when a Logger is created. That formatter would add the current spanContext to the meta (or is it info) object using Symbols. Then both the "log correlation" and "log sending" could use that captured spanContext on the info object.

It would mean that "log sending" would depend on that formatter. So a user attempting to do log sending without instrumentation-winston would need to add two things to their logger config. Something like:

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.combine(
    new OpenTelemetryCaptureSpanContextFormat(),
    // ... custom formatters if the user has any
  ),
  transports: [
    new winston.transports.Console(),
    new OpenTelemetryTransportV3()
  ]
});

This is just an idea, however. I haven't coded anything up to validate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:instrumentation-winston priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
Projects
None yet
Development

No branches or pull requests

3 participants