diff --git a/crates/weaver_semconv/README.md b/crates/weaver_semconv/README.md index 6a8f26ea..8c706c3f 100644 --- a/crates/weaver_semconv/README.md +++ b/crates/weaver_semconv/README.md @@ -9,3 +9,6 @@ methods to resolve references between different semconv catalogs. See [semantic convention YAML language](https://github.com/open-telemetry/build-tools/blob/main/semantic-conventions/syntax.md) for more details on the syntax. +See [build-tools JSON schema](https://github.com/open-telemetry/build-tools/blob/main/semantic-conventions/semconv.schema.json) for +formal definition of the allowed syntax. + diff --git a/crates/weaver_semconv/src/lib.rs b/crates/weaver_semconv/src/lib.rs index d54e7b38..67380788 100644 --- a/crates/weaver_semconv/src/lib.rs +++ b/crates/weaver_semconv/src/lib.rs @@ -778,6 +778,7 @@ mod tests { /// Load multiple semantic convention files in the semantic convention registry. /// No error should be emitted. + /// Spot check one or two pieces of loaded data. #[test] fn test_load_catalog() { let yaml_files = vec![ @@ -813,6 +814,23 @@ mod tests { let result = catalog.load_from_file(yaml); assert!(result.is_ok(), "{:#?}", result.err().unwrap()); } + + // Now let's resolve attributes and check provenance and structure is what we expect. + let _ = catalog.resolve(ResolverConfig::with_keep_specs()).unwrap(); + assert_eq!(catalog.attribute_with_provenance("server.address").unwrap().provenance, "data/server.yaml"); + let server_address = catalog.attribute("server.address").unwrap(); + assert_eq!(server_address.brief(), "Server address - domain name if available without reverse DNS lookup, otherwise IP address or Unix domain socket name."); + assert_eq!(server_address.is_required(), false); + assert_eq!(server_address.tag(), None); + if let AttributeSpec::Id { + r#type, .. + } = server_address { + assert_eq!(format!("{}", r#type), "string"); + } else { + panic!("Expected real AttributeSpec, not reference"); + } + // Assert that we read things correctly and keep provenance. + assert_eq!(catalog.metric_with_provenance("http.client.request.duration").unwrap().provenance, "data/http-metrics.yaml"); } /// Test the resolver with a semantic convention semantic convention registry that contains