@@ -564,32 +564,15 @@ fn resolve_refs(value: &mut serde_yaml::Value, schema_dir: &Path) -> Result<(),
564564 Ok ( ( ) )
565565}
566566
567- // ─── OTel Schema Resolution ─────────────────────────────────────────────────
568- //
569- // The OTel Collector schemas use a different JSON Schema dialect than the Datadog schema:
570- // - `$ref: <name>` resolves against the current file's `$defs` (local reference)
571- // - `$ref: /config/<package>.<def_name>` loads another package's `config.schema.yaml`
572- // and resolves against its `$defs` (package-qualified reference)
573- // - `allOf` merges multiple fragments into a single object
574- //
575- // These functions load the vendored OTel schemas from `schema/otel/`, resolve all references
576- // into a flat tree, strip excluded properties (`auth`, `middlewares`), convert to the Datadog
577- // schema dialect (`node_type: section` / `node_type: setting`), and patch the result into the
578- // Datadog schema's `otlp_config.receiver` subtree.
579-
580567/// Load the Datadog schema with the OTel receiver schema patched in.
581- ///
582- /// 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.
585568pub fn load_composed_schema ( datadog_schema : & Path , otel_schema_dir : & Path ) -> Result < serde_yaml:: Value , Error > {
586569 let mut datadog_schema = load_resolved_schema ( datadog_schema) ?;
587570 let otel_receiver = load_otel_receiver ( otel_schema_dir) ?;
588571 patch_receiver ( & mut datadog_schema, otel_receiver) ?;
589572 Ok ( datadog_schema)
590573}
591574
592- /// Load and fully resolve the OTel receiver schema into a Datadog-dialect subtree.
575+ /// Load and completely resolve the OTel receiver schema into a Datadog compatible subtree.
593576fn load_otel_receiver ( otel_dir : & Path ) -> Result < serde_yaml:: Value , Error > {
594577 let schema_path = otel_dir. join ( "config.schema.yaml" ) ;
595578 let doc = read_yaml ( & schema_path) ?;
@@ -634,9 +617,6 @@ fn load_otel_receiver(otel_dir: &Path) -> Result<serde_yaml::Value, Error> {
634617}
635618
636619/// Replace the `otlp_config.receiver` subtree in the Datadog schema with the resolved OTel subtree.
637- ///
638- /// If the Datadog schema does not have an `otlp_config.receiver` subtree (for example test schemas),
639- /// this is a no-op.
640620fn patch_receiver ( datadog_schema : & mut serde_yaml:: Value , otel_receiver : serde_yaml:: Value ) -> Result < ( ) , Error > {
641621 let Some ( otlp_config) = datadog_schema
642622 . get_mut ( "properties" )
@@ -654,13 +634,6 @@ fn patch_receiver(datadog_schema: &mut serde_yaml::Value, otel_receiver: serde_y
654634}
655635
656636/// Resolve OTel schema references into a flat tree.
657- ///
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
662- ///
663- /// Also strips `auth` and `middlewares` properties (excluded from the receiver keyspace).
664637fn resolve_otel_refs (
665638 value : & mut serde_yaml:: Value , otel_dir : & Path , current_defs : & serde_yaml:: Mapping ,
666639) -> Result < ( ) , Error > {
@@ -752,11 +725,6 @@ fn resolve_otel_refs(
752725}
753726
754727/// Resolve a single `$ref` target, returning the definition value and its source `$defs`.
755- ///
756- /// For local refs (`$ref: protocols`), looks up `current_defs`.
757- /// For package-qualified refs (`$ref: /config/`configgrpc`.server_config`), loads the
758- /// corresponding vendored schema file and looks up its `$defs`.
759- /// For `configopaque` refs (not vendored), returns an inline type definition.
760728fn resolve_otel_ref_target (
761729 ref_str : & str , otel_dir : & Path , current_defs : & serde_yaml:: Mapping ,
762730) -> Result < ( serde_yaml:: Value , serde_yaml:: Mapping ) , Error > {
@@ -816,10 +784,7 @@ fn resolve_otel_ref_target(
816784 }
817785}
818786
819- /// Convert an OTel schema tree to the Datadog schema dialect.
820- ///
821- /// Adds `node_type: section` to objects with `properties` and `node_type: setting` to leaves.
822- /// Removes OTel-specific extensions (`x-optional`, `x-customType`).
787+ /// Convert an OTel schema tree to the Datadog compatible schema dialect.
823788fn convert_to_datadog_dialect ( value : & mut serde_yaml:: Value ) {
824789 let Some ( map) = value. as_mapping_mut ( ) else {
825790 return ;
0 commit comments