pino
pino copied to clipboard
Should provide an OpenTelemetry transport
https://github.com/open-telemetry/opentelemetry-specification/blob/8e29f555b2282a3883b1b57009ad4eb11bfc5228/specification/logs/data-model.md
Just a note. Currently I'm extracting the traceId in the pino-http
customProps
function: https://github.com/pinojs/pino-http/blob/0c778530cecac64ca80ae4e88624c55c942413b9/logger.js#L122
Having the traceId is enough in most cases, as that's the entrypoint of retrieving a trace in jaeger/loki.
Not sure this issue belongs into pino itself. Retrieving a trace might have too much overhead.
module.exports = pinoHttp({
// ...,
reqCustomProps (req) {
return {traceId: req.traceId}
}
})
Together with
registerInstrumentations({
instrumentations: [
new DnsInstrumentation(),
new ExpressInstrumentation(),
new GrpcInstrumentation(),
new HttpInstrumentation({
requestHook (span, req) {
req.traceId = span?.spanContext().traceId
}
}),
new IORedisInstrumentation(),
new PgInstrumentation({enhancedDatabaseReporting: true})
],
meterProvider: metrics.meterProvider,
tracerProvider: tracing.tracerProvider
})
The idea would be to receive a standard Pino generated NDJSON line and mutate it to the format described in the linked OT documentation. Adding trace/span ids is out of scope.
Hi! I will take a look on this!
@jhonrocha any news?
Sorry, guys, I couldn't work on this yet.
I am working on this.
@jsumners could you please take a look if my PR solves the issue?
@mcollina would you like to bring this into the org?
@jsumners The PR has been reviewed and the OpenTelemetry transport for Pino is now available on npm: https://www.npmjs.com/package/pino-opentelemetry-transport .
What else is needed to close this issue?
Should I submit a PR to add this transport to the list of transports in Pino docs?
Sure, send a PR!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.