]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
feat: implement ostream << operator for SpanID
authorPieter Lexis <pieter.lexis@powerdns.com>
Thu, 25 Sep 2025 15:41:08 +0000 (17:41 +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 894fd97695208d424b9b5ce26e1f3389ea555485..06b78016b27fe8d787e75ab1bd4e883cc6cbfeca 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "protozero-trace.hh"
 #include "base64.hh"
+#include "misc.hh"
 #include <string>
 #include <variant>
 
@@ -577,4 +578,9 @@ void extractOTraceIDs(const EDNSOptionViewMap& map, pdns::trace::InitialSpanInfo
   random(span.span_id);
 }
 
+std::string SpanID::toLogString() const
+{
+  return makeHexDump(std::string(this->begin(), this->end()), "");
+}
+
 } // namespace pdns::trace
index bf3617dfcb8911e8be3ba224336c0c83576c2b13..f90d21ff85ee43bc6df61e83d0bd68cce9e88b1e 100644 (file)
@@ -229,7 +229,14 @@ struct InstrumentationScope
 };
 
 using TraceID = std::array<uint8_t, 16>;
-using SpanID = std::array<uint8_t, 8>;
+struct SpanID : public std::array<uint8_t, 8>
+{
+  [[nodiscard]] std::string toLogString() const;
+  friend std::ostream& operator<<(std::ostream& ostrm, const SpanID& val)
+  {
+    return ostrm << val.toLogString();
+  }
+};
 
 constexpr TraceID s_emptyTraceID = {};