From 96e97666379f7ab8ccd3a67221ce2e7ae8047444 Mon Sep 17 00:00:00 2001 From: Aaron Clawson Date: Wed, 5 Jun 2024 15:34:47 -0500 Subject: [PATCH] Add optional variant to requirement_level This enables weaver to parse semantic convention v1.18.0 --- crates/weaver_resolved_schema/src/catalog.rs | 1 + crates/weaver_semconv/src/attribute.rs | 3 +++ crates/weaver_semconv_gen/src/gen.rs | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/crates/weaver_resolved_schema/src/catalog.rs b/crates/weaver_resolved_schema/src/catalog.rs index 311e26c9..c2e506c9 100644 --- a/crates/weaver_resolved_schema/src/catalog.rs +++ b/crates/weaver_resolved_schema/src/catalog.rs @@ -83,6 +83,7 @@ impl Catalog { "recommended" } RequirementLevel::Basic(BasicRequirementLevelSpec::OptIn) => "opt_in", + RequirementLevel::Basic(BasicRequirementLevelSpec::Optional) => "optional", RequirementLevel::Recommended { .. } => "recommended", RequirementLevel::ConditionallyRequired { .. } => "conditionally_required", }; diff --git a/crates/weaver_semconv/src/attribute.rs b/crates/weaver_semconv/src/attribute.rs index c6fd215d..dac5a22d 100644 --- a/crates/weaver_semconv/src/attribute.rs +++ b/crates/weaver_semconv/src/attribute.rs @@ -472,6 +472,8 @@ pub enum BasicRequirementLevelSpec { Recommended, /// An opt-in requirement level. OptIn, + /// An optional requirement level. + Optional, } /// Implements a human readable display for BasicRequirementLevel. @@ -481,6 +483,7 @@ impl Display for BasicRequirementLevelSpec { BasicRequirementLevelSpec::Required => write!(f, "required"), BasicRequirementLevelSpec::Recommended => write!(f, "recommended"), BasicRequirementLevelSpec::OptIn => write!(f, "opt-in"), + BasicRequirementLevelSpec::Optional => write!(f, "optional"), } } } diff --git a/crates/weaver_semconv_gen/src/gen.rs b/crates/weaver_semconv_gen/src/gen.rs index 5b9ce38e..6b6df2e8 100644 --- a/crates/weaver_semconv_gen/src/gen.rs +++ b/crates/weaver_semconv_gen/src/gen.rs @@ -323,6 +323,9 @@ impl<'a> AttributeView<'a> { RequirementLevel::Basic(BasicRequirementLevelSpec::OptIn) => { Ok(write!(out, "`Opt-In`")?) } + RequirementLevel::Basic(BasicRequirementLevelSpec::Optional) => { + Ok(write!(out, "`Optional`")?) + } RequirementLevel::ConditionallyRequired { text } => { if text.len() > BREAK_COUNT { Ok(write!( @@ -377,6 +380,7 @@ fn sort_ordinal_for_requirement(e: &RequirementLevel) -> i32 { RequirementLevel::Recommended { .. } => 3, RequirementLevel::Basic(BasicRequirementLevelSpec::Recommended) => 3, RequirementLevel::Basic(BasicRequirementLevelSpec::OptIn) => 4, + RequirementLevel::Basic(BasicRequirementLevelSpec::Optional) => todo!(), } }