Skip to content

Commit e161e2a

Browse files
committed
fix(otlp): change comments and add new words to allow list
1 parent f0585d0 commit e161e2a

2 files changed

Lines changed: 35 additions & 28 deletions

File tree

  • .vale/styles/config/vocabularies/technical
  • lib/datadog-agent/config-overlay-model/src

.vale/styles/config/vocabularies/technical/accept.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,10 @@ reimplemented
254254
hoc
255255
rss
256256
waker
257+
keepalive
258+
recurse
259+
recurses
260+
otlpreceiver
261+
configgrpc
262+
configtls
263+
keyspace

lib/datadog-agent/config-overlay-model/src/lib.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub enum InputShape {
260260
pub struct Files {
261261
/// The Datadog Agent core schema file (`schema/core/core_schema.yaml`).
262262
pub datadog_schema: PathBuf,
263-
/// Directory containing the vendored OTEL receiver schema (`schema/otel/`).
263+
/// Directory containing the vendored OTel receiver schema (`schema/otel/`).
264264
pub otel_schema_dir: PathBuf,
265265
/// The schema overlay (`schema/schema_overlay.yaml`).
266266
pub overlay: PathBuf,
@@ -564,48 +564,48 @@ fn resolve_refs(value: &mut serde_yaml::Value, schema_dir: &Path) -> Result<(),
564564
Ok(())
565565
}
566566

567-
// ─── OTEL Schema Resolution ─────────────────────────────────────────────────
567+
// ─── OTel Schema Resolution ─────────────────────────────────────────────────
568568
//
569-
// The OTEL Collector schemas use a different JSON Schema dialect than the Datadog schema:
569+
// The OTel Collector schemas use a different JSON Schema dialect than the Datadog schema:
570570
// - `$ref: <name>` resolves against the current file's `$defs` (local reference)
571571
// - `$ref: /config/<package>.<def_name>` loads another package's `config.schema.yaml`
572572
// and resolves against its `$defs` (package-qualified reference)
573573
// - `allOf` merges multiple fragments into a single object
574574
//
575-
// These functions load the vendored OTEL schemas from `schema/otel/`, resolve all references
575+
// These functions load the vendored OTel schemas from `schema/otel/`, resolve all references
576576
// into a flat tree, strip excluded properties (`auth`, `middlewares`), convert to the Datadog
577577
// schema dialect (`node_type: section` / `node_type: setting`), and patch the result into the
578578
// Datadog schema's `otlp_config.receiver` subtree.
579579

580-
/// Load the Datadog schema with the OTEL receiver schema patched in.
580+
/// Load the Datadog schema with the OTel receiver schema patched in.
581581
///
582582
/// This loads the pristine Datadog schema (`core_schema.yaml`), loads and resolves the pristine
583-
/// OTEL receiver schema (`otel/config.schema.yaml`), and replaces the `otlp_config.receiver`
584-
/// subtree in the Datadog schema with the resolved OTEL subtree.
583+
/// OTel receiver schema (`otel/config.schema.yaml`), and replaces the `otlp_config.receiver`
584+
/// subtree in the Datadog schema with the resolved OTel subtree.
585585
pub fn load_composed_schema(datadog_schema: &Path, otel_schema_dir: &Path) -> Result<serde_yaml::Value, Error> {
586586
let mut datadog_schema = load_resolved_schema(datadog_schema)?;
587587
let otel_receiver = load_otel_receiver(otel_schema_dir)?;
588588
patch_receiver(&mut datadog_schema, otel_receiver)?;
589589
Ok(datadog_schema)
590590
}
591591

592-
/// Load and fully resolve the OTEL receiver schema into a Datadog-dialect subtree.
592+
/// Load and fully resolve the OTel receiver schema into a Datadog-dialect subtree.
593593
fn load_otel_receiver(otel_dir: &Path) -> Result<serde_yaml::Value, Error> {
594594
let schema_path = otel_dir.join("config.schema.yaml");
595595
let doc = read_yaml(&schema_path)?;
596596

597597
let defs = doc
598598
.get("$defs")
599599
.and_then(|v| v.as_mapping())
600-
.ok_or_else(|| Error::Validation("OTEL schema missing $defs".to_string()))?
600+
.ok_or_else(|| Error::Validation("OTel schema missing $defs".to_string()))?
601601
.clone();
602602

603603
// Start from properties.protocols (the root of the receiver config).
604604
let mut protocols = doc
605605
.get("properties")
606606
.and_then(|v| v.get("protocols"))
607607
.cloned()
608-
.ok_or_else(|| Error::Validation("OTEL schema missing properties.protocols".to_string()))?;
608+
.ok_or_else(|| Error::Validation("OTel schema missing properties.protocols".to_string()))?;
609609

610610
// Resolve all $ref, $defs, and allOf.
611611
resolve_otel_refs(&mut protocols, otel_dir, &defs)?;
@@ -633,9 +633,9 @@ fn load_otel_receiver(otel_dir: &Path) -> Result<serde_yaml::Value, Error> {
633633
Ok(serde_yaml::Value::Mapping(receiver_section))
634634
}
635635

636-
/// Replace the `otlp_config.receiver` subtree in the Datadog schema with the resolved OTEL subtree.
636+
/// Replace the `otlp_config.receiver` subtree in the Datadog schema with the resolved OTel subtree.
637637
///
638-
/// If the Datadog schema does not have an `otlp_config.receiver` subtree (e.g. test schemas),
638+
/// If the Datadog schema does not have an `otlp_config.receiver` subtree (for example test schemas),
639639
/// this is a no-op.
640640
fn patch_receiver(datadog_schema: &mut serde_yaml::Value, otel_receiver: serde_yaml::Value) -> Result<(), Error> {
641641
let Some(otlp_config) = datadog_schema
@@ -653,12 +653,12 @@ fn patch_receiver(datadog_schema: &mut serde_yaml::Value, otel_receiver: serde_y
653653
Ok(())
654654
}
655655

656-
/// Resolve OTEL schema references into a flat tree.
656+
/// Resolve OTel schema references into a flat tree.
657657
///
658-
/// Handles three OTEL schema features:
659-
/// - `$ref: <name>` local lookup in the current file's `$defs`
660-
/// - `$ref: /config/<package>.<def_name>` load another package's schema file
661-
/// - `allOf` merge fragments into the parent
658+
/// Handles three OTel schema features:
659+
/// - `$ref: <name>`: local lookup in the current file's `$defs`
660+
/// - `$ref: /config/<package>.<def_name>`: load another package's schema file
661+
/// - `allOf`: merge fragments into the parent
662662
///
663663
/// Also strips `auth` and `middlewares` properties (excluded from the receiver keyspace).
664664
fn resolve_otel_refs(
@@ -668,9 +668,9 @@ fn resolve_otel_refs(
668668
return Ok(());
669669
};
670670

671-
// 1. Handle $ref replace this node with the resolved definition.
671+
// 1. Handle $ref: replace this node with the resolved definition.
672672
if let Some(ref_str) = map.get("$ref").and_then(|v| v.as_str()) {
673-
// Save sibling keys (everything except $ref) — e.g. x-optional, description.
673+
// Save sibling keys (everything except $ref): for example x-optional, description.
674674
let siblings: Vec<(serde_yaml::Value, serde_yaml::Value)> = map
675675
.iter()
676676
.filter(|(k, _)| k.as_str() != Some("$ref"))
@@ -701,7 +701,7 @@ fn resolve_otel_refs(
701701
return Ok(());
702702
}
703703

704-
// 2. Handle allOf merge each fragment's properties into this node.
704+
// 2. Handle allOf: merge each fragment's properties into this node.
705705
if let Some(allof) = map.remove("allOf") {
706706
if let Some(allof_seq) = allof.as_sequence() {
707707
for fragment in allof_seq {
@@ -741,14 +741,14 @@ fn resolve_otel_refs(
741741
/// Resolve a single `$ref` target, returning the definition value and its source `$defs`.
742742
///
743743
/// For local refs (`$ref: protocols`), looks up `current_defs`.
744-
/// For package-qualified refs (`$ref: /config/configgrpc.server_config`), loads the
744+
/// For package-qualified refs (`$ref: /config/`configgrpc`.server_config`), loads the
745745
/// corresponding vendored schema file and looks up its `$defs`.
746746
/// For `configopaque` refs (not vendored), returns an inline type definition.
747747
fn resolve_otel_ref_target(
748748
ref_str: &str, otel_dir: &Path, current_defs: &serde_yaml::Mapping,
749749
) -> Result<(serde_yaml::Value, serde_yaml::Mapping), Error> {
750750
if let Some(stripped) = ref_str.strip_prefix('/') {
751-
// Package-qualified ref: /config/configgrpc.server_config
751+
// Package-qualified ref: /config/`configgrpc`.server_config
752752
let last_dot = stripped
753753
.rfind('.')
754754
.ok_or_else(|| Error::Validation(format!("invalid package-qualified ref (no dot): {ref_str}")))?;
@@ -785,7 +785,7 @@ fn resolve_otel_ref_target(
785785
let file_defs = file_doc
786786
.get("$defs")
787787
.and_then(|v| v.as_mapping())
788-
.ok_or_else(|| Error::Validation(format!("OTEL schema {file_path:?} missing $defs")))?
788+
.ok_or_else(|| Error::Validation(format!("OTel schema {file_path:?} missing $defs")))?
789789
.clone();
790790
let def_value = file_defs
791791
.get(def_name)
@@ -803,16 +803,16 @@ fn resolve_otel_ref_target(
803803
}
804804
}
805805

806-
/// Convert an OTEL schema tree to the Datadog schema dialect.
806+
/// Convert an OTel schema tree to the Datadog schema dialect.
807807
///
808808
/// Adds `node_type: section` to objects with `properties` and `node_type: setting` to leaves.
809-
/// Removes OTEL-specific extensions (`x-optional`, `x-customType`).
809+
/// Removes OTel-specific extensions (`x-optional`, `x-customType`).
810810
fn convert_to_datadog_dialect(value: &mut serde_yaml::Value) {
811811
let Some(map) = value.as_mapping_mut() else {
812812
return;
813813
};
814814

815-
// Remove OTEL-specific extensions.
815+
// Remove OTel-specific extensions.
816816
map.remove(serde_yaml::Value::String("x-optional".to_string()));
817817
map.remove(serde_yaml::Value::String("x-customType".to_string()));
818818

@@ -882,7 +882,7 @@ impl std::error::Error for Error {
882882
mod tests {
883883
use super::*;
884884

885-
/// Returns the OTEL schema directory for tests that need the composed schema.
885+
/// Returns the OTel schema directory for tests that need the composed schema.
886886
fn otel_schema_dir_for_tests() -> PathBuf {
887887
Path::new(env!("CARGO_MANIFEST_DIR"))
888888
.join("..")
@@ -1109,7 +1109,7 @@ excluded: {}
11091109

11101110
// The per-entry validation rules (`validate_entries`) are documented in `VALIDATION_RULES` and
11111111
// enforced independently of the schema cross-check, so these tests deserialize an overlay in
1112-
// isolation (via `from_yaml`) and run only that pass no matching core schema is needed.
1112+
// isolation (via `from_yaml`) and run only that pass: no matching core schema is needed.
11131113
fn validate_entries_of(overlay: &str) -> Result<(), Error> {
11141114
SchemaOverlay::from_yaml(overlay)
11151115
.expect("overlay should deserialize")

0 commit comments

Comments
 (0)