Logs with Pino not showing in Datadog APM trace logs

Viewed 172

I'm having trouble getting Pino logs to show up in Datadog APM traces, even though, it would appear that the log injection is working fine.

So I have dd-trace all running fine, and traces and spans appearing perfectly in APM. I then hook up Pino, I have all env vars set correctly and when my Pino log outputs I can see the trace_id and span_id in the log... but under Logs in APM I see nothing.

My Pino log looks like this:

{
  "level":30,
  "time":1658480164226,
  "pid":20400,
  "hostname":"local",
  "dd":{
    "trace_id":"1314152611599688171",
    "span_id":"6560268894829180062",
    "service":"datadog-sandbox",
    "version":"development",
    "env":"development"
  },
  "foo":"bar",
  "msg":"How am I doing?"
}

As you can see, the trace_id and span_id have been injected in to the log. But when I look at this trace and span in APM I see no logs connected at all:

APM Trace

Am I missing some configuration here? I'm happy to supply any other code if that helps.

Thanks

1 Answers

dd-trace is just injecting the tracing context into the logs in order to correlate between traces and logs. It does not send the logs anywhere on its own.

Logs sending can be achieved by Datadog Agent or directly via HTTP. I was able to make it work with Agentless logging

Related