You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I converted the example code in the @opentelemetry/instrumentation-pino package to ES module syntax, the instrumentation stopped working. But it works as expected when run using the original CommonJS format.
import{NodeSDK,tracing,logs,api}from"@opentelemetry/sdk-node";import{PinoInstrumentation}from"@opentelemetry/instrumentation-pino";importpinofrom"pino";constsdk=newNodeSDK({spanProcessor: newtracing.SimpleSpanProcessor(newtracing.ConsoleSpanExporter(),),logRecordProcessor: newlogs.SimpleLogRecordProcessor(newlogs.ConsoleLogRecordExporter(),),instrumentations: [newPinoInstrumentation({// See below for Pino instrumentation options.}),],});sdk.start();constlogger=pino();logger.info("hi");// 1. Log records will be sent to the SDK-registered log record processor, if any.// This is called "log sending".consttracer=api.trace.getTracer("example");tracer.startActiveSpan("manual-span",(span)=>{logger.info("in a span");// 2. Fields identifying the current span will be added to log records:// {"level":30,...,"msg":"in a span","trace_id":"d61b4e4af1032e0aae279d12f3ab0159","span_id":"d140da862204f2a2","trace_flags":"01"}// This feature is called "log correlation".});
What did you expect to see?
The trace_id and span_id in the logs, alongside their OTLP representation as is the case with the original CommonJS format:
What version of OpenTelemetry are you using?
@opentelemetry/[email protected]
@opentelemetry/[email protected]
@opentelemetry/[email protected]
[email protected]
What version of Node are you using?
Node.js 24
What did you do?
When I converted the example code in the
@opentelemetry/instrumentation-pino
package to ES module syntax, the instrumentation stopped working. But it works as expected when run using the original CommonJS format.What did you expect to see?
The
trace_id
andspan_id
in the logs, alongside their OTLP representation as is the case with the original CommonJS format:What did you see instead?
No
trace_id
orspan_id
. The OTLP console representation was also absent:Additional context
The text was updated successfully, but these errors were encountered: