From: Otto Moerbeek Date: Mon, 20 Oct 2025 13:08:36 +0000 (+0200) Subject: Add struct for specifying conditions for OpenTelemetry Tracing X-Git-Tag: rec-5.4.0-alpha1~103^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adf678210a46f07b4f8fb934c0c1b08c3eee0a0b;p=thirdparty%2Fpdns.git Add struct for specifying conditions for OpenTelemetry Tracing Signed-off-by: Otto Moerbeek --- diff --git a/pdns/recursordist/rec-rust-lib/generate.py b/pdns/recursordist/rec-rust-lib/generate.py index 902c344fd6..56106401a3 100644 --- a/pdns/recursordist/rec-rust-lib/generate.py +++ b/pdns/recursordist/rec-rust-lib/generate.py @@ -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): diff --git a/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs b/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs index b1e8a2214b..d3d5b1341d 100644 --- a/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs +++ b/pdns/recursordist/rec-rust-lib/rust-bridge-in.rs @@ -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, + #[serde(default, skip_serializing_if = "crate::is_default")] + qnames: Vec, + #[serde(default, skip_serializing_if = "crate::is_default")] + qtypes: Vec, + #[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 { diff --git a/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs b/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs index 95b8b43a56..cf8cb5e3aa 100644 --- a/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs +++ b/pdns/recursordist/rec-rust-lib/rust/src/bridge.rs @@ -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) -> Result<(), ValidationError> { validate_vec(field, vec, |field, element| element.validate(field)) diff --git a/pdns/recursordist/rec-rust-lib/table.py b/pdns/recursordist/rec-rust-lib/table.py index c4d321d154..7548ca389f 100644 --- a/pdns/recursordist/rec-rust-lib/table.py +++ b/pdns/recursordist/rec-rust-lib/table.py @@ -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'], + }, ]