return value;
}
-void extractOTraceIDs(const EDNSOptionViewMap& map, pdns::trace::Span& span)
+void extractOTraceIDs(const EDNSOptionViewMap& map, pdns::trace::InitialSpanInfo& span)
{
// traceid gets set from edns options (if available and well-formed), otherwise random
// parent_span_id gets set from edns options (if available and well-formed, otherwise it remains cleared (no parent))
return (1000000000ULL * now.tv_sec) + now.tv_nsec;
}
+// This struct is used to store the info of the initial span. As it is passed around resolving
+// queries, it needs to be as small as possible, hence no full Span.
+struct InitialSpanInfo
+{
+ TraceID trace_id{};
+ SpanID span_id{};
+ SpanID parent_span_id{};
+ uint64_t start_time_unix_nano{0};
+
+ void clear()
+ {
+ pdns::trace::clear(trace_id);
+ pdns::trace::clear(span_id);
+ pdns::trace::clear(parent_span_id);
+ start_time_unix_nano = 0;
+ }
+};
+
struct Span
{
// A unique identifier for a trace. All spans from the same trace share
return pdns::trace::decode<KeyValueList, KeyValue>(reader);
}
-void extractOTraceIDs(const EDNSOptionViewMap& map, pdns::trace::Span& span);
+void extractOTraceIDs(const EDNSOptionViewMap& map, pdns::trace::InitialSpanInfo& span);
} // namespace pdns::trace
pbMessage.addEvents(resolver.d_eventTrace);
}
if (resolver.d_eventTrace.enabled() && SyncRes::eventTraceEnabled(SyncRes::event_trace_to_ot)) {
- resolver.d_otTrace.close();
auto otTrace = pdns::trace::TracesData::boilerPlate("rec", comboWriter->d_mdp.d_qname.toLogString() + '/' + QType(comboWriter->d_mdp.d_qtype).toString(), resolver.d_eventTrace.convertToOT(resolver.d_otTrace));
string otData = otTrace.encode();
pbMessage.setOpenTelemetryData(otData);
// source: the address we assume the query is coming from, might be set by proxy protocol
// destination: the address we assume the query was sent to, might be set by proxy protocol
// mappedSource: the address we assume the query is coming from. Differs from source if table based mapping has been applied
-static string* doProcessUDPQuestion(const std::string& question, const ComboAddress& fromaddr, const ComboAddress& destaddr, ComboAddress source, ComboAddress destination, const ComboAddress& mappedSource, struct timeval tval, int fileDesc, std::vector<ProxyProtocolValue>& proxyProtocolValues, RecEventTrace& eventTrace, pdns::trace::Span& otTrace) // NOLINT(readability-function-cognitive-complexity): https://github.com/PowerDNS/pdns/issues/12791
+static string* doProcessUDPQuestion(const std::string& question, const ComboAddress& fromaddr, const ComboAddress& destaddr, ComboAddress source, ComboAddress destination, const ComboAddress& mappedSource, struct timeval tval, int fileDesc, std::vector<ProxyProtocolValue>& proxyProtocolValues, RecEventTrace& eventTrace, pdns::trace::InitialSpanInfo& otTrace) // NOLINT(readability-function-cognitive-complexity): https://github.com/PowerDNS/pdns/issues/12791
{
RecThreadInfo::self().incNumberOfDistributedQueries();
gettimeofday(&g_now, nullptr);
bool firstQuery = true;
std::vector<ProxyProtocolValue> proxyProtocolValues;
RecEventTrace eventTrace;
- pdns::trace::Span otTrace;
+ pdns::trace::InitialSpanInfo otTrace;
for (size_t queriesCounter = 0; queriesCounter < g_maxUDPQueriesPerRound; queriesCounter++) {
bool proxyProto = false;
if (SyncRes::eventTraceEnabled(SyncRes::event_trace_to_ot)) {
otTrace.clear();
otTrace.start_time_unix_nano = traceTS;
- otTrace.name = "RecRequest";
}
firstQuery = false;
// The event trace uses start-stop records which need to be mapped to OpenTelemetry Spans, which is a
// list of spans. Spans can refer to other spans as their parent.
-std::vector<pdns::trace::Span> RecEventTrace::convertToOT(const Span& span) const
+std::vector<pdns::trace::Span> RecEventTrace::convertToOT(const InitialSpanInfo& span) const
{
timespec realtime{};
clock_gettime(CLOCK_REALTIME, &realtime);
ret.reserve((d_events.size() / 2) + 1);
// The parent of all Spans
- ret.emplace_back(span);
+ ret.emplace_back(Span{.trace_id = span.trace_id, .span_id = span.span_id, .parent_span_id = span.parent_span_id, .end_time_unix_nano = timestamp()});
std::vector<SpanID> spanIDs; // mapping of span index in ret vector to SpanID
std::map<size_t, size_t> ids; // mapping from event record index to index in ret vector (Spans)
return d_events;
}
- std::vector<pdns::trace::Span> convertToOT(const pdns::trace::Span& span) const;
+ std::vector<pdns::trace::Span> convertToOT(const pdns::trace::InitialSpanInfo& span) const;
size_t setParent(size_t parent)
{
const boost::uuids::uuid& uniqueId, const string& requestorId, const string& deviceId,
const string& deviceName, const std::map<std::string, RecursorLua4::MetaValue>& meta,
const RecEventTrace& eventTrace,
- pdns::trace::Span& otTrace,
+ pdns::trace::InitialSpanInfo& otTrace,
const std::unordered_set<std::string>& policyTags)
{
pdns::ProtoZero::RecMessage pbMessage(pbData ? pbData->d_message : "", pbData ? pbData->d_response : "", 64, 10); // The extra bytes we are going to add
pbMessage.addEvents(eventTrace);
}
if (eventTrace.enabled() && (SyncRes::s_event_trace_enabled & SyncRes::event_trace_to_ot) != 0) {
- otTrace.close();
auto trace = pdns::trace::TracesData::boilerPlate("rec", qname.toLogString() + '/' + qtype.toString(), eventTrace.convertToOT(otTrace));
pbMessage.setOpenTelemetryData(trace.encode());
}
ComboAddress d_destination; // the address we assume the query is sent to, might be set by proxy protocol
ComboAddress d_mappedSource; // the source address after being mapped by table based proxy mapping
RecEventTrace d_eventTrace;
- pdns::trace::Span d_otTrace;
+ pdns::trace::InitialSpanInfo d_otTrace;
boost::uuids::uuid d_uuid;
string d_requestorId;
string d_deviceId;
const boost::uuids::uuid& uniqueId, const string& requestorId, const string& deviceId,
const string& deviceName, const std::map<std::string, RecursorLua4::MetaValue>& meta,
const RecEventTrace& eventTrace,
- pdns::trace::Span& otTrace,
+ pdns::trace::InitialSpanInfo& otTrace,
const std::unordered_set<std::string>& policyTags);
void requestWipeCaches(const DNSName& canon);
void startDoResolve(void*);
if (SyncRes::eventTraceEnabled(SyncRes::event_trace_to_ot)) {
comboWriter->d_otTrace.clear();
comboWriter->d_otTrace.start_time_unix_nano = traceTS;
- comboWriter->d_otTrace.name = "RecRequest";
+ //comboWriter->d_otTrace.name = "RecRequest";
}
auto luaconfsLocal = g_luaconfs.getLocal();
if (checkProtobufExport(luaconfsLocal)) {
boost::optional<string> d_routingTag;
ComboAddress d_fromAuthIP;
RecEventTrace d_eventTrace;
- pdns::trace::Span d_otTrace;
+ pdns::trace::InitialSpanInfo d_otTrace;
std::shared_ptr<Logr::Logger> d_slog = g_slog->withName("syncres");
boost::optional<EDNSExtendedError> d_extendedError;