]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Use a optional to distinguish between "not tested" and "not enabled"
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 26 May 2026 09:44:55 +0000 (11:44 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 26 May 2026 09:44:55 +0000 (11:44 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-idstate.hh

index 0d14823b5764b07ede2d3a99e7896d948513d4d5..ec31db044609483a3d6d9fb8d4f520225efda8ef 100644 (file)
@@ -133,15 +133,16 @@ struct InternalQueryState
 #ifdef DISABLE_PROTOBUF
     return d_OTTracer;
 #else
-    if (!d_OTTracingEnabled || d_OTTracer != nullptr) {
+    if ((d_OTTracingEnabledInConfiguration && !*d_OTTracingEnabledInConfiguration) || d_OTTracer != nullptr) {
       return d_OTTracer;
     }
     if (dnsdist::configuration::getCurrentRuntimeConfiguration().d_openTelemetryTracing) {
       // OpenTelemetry tracing is enabled, but we don't have a tracer yet
+      d_OTTracingEnabledInConfiguration = true;
       d_OTTracer = pdns::trace::dnsdist::Tracer::getTracer();
     }
     else {
-      d_OTTracingEnabled = false;
+      d_OTTracingEnabledInConfiguration = false;
     }
     return d_OTTracer;
 #endif
@@ -233,6 +234,9 @@ public:
   uint16_t udpPayloadSize{0}; // Max UDP payload size from the query // 2
   uint16_t sendTraceParentToDownstreamID{0}; // Whether or not to add a TRACEPARENT EDNS option to downstreams, set to non-0 for the EDNS Option ID
   std::optional<bool> dnssecOK;
+#ifndef DISABLE_PROTOBUF
+  std::optional<bool> d_OTTracingEnabledInConfiguration; // Whether OpenTelemetry tracing is enabled in the configuration. This prevents having to check the configuration several times for the same query
+#endif /* DISABLE_PROTOBUF */                                                         //
   dnsdist::Protocol protocol; // 1
   uint8_t restartCount{0}; // 1
   bool ednsAdded{false};
@@ -245,7 +249,6 @@ public:
   bool staleCacheHit{false};
   bool tracingEnabled{false}; // Whether or not Open Telemetry tracing is enabled for this query
   bool rulesAppliedToQuery{false}; // Whether applyRulesToQuery has been called for the query, used to determine if we need to trace
-  bool d_OTTracingEnabled{true}; // Whether OpenTelemetry tracing is enabled in the configuration. This prevents having to check the configuration several times for the same query
   struct rulesAppliedToQuerySetter
   {
     rulesAppliedToQuerySetter(bool& pastProcessRules) :