@@ -84,91 +84,39 @@ impl InstrumentKind {
8484/// let view = new_view(criteria, mask);
8585/// # drop(view);
8686/// ```
87- #[ derive( Clone , Default , Debug , PartialEq ) ]
88- #[ non_exhaustive]
87+ #[ derive( Clone , Debug , PartialEq ) ]
8988pub struct Instrument {
9089 /// The human-readable identifier of the instrument.
91- pub name : Cow < ' static , str > ,
90+ pub ( crate ) name : Cow < ' static , str > ,
9291 /// describes the purpose of the instrument.
93- pub description : Cow < ' static , str > ,
92+ pub ( crate ) description : Cow < ' static , str > ,
9493 /// The functional group of the instrument.
95- pub kind : Option < InstrumentKind > ,
94+ pub ( crate ) kind : InstrumentKind ,
9695 /// Unit is the unit of measurement recorded by the instrument.
97- pub unit : Cow < ' static , str > ,
96+ pub ( crate ) unit : Cow < ' static , str > ,
9897 /// The instrumentation that created the instrument.
99- pub scope : InstrumentationScope ,
98+ pub ( crate ) scope : InstrumentationScope ,
10099}
101100
102- #[ cfg( feature = "spec_unstable_metrics_views" ) ]
103101impl Instrument {
104- /// Create a new instrument with default values
105- pub fn new ( ) -> Self {
106- Instrument :: default ( )
107- }
108-
109- /// Set the instrument name.
110- pub fn name ( mut self , name : impl Into < Cow < ' static , str > > ) -> Self {
111- self . name = name. into ( ) ;
112- self
113- }
114-
115- /// Set the instrument description.
116- pub fn description ( mut self , description : impl Into < Cow < ' static , str > > ) -> Self {
117- self . description = description. into ( ) ;
118- self
119- }
120-
121- /// Set the instrument unit.
122- pub fn unit ( mut self , unit : impl Into < Cow < ' static , str > > ) -> Self {
123- self . unit = unit. into ( ) ;
124- self
125- }
126-
127- /// Set the instrument scope.
128- pub fn scope ( mut self , scope : InstrumentationScope ) -> Self {
129- self . scope = scope;
130- self
131- }
132-
133- /// empty returns if all fields of i are their default-value.
134- pub ( crate ) fn is_empty ( & self ) -> bool {
135- self . name . is_empty ( )
136- && self . description . is_empty ( )
137- && self . kind . is_none ( )
138- && self . unit . is_empty ( )
139- && self . scope == InstrumentationScope :: default ( )
140- }
141-
142- pub ( crate ) fn matches ( & self , other : & Instrument ) -> bool {
143- self . matches_name ( other)
144- && self . matches_description ( other)
145- && self . matches_kind ( other)
146- && self . matches_unit ( other)
147- && self . matches_scope ( other)
148- }
149-
150- pub ( crate ) fn matches_name ( & self , other : & Instrument ) -> bool {
151- self . name . is_empty ( ) || self . name . as_ref ( ) == other. name . as_ref ( )
152- }
153-
154- pub ( crate ) fn matches_description ( & self , other : & Instrument ) -> bool {
155- self . description . is_empty ( ) || self . description . as_ref ( ) == other. description . as_ref ( )
102+ /// Instrument name.
103+ pub fn name ( & self ) -> & str {
104+ self . name . as_ref ( )
156105 }
157106
158- pub ( crate ) fn matches_kind ( & self , other : & Instrument ) -> bool {
159- self . kind . is_none ( ) || self . kind == other. kind
107+ /// Instrument kind.
108+ pub fn kind ( & self ) -> InstrumentKind {
109+ self . kind
160110 }
161111
162- pub ( crate ) fn matches_unit ( & self , other : & Instrument ) -> bool {
163- self . unit . is_empty ( ) || self . unit . as_ref ( ) == other. unit . as_ref ( )
112+ /// Instrument unit.
113+ pub fn unit ( & self ) -> & str {
114+ self . unit . as_ref ( )
164115 }
165116
166- pub ( crate ) fn matches_scope ( & self , other : & Instrument ) -> bool {
167- ( self . scope . name ( ) . is_empty ( ) || self . scope . name ( ) == other. scope . name ( ) )
168- && ( self . scope . version ( ) . is_none ( )
169- || self . scope . version ( ) . as_ref ( ) == other. scope . version ( ) . as_ref ( ) )
170- && ( self . scope . schema_url ( ) . is_none ( )
171- || self . scope . schema_url ( ) . as_ref ( ) == other. scope . schema_url ( ) . as_ref ( ) )
117+ /// Instrument scope.
118+ pub fn scope ( & self ) -> & InstrumentationScope {
119+ & self . scope
172120 }
173121}
174122
@@ -188,7 +136,6 @@ impl Instrument {
188136/// .unwrap();
189137/// ```
190138#[ derive( Default , Debug ) ]
191- #[ non_exhaustive]
192139pub struct StreamBuilder {
193140 name : Option < Cow < ' static , str > > ,
194141 description : Option < Cow < ' static , str > > ,
@@ -331,8 +278,6 @@ fn validate_bucket_boundaries(boundaries: &[f64]) -> Result<(), String> {
331278/// # drop(view);
332279/// ```
333280#[ derive( Default , Debug ) ]
334- #[ non_exhaustive]
335- #[ allow( unreachable_pub) ]
336281pub struct Stream {
337282 /// The human-readable identifier of the stream.
338283 pub ( crate ) name : Option < Cow < ' static , str > > ,
0 commit comments