File tree Expand file tree Collapse file tree 7 files changed +25
-2
lines changed
examples/metrics-advanced Expand file tree Collapse file tree 7 files changed +25
-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 4949
5050- * * BREAKING ** : `Temporality ` enum moved from `opentelemetry_sdk :: metrics :: data :: Temporality ` to `opentelemetry_sdk :: metrics :: Temporality `.
5151
52+ - * * BREAKING ** : `Views ` are now an opt- in ONLY feature. Please include the feature `spec_unstable_metrics_views` to enable `Views `. It will be stabilized post 1. 0 stable release of the SDK . [#2295](https: // github.com/open-telemetry/opentelemetry-rust/issues/2295)
53+
5254- Added a new `PeriodicReader ` implementation (`PeriodicReaderWithOwnThread `)
5355 that does not rely on an async runtime, and instead creates own Thread . This
5456 is under feature flag "experimental_metrics_periodic_reader_no_runtime". The
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ rt-tokio-current-thread = ["tokio", "tokio-stream"]
5454rt-async-std = [" async-std" ]
5555internal-logs = [" tracing" ]
5656experimental_metrics_periodic_reader_no_runtime = [" metrics" ]
57+ spec_unstable_metrics_views = [" metrics" ]
5758
5859[[bench ]]
5960name = " 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 @@ -58,14 +58,24 @@ pub(crate) mod view;
5858
5959pub use aggregation:: * ;
6060pub use error:: { MetricError , MetricResult } ;
61- pub use instrument:: * ;
6261pub use manual_reader:: * ;
6362pub use meter_provider:: * ;
6463pub use periodic_reader:: * ;
6564#[ cfg( feature = "experimental_metrics_periodic_reader_no_runtime" ) ]
6665pub use periodic_reader_with_own_thread:: * ;
6766pub use pipeline:: Pipeline ;
67+
68+ pub use instrument:: InstrumentKind ;
69+
70+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
71+ pub use instrument:: * ;
72+ // #[cfg(not(feature = "spec_unstable_metrics_views"))]
73+ // pub(crate) use instrument::*;
74+
75+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
6876pub use view:: * ;
77+ // #[cfg(not(feature = "spec_unstable_metrics_views"))]
78+ // pub(crate) use view::*;
6979
7080use std:: collections:: hash_map:: DefaultHasher ;
7181use 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