From: Pieter Lexis Date: Thu, 25 Sep 2025 15:41:08 +0000 (+0200) Subject: feat: implement ostream << operator for SpanID X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c4ae410f17ffc4b73c71037147cb784c27e63ff4;p=thirdparty%2Fpdns.git feat: implement ostream << operator for SpanID --- diff --git a/pdns/protozero-trace.cc b/pdns/protozero-trace.cc index 894fd97695..06b78016b2 100644 --- a/pdns/protozero-trace.cc +++ b/pdns/protozero-trace.cc @@ -22,6 +22,7 @@ #include "protozero-trace.hh" #include "base64.hh" +#include "misc.hh" #include #include @@ -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 diff --git a/pdns/protozero-trace.hh b/pdns/protozero-trace.hh index bf3617dfcb..f90d21ff85 100644 --- a/pdns/protozero-trace.hh +++ b/pdns/protozero-trace.hh @@ -229,7 +229,14 @@ struct InstrumentationScope }; using TraceID = std::array; -using SpanID = std::array; +struct SpanID : public std::array +{ + [[nodiscard]] std::string toLogString() const; + friend std::ostream& operator<<(std::ostream& ostrm, const SpanID& val) + { + return ostrm << val.toLogString(); + } +}; constexpr TraceID s_emptyTraceID = {};