]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
feat(dnsdist): Log TraceID in structured logs
authorPieter Lexis <pieter.lexis@powerdns.com>
Tue, 7 Jul 2026 12:06:08 +0000 (14:06 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Wed, 8 Jul 2026 09:40:49 +0000 (11:40 +0200)
When a traced query generates a log message, log the TraceID as well fo
easier correlation.

pdns/dnsdistdist/dnsdist-idstate.cc

index 63cac9b8b6562289240dd0874f2d79d46d009314..9844de0db423b3acc967f05654c271ed06cfd8c0 100644 (file)
@@ -163,5 +163,10 @@ std::shared_ptr<const Logr::Logger> InternalQueryState::getLogger(std::shared_pt
     parent = dnsdist::logging::getTopLogger("query-processing");
   }
   auto logger = parent->withValues("dns.question.name", Logging::Loggable(this->qname), "dns.question.type", Logging::Loggable(this->qtype), "dns.question.class", Logging::Loggable(this->qclass), "source.address", Logging::Loggable(this->origRemote), "destination.address", Logging::Loggable(this->origDest), "proto", Logging::Loggable(this->protocol), "dns.question.id", Logging::Loggable(ntohs(this->origID)), "dns.question.flags", Logging::Loggable(this->origFlags));
+#ifndef DISABLE_PROTOBUF
+  if (d_OTTracer != nullptr) {
+    logger = logger->withValues("traceID", Logging::Loggable{d_OTTracer->getTraceID().toLogString()});
+  }
+#endif
   return logger;
 }