Open
Description
What version of OpenTelemetry are you using?
"@opentelemetry/instrumentation-pino": "0.44.0",
What version of Node are you using?
v20.11.1
What did you do?
I am adding pino log messages to the my span using logHook of pino instrumentation. I tried with winston instrumentation. Log messages are adding to the span and able to see it in the jaager UI.
What did you expect to see?
I want log message should be there part of record parameter as like to winston. So I can add it in the span.
What did you see instead?
I don't see log message. But I see only traceId, spanId and trace flags.
Additional context
I am using jaeger all in one collector to collect the traces from my service. I am using GRPC OLTP Trace Exporter to export the traces. I have used pino logger for logging and registered pino instrumentation for automatic log correlation with span Id, trace ID.
tracing.js
const { BatchSpanProcessor, AlwaysOnSampler} = require("@opentelemetry/sdk-trace-base");
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { Resource } = require("@opentelemetry/resources");
const {
SEMRESATTRS_SERVICE_NAME,
} = require("@opentelemetry/semantic-conventions");
const { diag, DiagConsoleLogger, DiagLogLevel } = require("@opentelemetry/api");
const { HttpInstrumentation } = require("@opentelemetry/instrumentation-http");
const { registerInstrumentations } = require("@opentelemetry/instrumentation");
const {
OTLPTraceExporter,
} = require("@opentelemetry/exporter-trace-otlp-grpc");
const {
B3Propagator,
B3InjectEncoding,
} = require("@opentelemetry/propagator-b3");
const {
ExpressInstrumentation
} = require('@opentelemetry/instrumentation-express');
const { PinoInstrumentation } = require('@opentelemetry/instrumentation-pino');
module.exports = {
initTracing: (config) => {
if (config?.tracing?.enableDebug) {
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ALL);
}
const exporter = new OTLPTraceExporter(config.tracing);
const provider = new NodeTracerProvider({
sampler: new AlwaysOnSampler(),
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: config.service_name,
}),
});
provider.addSpanProcessor(new BatchSpanProcessor(exporter, config?.batchSpanProcessorConfig));
provider.register({
propagator: new B3Propagator({
injectEncoding: B3InjectEncoding.MULTI_HEADER,
}),
});
registerInstrumentations({
instrumentations: [
new ExpressInstrumentation(),
new HttpInstrumentation({
ignoreIncomingRequestHook: function (request) {
if (config.tracing.urls_to_be_skipped.includes(request.url)) {
return true;
}
},
applyCustomAttributesOnSpan: function (span, request, response) {
span.updateName(request.path);
},
ignoreOutgoingRequestHook: () => true,
}),
new PinoInstrumentation(
{
enabled: true,
logHook: (span, record) => {
span.addEvent("log", record);
},
}
),
],
tracerProvider: provider,
});
return provider;
},
};