File tree Expand file tree Collapse file tree 6 files changed +23
-2
lines changed
examples/metrics-advanced Expand file tree Collapse file tree 6 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ publish = false
77
88[dependencies ]
99opentelemetry = { path = " ../../opentelemetry" , features = [" metrics" ] }
10- opentelemetry_sdk = { path = " ../../opentelemetry-sdk" , features = [" metrics " , " rt-tokio" ] }
10+ opentelemetry_sdk = { path = " ../../opentelemetry-sdk" , features = [" spec_unstable_metrics_views " , " rt-tokio" ] }
1111opentelemetry-stdout = { path = " ../../opentelemetry-stdout" , features = [" metrics" ] }
1212tokio = { workspace = true , features = [" full" ] }
1313serde_json = { workspace = true }
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ rt-tokio = ["tokio", "tokio-stream"]
5353rt-tokio-current-thread = [" tokio" , " tokio-stream" ]
5454rt-async-std = [" async-std" ]
5555internal-logs = [" tracing" ]
56+ spec_unstable_metrics_views = [" metrics" ]
5657
5758[[bench ]]
5859name = " context"
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ impl InstrumentKind {
8383/// ```
8484#[ derive( Clone , Default , Debug , PartialEq ) ]
8585#[ non_exhaustive]
86+ #[ allow( unreachable_pub) ]
8687pub struct Instrument {
8788 /// The human-readable identifier of the instrument.
8889 pub name : Cow < ' static , str > ,
@@ -96,6 +97,7 @@ pub struct Instrument {
9697 pub scope : InstrumentationScope ,
9798}
9899
100+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
99101impl Instrument {
100102 /// Create a new instrument with default values
101103 pub fn new ( ) -> Self {
@@ -185,6 +187,7 @@ impl Instrument {
185187/// ```
186188#[ derive( Default , Debug ) ]
187189#[ non_exhaustive]
190+ #[ allow( unreachable_pub) ]
188191pub struct Stream {
189192 /// The human-readable identifier of the stream.
190193 pub name : Cow < ' static , str > ,
@@ -202,6 +205,7 @@ pub struct Stream {
202205 pub allowed_attribute_keys : Option < Arc < HashSet < Key > > > ,
203206}
204207
208+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
205209impl Stream {
206210 /// Create a new stream with empty values.
207211 pub fn new ( ) -> Self {
Original file line number Diff line number Diff line change @@ -215,6 +215,7 @@ impl MeterProviderBuilder {
215215 self
216216 }
217217
218+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
218219 /// Associates a [View] with a [MeterProvider].
219220 ///
220221 /// [View]s are appended to existing ones in a [MeterProvider] if this option is
Original file line number Diff line number Diff line change @@ -56,12 +56,22 @@ pub(crate) mod view;
5656
5757pub use aggregation:: * ;
5858pub use error:: { MetricError , MetricResult } ;
59- pub use instrument:: * ;
6059pub use manual_reader:: * ;
6160pub use meter_provider:: * ;
6261pub use periodic_reader:: * ;
6362pub use pipeline:: Pipeline ;
63+
64+ pub use instrument:: InstrumentKind ;
65+
66+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
67+ pub use instrument:: * ;
68+ // #[cfg(not(feature = "spec_unstable_metrics_views"))]
69+ // pub(crate) use instrument::*;
70+
71+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
6472pub use view:: * ;
73+ // #[cfg(not(feature = "spec_unstable_metrics_views"))]
74+ // pub(crate) use view::*;
6575
6676use std:: collections:: hash_map:: DefaultHasher ;
6777use std:: collections:: HashSet ;
Original file line number Diff line number Diff line change 11use super :: instrument:: { Instrument , Stream } ;
2+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
23use crate :: metrics:: { MetricError , MetricResult } ;
4+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
35use glob:: Pattern ;
46
7+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
58fn empty_view ( _inst : & Instrument ) -> Option < Stream > {
69 None
710}
@@ -42,6 +45,7 @@ fn empty_view(_inst: &Instrument) -> Option<Stream> {
4245/// let provider = SdkMeterProvider::builder().with_view(my_view).build();
4346/// # drop(provider)
4447/// ```
48+ #[ allow( unreachable_pub) ]
4549pub trait View : Send + Sync + ' static {
4650 /// Defines how data should be collected for certain instruments.
4751 ///
@@ -65,6 +69,7 @@ impl View for Box<dyn View> {
6569 }
6670}
6771
72+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
6873/// Creates a [View] that applies the [Stream] mask for all instruments that
6974/// match criteria.
7075///
You can’t perform that action at this time.
0 commit comments