if (resolver.d_eventTrace.enabled() && SyncRes::eventTraceEnabled(SyncRes::event_trace_to_pb)) {
pbMessage.addEvents(resolver.d_eventTrace);
}
- if (resolver.d_eventTrace.enabled() && SyncRes::eventTraceEnabled(SyncRes::event_trace_to_ot)) {
+
+ if (resolver.d_eventTrace.enabled() && resolver.d_eventTrace.getThisOTTraceEnabled() && SyncRes::eventTraceEnabled(SyncRes::event_trace_to_ot)) {
auto otTrace = pdns::trace::TracesData::boilerPlate("rec", resolver.d_eventTrace.convertToOT(resolver.d_otTrace), {
{"query.qname", {comboWriter->d_mdp.d_qname.toLogString()}},
{"query.qtype", {QType(comboWriter->d_mdp.d_qtype).toString()}},
return true;
}
-bool matchOTConditions(const std::unique_ptr<OpenTelemetryTraceConditions>& conditions, const ComboAddress& source, const DNSName& qname, QType qtype, uint16_t qid, bool edns_option_present)
+bool matchOTConditions(RecEventTrace& eventTrace, const std::unique_ptr<OpenTelemetryTraceConditions>& conditions, const ComboAddress& source, const DNSName& qname, QType qtype, uint16_t qid, bool edns_option_present)
{
if (conditions == nullptr || conditions->size() == 0) {
return false;
return false;
}
}
+ eventTrace.setThisOTTraceEnabled();
return true;
}
if (SyncRes::eventTraceEnabled(SyncRes::event_trace_to_ot)) {
bool ednsFound = pdns::trace::extractOTraceIDs(ednsOptions, otTrace);
- if (SyncRes::eventTraceEnabledOnly(SyncRes::event_trace_to_ot) && !matchOTConditions(t_OTConditions, mappedSource, qname, qtype, ntohs(headerdata->id), ednsFound)) {
+ if (!matchOTConditions(eventTrace, t_OTConditions, mappedSource, qname, qtype, ntohs(headerdata->id), ednsFound) && SyncRes::eventTraceEnabledOnly(SyncRes::event_trace_to_ot)) {
eventTrace.setEnabled(false);
}
}
RecEventTrace(const RecEventTrace& old) :
d_events(old.d_events),
d_base(old.d_base),
- d_status(old.d_status)
+ d_status(old.d_status),
+ d_OTTrace(old.d_OTTrace)
{
// An RecEventTrace object can be copied, but the original will be marked invalid.
// This is do detect (very likely) unintended modifications to the original after
RecEventTrace(RecEventTrace&& old) noexcept :
d_events(std::move(old.d_events)),
d_base(old.d_base),
- d_status(old.d_status)
+ d_status(old.d_status),
+ d_OTTrace(old.d_OTTrace)
{
// An RecEventTrace object can be moved, but the original will be marked invalid.
// This is do detect (very likely) unintended modifications to the original after
d_events = std::move(old.d_events);
d_base = old.d_base;
d_status = old.d_status;
+ d_OTTrace = old.d_OTTrace;
old.d_status = Invalid;
return *this;
}
struct timespec theTime{};
clock_gettime(CLOCK_MONOTONIC, &theTime);
d_base = theTime.tv_nsec + theTime.tv_sec * 1000000000;
+ d_OTTrace = false;
d_status = Disabled;
}
return old;
}
+ bool getThisOTTraceEnabled() const
+ {
+ return d_OTTrace;
+ }
+
+ void setThisOTTraceEnabled()
+ {
+ d_OTTrace = true;
+ }
+
// The EventScope class is used to close (add an end event) automatically upon the scope object
// going out of scope. It is also possible to manually close it, specifying a value to be registered
// at the close event. In that case the dt call will become a no-op.
Enabled
};
mutable Status d_status{Disabled};
+ bool d_OTTrace{false};
};
if (eventTrace.enabled() && SyncRes::eventTraceEnabled(SyncRes::event_trace_to_pb)) {
pbMessage.addEvents(eventTrace);
}
- if (eventTrace.enabled() && SyncRes::eventTraceEnabled(SyncRes::event_trace_to_ot)) {
+
+ if (eventTrace.enabled() && eventTrace.getThisOTTraceEnabled() && SyncRes::eventTraceEnabled(SyncRes::event_trace_to_ot)) {
auto trace = pdns::trace::TracesData::boilerPlate("rec", eventTrace.convertToOT(otTrace),
{{"query.qname", {qname.toLogString()}},
{"query.qtype", {qtype.toString()}}},
void startDoResolve(void*);
bool expectProxyProtocol(const ComboAddress& from, const ComboAddress& listenAddress);
bool matchOTConditions(const std::unique_ptr<OpenTelemetryTraceConditions>& conditions, const ComboAddress& source);
-bool matchOTConditions(const std::unique_ptr<OpenTelemetryTraceConditions>& conditions, const ComboAddress& source, const DNSName& qname, QType qtype, uint16_t qid, bool edns_option_present);
+bool matchOTConditions(RecEventTrace& eventTrace, const std::unique_ptr<OpenTelemetryTraceConditions>& conditions, const ComboAddress& source, const DNSName& qname, QType qtype, uint16_t qid, bool edns_option_present);
void finishTCPReply(std::unique_ptr<DNSComboWriter>&, bool hadError, bool updateInFlight);
void checkFastOpenSysctl(bool active, Logr::log_t);
void checkTFOconnect(Logr::log_t);
boost::optional<uint32_t> ednsVersion;
comboWriter->d_eventTrace.setEnabled(SyncRes::s_event_trace_enabled != 0);
- if (SyncRes::eventTraceEnabledOnly(SyncRes::event_trace_to_ot) && !matchOTConditions(t_OTConditions, comboWriter->d_mappedSource)) {
+ if (!matchOTConditions(t_OTConditions, comboWriter->d_mappedSource) && SyncRes::eventTraceEnabledOnly(SyncRes::event_trace_to_ot)) {
comboWriter->d_eventTrace.setEnabled(false);
}
if (SyncRes::eventTraceEnabled(SyncRes::event_trace_to_ot)) {
bool ednsFound = pdns::trace::extractOTraceIDs(ednsOptions, comboWriter->d_otTrace);
- if (SyncRes::eventTraceEnabledOnly(SyncRes::event_trace_to_ot) && !matchOTConditions(t_OTConditions, comboWriter->d_mappedSource, qname, qtype, ntohs(comboWriter->d_mdp.d_header.id), ednsFound)) {
+ if (SyncRes::eventTraceEnabledOnly(SyncRes::event_trace_to_ot) && !matchOTConditions(comboWriter->d_eventTrace, t_OTConditions, comboWriter->d_mappedSource, qname, qtype, ntohs(comboWriter->d_mdp.d_header.id), ednsFound)) {
comboWriter->d_eventTrace.setEnabled(false);
}
}