Hi, I'm trying to send pino logs to grafana loki from a NextJS server side context, with pino-opentelemetry-transport I have this error:
Error [ERR_INTERNAL_ASSERTION]: Unknown worker message type message
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at Function.fail (node:internal/assert:20:9)
at [kOnMessage] (node:internal/worker:354:12)
at MessagePort.<anonymous> (node:internal/worker:232:57)
at _ZoneDelegate.invokeTask (webpack-internal:///(ssr)/../../node_modules/.pnpm/zone.js@0.11.8/node_modules/zone.js/fesm2015/zone.js:406:31)
at Zone.runTask (webpack-internal:///(ssr)/../../node_modules/.pnpm/zone.js@0.11.8/node_modules/zone.js/fesm2015/zone.js:178:47)
at ZoneTask.invokeTask [as invoke] (webpack-internal:///(ssr)/../../node_modules/.pnpm/zone.js@0.11.8/node_modules/zone.js/fesm2015/zone.js:487:34)
at invokeTask (webpack-internal:///(ssr)/../../node_modules/.pnpm/zone.js@0.11.8/node_modules/zone.js/fesm2015/zone.js:1661:18)
at globalCallback (webpack-internal:///(ssr)/../../node_modules/.pnpm/zone.js@0.11.8/node_modules/zone.js/fesm2015/zone.js:1692:29)
at MessagePort.globalZoneAwareCallback (webpack-internal:///(ssr)/../../node_modules/.pnpm/zone.js@0.11.8/node_modules/zone.js/fesm2015/zone.js:1725:16)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:820:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
at MessagePort.callbackTrampoline (node:internal/async_hooks:130:17) {
code: 'ERR_INTERNAL_ASSERTION'
}
About the code, this is my instrumentation config:
const OTEL_COLLECTOR_URL="http://localhost:4318";
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
const sdk = new NodeSDK({
serviceName: "next-node-instrumentation",
textMapPropagator: new W3CTraceContextPropagator(),
traceExporter: new OTLPTraceExporter({
url: `${OTEL_COLLECTOR_URL}/v1/traces`
}),
instrumentations: [
getNodeAutoInstrumentations(),
new PinoInstrumentation({
logHook: (span, record) => {
console.log("RECEIVE FROM HOOK")
}
}),
],
logRecordProcessors: [
new logs.SimpleLogRecordProcessor(new logs.ConsoleLogRecordExporter()),
new logs.SimpleLogRecordProcessor(
new OTLPLogExporter({
url: `${OTEL_COLLECTOR_URL}/v1/logs`,
}),
)],
})
sdk.start()
and this is an example POST route where pino is used:
export async function POST(request: Request) {
const { url } = await request.json();
const transport = pino.transport({
target: 'pino-opentelemetry-transport'
})
const log = pino(transport)
log.info("HELLO FROM PINO");
}
env
OTEL_EXPORTER_OTLP_PROTOCOL=http
OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://localhost:4318
node -v: 20.17.0
next: 14
pino: 9.4.0
pino-opentelemetry-transport: 1.0.1
Am I missing something inside the configuration?
Hi, I'm trying to send pino logs to grafana loki from a NextJS server side context, with pino-opentelemetry-transport I have this error:
About the code, this is my instrumentation config:
and this is an example POST route where pino is used:
env
node -v: 20.17.0
next: 14
pino: 9.4.0
pino-opentelemetry-transport: 1.0.1
Am I missing something inside the configuration?