]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
feat: implement ostream << operator for TraceID
authorPieter Lexis <pieter.lexis@powerdns.com>
Thu, 25 Sep 2025 15:46:33 +0000 (17:46 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Tue, 14 Oct 2025 18:34:58 +0000 (20:34 +0200)
pdns/protozero-trace.cc
pdns/protozero-trace.hh

index 06b78016b27fe8d787e75ab1bd4e883cc6cbfeca..7fdc2644a795bd6b9dcac393a0a9352fa4106562 100644 (file)
@@ -583,4 +583,9 @@ std::string SpanID::toLogString() const
   return makeHexDump(std::string(this->begin(), this->end()), "");
 }
 
+std::string TraceID::toLogString() const
+{
+  return makeHexDump(std::string(this->begin(), this->end()), "");
+}
+
 } // namespace pdns::trace
index f90d21ff85ee43bc6df61e83d0bd68cce9e88b1e..3ba88ccf042d157475f5d83ad1a0e692c1ce1c13 100644 (file)
@@ -228,7 +228,15 @@ struct InstrumentationScope
   static InstrumentationScope decode(protozero::pbf_reader& reader);
 };
 
-using TraceID = std::array<uint8_t, 16>;
+struct TraceID : public std::array<uint8_t, 16>
+{
+  [[nodiscard]] std::string toLogString() const;
+  friend std::ostream& operator<<(std::ostream& ostrm, const TraceID& val)
+  {
+    return ostrm << val.toLogString();
+  }
+};
+
 struct SpanID : public std::array<uint8_t, 8>
 {
   [[nodiscard]] std::string toLogString() const;