]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add struct for specifying conditions for OpenTelemetry Tracing
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 20 Oct 2025 13:08:36 +0000 (15:08 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 10 Nov 2025 14:14:35 +0000 (15:14 +0100)
Signed-off-by: Otto Moerbeek <otto.moerbeek@open-xchange.com>
pdns/recursordist/rec-rust-lib/generate.py
pdns/recursordist/rec-rust-lib/rust-bridge-in.rs
pdns/recursordist/rec-rust-lib/rust/src/bridge.rs
pdns/recursordist/rec-rust-lib/table.py

index 902c344fd67e07e4d157f6aff221b0ef2226b1e3..56106401a31d428f22916d1dd8031bad1bcab914 100644 (file)
@@ -114,6 +114,7 @@ class LType(Enum):
     ListTrustAnchors = auto()
     ListZoneToCaches = auto()
     ListOutgoingTLSConfigurations = auto()
+    ListOpenTelemetryTraceConditions = auto()
     String = auto()
     Uint64 = auto()
 
@@ -122,7 +123,7 @@ listOfStructuredTypes = (LType.ListAuthZones, LType.ListForwardZones, LType.List
                          LType.ListProtobufServers, LType.ListDNSTapFrameStreamServers, LType.ListDNSTapNODFrameStreamServers,
                          LType.ListSortLists, LType.ListRPZs, LType.ListZoneToCaches, LType.ListAllowedAdditionalQTypes,
                          LType.ListProxyMappings, LType.ListForwardingCatalogZones, LType.ListIncomingWSConfigs,
-                         LType.ListOutgoingTLSConfigurations)
+                         LType.ListOutgoingTLSConfigurations, LType.ListOpenTelemetryTraceConditions)
 
 def get_olddoc_typename(typ):
     """Given a type from table.py, return the old-style type name"""
@@ -192,6 +193,8 @@ def get_newdoc_typename(typ):
         return 'Sequence of `IncomingWSConfig`_'
     if typ == LType.ListOutgoingTLSConfigurations:
         return 'Sequence of `OutgoingTLSConfiguration`_'
+    if typ == LType.ListOpenTelemetryTraceConditions:
+        return 'Sequence of `OpenTelemetryTraceCondition`_'
     return 'Unknown2' + str(typ)
 
 def get_default_olddoc_value(typ, val):
index b1e8a2214b7767f5a0d170ea22ecbac96fa44001..d3d5b1341df679530a0d850311ed60b0585b9f9b 100644 (file)
@@ -350,6 +350,23 @@ struct OutgoingTLSConfiguration {
     ciphers_tls_13: String,
 }
 
+#[derive(Deserialize, Serialize, Clone, Debug, PartialEq)]
+#[serde(deny_unknown_fields)]
+struct OpenTelemetryTraceCondition {
+    #[serde(default, skip_serializing_if = "crate::is_default")]
+    acls: Vec<String>,
+    #[serde(default, skip_serializing_if = "crate::is_default")]
+    qnames: Vec<String>,
+    #[serde(default, skip_serializing_if = "crate::is_default")]
+    qtypes: Vec<String>,
+    #[serde(default = "crate::U32::<{u32::MAX}>::value", skip_serializing_if = "crate::U32::<{u32::MAX}>::is_equal")]
+    qid: u32,
+    #[serde(default, skip_serializing_if = "crate::is_default")]
+    edns_option_required: bool,
+    #[serde(default, skip_serializing_if = "crate::is_default")]
+    traceid_only: bool,
+}
+
 // Two structs used to generated YAML based on a vector of name to value mappings
 // Cannot use Enum as CXX has only very basic Enum support
 struct Value {
index 95b8b43a5604ed535ea51d62fbc210c02c84c0da..cf8cb5e3aa658ad956b599886f0148b4b5a84407 100644 (file)
@@ -793,6 +793,31 @@ impl OutgoingTLSConfiguration {
     }
 }
 
+impl OpenTelemetryTraceCondition {
+    pub fn validate(&self, field: &str) -> Result<(), ValidationError> {
+        validate_vec(
+            &(field.to_string() + ".acls"),
+            &self.acls,
+            validate_subnet,
+        )?;
+        validate_vec(
+            &(field.to_string() + ".qnames"),
+            &self.qnames,
+            validate_name,
+        )?;
+        validate_vec(
+            &(field.to_string() + ".qtypes"),
+            &self.qtypes,
+            validate_qtype,
+        )?;
+        if self.qid != u32::MAX && self.qid > u16::MAX.into() {
+            let msg = format!("{}.qid: must be between 0 and 2^16", field);
+            return Err(ValidationError { msg });
+        }
+        Ok(())
+    }
+}
+
 #[allow(clippy::ptr_arg)] //# Avoids creating a rust::Slice object on the C++ side.
 pub fn validate_auth_zones(field: &str, vec: &Vec<AuthZone>) -> Result<(), ValidationError> {
     validate_vec(field, vec, |field, element| element.validate(field))
index c4d321d1541c587d3f75a70949ce748d13406cfc..7548ca389f61d9a879395929d984d1164a9c41da 100644 (file)
@@ -3573,4 +3573,17 @@ A DoT connection is matched against the subnets lists (using the remote IP) and
         'versionadded': '5.4.0',
         'runtime': ['reload-lua-config', 'reload-yaml'],
     },
+    {
+        'name' : 'opentelemetry_trace_conditions',
+        'section' : 'logging',
+        'type' : LType.ListOpenTelemetryTraceConditions,
+        'default' : '',
+        'help' : 'Sequence of OpenTelemetryTraceCondition',
+        'doc' : '''
+        XXX
+        ''',
+        'skip-old' : 'No equivalent old style setting',
+        'versionadded': '5.4.0',
+        'runtime': ['reload-lua-config', 'reload-yaml'],
+    },
 ]