@@ -13,7 +13,9 @@ use std::fmt::{Display, Formatter};
1313use crate :: any_value:: AnyValueSpec ;
1414use crate :: attribute:: { AttributeSpec , AttributeType , PrimitiveOrArrayTypeSpec } ;
1515use crate :: deprecated:: Deprecated ;
16+ use crate :: footer:: FooterSpec ;
1617use crate :: group:: InstrumentSpec :: { Counter , Gauge , Histogram , UpDownCounter } ;
18+ use crate :: header:: HeaderSpec ;
1719use crate :: provenance:: Provenance ;
1820use crate :: semconv:: Imports ;
1921use crate :: stability:: Stability ;
@@ -109,6 +111,12 @@ pub struct GroupSpec {
109111 /// Note: only valid if type is event
110112 #[ serde( skip_serializing_if = "Option::is_none" ) ]
111113 pub body : Option < AnyValueSpec > ,
114+ /// Header for the namespace/page.
115+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
116+ pub header : Option < HeaderSpec > ,
117+ /// Footer for the namespace/page.
118+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
119+ pub footer : Option < FooterSpec > ,
112120 /// Annotations for the group.
113121 #[ serde( default ) ]
114122 #[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -137,8 +145,8 @@ impl GroupSpec {
137145 } ) ;
138146 }
139147
140- // Field stability is required for all group types except attribute group.
141- if self . r#type != GroupType :: AttributeGroup && self . stability . is_none ( ) {
148+ // Field stability is required for all group types except namespaces & attribute group.
149+ if self . r#type != GroupType :: AttributeGroup && self . r#type != GroupType :: NameSpace && self . stability . is_none ( ) {
142150 errors. push ( Error :: InvalidGroupStability {
143151 path_or_url : path_or_url. to_owned ( ) ,
144152 group_id : self . id . clone ( ) ,
@@ -159,9 +167,10 @@ impl GroupSpec {
159167 // Groups should only reference attributes once.
160168 validate_duplicate_attribute_ref ( & mut errors, & self . attributes , & self . id , path_or_url) ;
161169
162- // All types, except metric and event, must have extends or attributes or both.
170+ // All types, except namespaces, metric and event, must have extends or attributes or both.
163171 if self . r#type != GroupType :: Metric
164172 && self . r#type != GroupType :: Event
173+ && self . r#type != GroupType :: NameSpace
165174 && self . extends . is_none ( )
166175 && self . attributes . is_empty ( )
167176 {
@@ -182,6 +191,7 @@ impl GroupSpec {
182191 . to_owned ( ) ,
183192 } ) ;
184193 }
194+ // TODO: this should become a warning as span events are deprecated
185195 if !self . events . is_empty ( ) {
186196 errors. push ( Error :: InvalidGroup {
187197 path_or_url : path_or_url. to_owned ( ) ,
@@ -545,7 +555,7 @@ fn validate_any_value(
545555 }
546556}
547557
548- /// The different types of groups: `attribute_group`, `span`, `event`, `metric`, `entity`, `scope`.
558+ /// The different types of groups: `attribute_group`, `span`, `event`, `metric`, `entity`, `scope`, `namespace` .
549559///
550560/// Note: The `resource` type is no longer used and is an alias for `entity`.
551561#[ derive( Serialize , Deserialize , Debug , Eq , PartialEq , Hash , Clone , JsonSchema ) ]
@@ -572,6 +582,8 @@ pub enum GroupType {
572582 Scope ,
573583 /// Undefined group type.
574584 Undefined ,
585+ /// Namespace semantic convention.
586+ NameSpace ,
575587}
576588
577589impl Default for GroupType {
@@ -697,6 +709,8 @@ mod tests {
697709 name : None ,
698710 display_name : None ,
699711 body : None ,
712+ header : None ,
713+ footer : None ,
700714 annotations : None ,
701715 entity_associations : Vec :: new ( ) ,
702716 } ;
@@ -862,6 +876,8 @@ mod tests {
862876 name : None ,
863877 display_name : None ,
864878 body : None ,
879+ header : None ,
880+ footer : None ,
865881 annotations : None ,
866882 entity_associations : Vec :: new ( ) ,
867883 } ;
@@ -1159,6 +1175,8 @@ mod tests {
11591175 ) ,
11601176 } ,
11611177 } ) ,
1178+ header : None ,
1179+ footer : None ,
11621180 annotations : None ,
11631181 entity_associations : Vec :: new ( ) ,
11641182 } ;
@@ -1374,6 +1392,8 @@ mod tests {
13741392 ) ,
13751393 } ,
13761394 } ) ,
1395+ header : None ,
1396+ footer : None ,
13771397 annotations : None ,
13781398 entity_associations : Vec :: new ( ) ,
13791399 } ;
@@ -1518,6 +1538,8 @@ mod tests {
15181538 name : None ,
15191539 display_name : None ,
15201540 body : None ,
1541+ header : None ,
1542+ footer : None ,
15211543 annotations : None ,
15221544 entity_associations : Vec :: new ( ) ,
15231545 } ;
@@ -1688,6 +1710,8 @@ mod tests {
16881710 name : None ,
16891711 display_name : None ,
16901712 body : None ,
1713+ header : None ,
1714+ footer : None ,
16911715 annotations : None ,
16921716 entity_associations : Vec :: new ( ) ,
16931717 } ;
@@ -1840,6 +1864,8 @@ mod tests {
18401864 name : None ,
18411865 display_name : None ,
18421866 body : None ,
1867+ header : None ,
1868+ footer : None ,
18431869 annotations : None ,
18441870 entity_associations : Vec :: new ( ) ,
18451871 } ;
@@ -1900,6 +1926,8 @@ mod tests {
19001926 name : None ,
19011927 display_name : None ,
19021928 body : None ,
1929+ header : None ,
1930+ footer : None ,
19031931 annotations : None ,
19041932 entity_associations : vec ! [ "test" . to_owned( ) ] ,
19051933 } ;
@@ -1938,4 +1966,35 @@ mod tests {
19381966 result
19391967 ) ;
19401968 }
1969+
1970+ #[ test]
1971+ fn test_validate_namespace ( ) {
1972+ let mut group = GroupSpec {
1973+ id : "test" . to_owned ( ) ,
1974+ r#type : GroupType :: NameSpace ,
1975+ name : Some ( "test_namespace" . to_owned ( ) ) ,
1976+ brief : "test" . to_owned ( ) ,
1977+ note : "test" . to_owned ( ) ,
1978+ prefix : "" . to_owned ( ) ,
1979+ extends : None ,
1980+ stability : None ,
1981+ deprecated : None ,
1982+ span_kind : None ,
1983+ events : vec ! [ ] ,
1984+ metric_name : None ,
1985+ instrument : None ,
1986+ unit : None ,
1987+ display_name : None ,
1988+ attributes : vec ! [ ] ,
1989+ body : None ,
1990+ header : None ,
1991+ footer : None ,
1992+ annotations : None ,
1993+ entity_associations : Vec :: new ( ) ,
1994+ } ;
1995+ assert ! ( group
1996+ . validate( "<test>" )
1997+ . into_result_failing_non_fatal( )
1998+ . is_ok( ) ) ;
1999+ }
19412000}
0 commit comments