pino icon indicating copy to clipboard operation
pino copied to clipboard

Should provide an OpenTelemetry transport

Open jsumners opened this issue 3 years ago • 8 comments

https://github.com/open-telemetry/opentelemetry-specification/blob/8e29f555b2282a3883b1b57009ad4eb11bfc5228/specification/logs/data-model.md

jsumners avatar Jan 06 '22 19:01 jsumners

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
    })

marcbachmann avatar Jan 06 '22 23:01 marcbachmann

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.

jsumners avatar Jan 07 '22 14:01 jsumners

Hi! I will take a look on this!

jhonrocha avatar Feb 01 '22 13:02 jhonrocha

@jhonrocha any news?

simoneb avatar Feb 18 '22 18:02 simoneb

Sorry, guys, I couldn't work on this yet.

jhonrocha avatar Feb 18 '22 19:02 jhonrocha

I am working on this.

Vunovati avatar Apr 07 '22 19:04 Vunovati

@jsumners could you please take a look if my PR solves the issue?

Vunovati avatar Apr 08 '22 12:04 Vunovati

@mcollina would you like to bring this into the org?

jsumners avatar Apr 08 '22 13:04 jsumners

@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?

Vunovati avatar Jul 27 '23 20:07 Vunovati

Sure, send a PR!

mcollina avatar Jul 28 '23 07:07 mcollina

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.

github-actions[bot] avatar Aug 28 '23 00:08 github-actions[bot]