-
Notifications
You must be signed in to change notification settings - Fork 940
How to enrich LogRecord with traceid and spanid? (web) #4210
-
In our setup we use NgxLogger and provide a specific logger monitor (impementation of INGXLoggerMonitor) that forwards the log messages via otlp to a running opentelemetry collector instance.
Currently, I'm struggeling with two things:
- How to add traceid and spanid to created LogRecord objects for correlation? Do I have to provide my own 'Context' object that returns appropriate values for 'traceId' and 'spanId'?
- Currently
const currentSpan = trace.getSpan(context.active());is undefined, even though the logger is triggered by interacting with the web page and instrumenation of user-interactions is configured correctlyregisterInstrumentations({ instrumentations: [ new DocumentLoadInstrumentation(), new UserInteractionInstrumentation(), ], });
I appreciate any hint pointing me in the right direction. I could only find one example that shows the basic use (see here \opentelemetry-js\experimental\examples\logs\index.ts). But this example does not cover how to get the current trace and span identifier and how to propagate them to the log record, for correlation of traces with log records.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
Did you ever figure this out?
Beta Was this translation helpful? Give feedback.
All reactions
-
Did you ever figure this out?
Unfortunately not, nobody commented on this and I have not investigated this further. Since some time has passed since then, I hope that this is solved with current version and documentation. Do you have a similar issue, with current versions?
Beta Was this translation helpful? Give feedback.