@@ -28,6 +28,17 @@ pub trait MeterProvider: fmt::Debug {
2828
2929/// Meter is the OpenTelemetry metric API, based on a sdk-defined `MeterCore`
3030/// implementation and the `Meter` library name.
31+ ///
32+ /// # Instruments
33+ ///
34+ /// | **Name** | Instrument kind | Function(argument) | Default aggregation | Notes |
35+ /// | ----------------------- | ----- | --------- | ------------- | --- |
36+ /// | **Counter** | Synchronous adding monotonic | Add(increment) | Sum | Per-request, part of a monotonic sum |
37+ /// | **UpDownCounter** | Synchronous adding | Add(increment) | Sum | Per-request, part of a non-monotonic sum |
38+ /// | **ValueRecorder** | Synchronous | Record(value) | [TBD issue 636](https://github.com/open-telemetry/opentelemetry-specification/issues/636) | Per-request, any grouping measurement |
39+ /// | **SumObserver** | Asynchronous adding monotonic | Observe(sum) | Sum | Per-interval, reporting a monotonic sum |
40+ /// | **UpDownSumObserver** | Asynchronous adding | Observe(sum) | Sum | Per-interval, reporting a non-monotonic sum |
41+ /// | **ValueObserver** | Asynchronous | Observe(value) | LastValue | Per-interval, any grouping measurement |
3142#[ derive( Debug ) ]
3243pub struct Meter {
3344 instrumentation_library : InstrumentationLibrary ,
@@ -50,125 +61,98 @@ impl Meter {
5061 }
5162 }
5263
53- #[ deprecated( note = "use instrumentation_library() instead" ) ]
54- #[ allow( dead_code) ]
55- pub ( crate ) fn instrumentation_name ( & self ) -> & str {
56- self . instrumentation_library . name
57- }
58-
5964 pub ( crate ) fn instrumentation_library ( & self ) -> InstrumentationLibrary {
6065 self . instrumentation_library
6166 }
6267
63- /// Creates a new floating point `CounterBuilder` for `f64` values with the given name.
64- pub fn f64_counter < T > ( & self , name : T ) -> CounterBuilder < ' _ , f64 >
65- where
66- T : Into < String > ,
67- {
68- CounterBuilder :: new ( self , name. into ( ) , NumberKind :: F64 )
69- }
70-
71- /// Creates a new floating point `UpDownCounterBuilder` for an `f64` up down counter with the given name.
72- pub fn f64_up_down_counter < T > ( & self , name : T ) -> UpDownCounterBuilder < ' _ , f64 >
68+ /// Creates a new integer `CounterBuilder` for `u64` values with the given name.
69+ pub fn u64_counter < T > ( & self , name : T ) -> CounterBuilder < ' _ , u64 >
7370 where
7471 T : Into < String > ,
7572 {
76- UpDownCounterBuilder :: new ( self , name. into ( ) , NumberKind :: F64 )
73+ CounterBuilder :: new ( self , name. into ( ) , NumberKind :: U64 )
7774 }
7875
79- /// Creates a new floating point `ValueRecorderBuilder ` for `f64` values with the given name.
80- pub fn f64_value_recorder < T > ( & self , name : T ) -> ValueRecorderBuilder < ' _ , f64 >
76+ /// Creates a new floating point `CounterBuilder ` for `f64` values with the given name.
77+ pub fn f64_counter < T > ( & self , name : T ) -> CounterBuilder < ' _ , f64 >
8178 where
8279 T : Into < String > ,
8380 {
84- ValueRecorderBuilder :: new ( self , name. into ( ) , NumberKind :: F64 )
81+ CounterBuilder :: new ( self , name. into ( ) , NumberKind :: F64 )
8582 }
8683
87- /// Creates a new floating point `SumObserverBuilder ` for `f64` values with the given name and callback .
88- pub fn f64_sum_observer < T , F > ( & self , name : T , callback : F ) -> SumObserverBuilder < ' _ , f64 >
84+ /// Creates a new integer `UpDownCounterBuilder ` for an `i64` up down counter with the given name.
85+ pub fn i64_up_down_counter < T > ( & self , name : T ) -> UpDownCounterBuilder < ' _ , i64 >
8986 where
9087 T : Into < String > ,
91- F : Fn ( ObserverResult < f64 > ) + Send + Sync + ' static ,
9288 {
93- SumObserverBuilder :: new (
94- self ,
95- name. into ( ) ,
96- Some ( AsyncRunner :: F64 ( Box :: new ( callback) ) ) ,
97- NumberKind :: F64 ,
98- )
89+ UpDownCounterBuilder :: new ( self , name. into ( ) , NumberKind :: I64 )
9990 }
10091
101- /// Creates a new floating point `UpDownSumObserverBuilder` for `f64` values with the given name and callback.
102- pub fn f64_up_down_sum_observer < T , F > (
103- & self ,
104- name : T ,
105- callback : F ,
106- ) -> UpDownSumObserverBuilder < ' _ , f64 >
92+ /// Creates a new floating point `UpDownCounterBuilder` for an `f64` up down counter with the given name.
93+ pub fn f64_up_down_counter < T > ( & self , name : T ) -> UpDownCounterBuilder < ' _ , f64 >
10794 where
10895 T : Into < String > ,
109- F : Fn ( ObserverResult < f64 > ) + Send + Sync + ' static ,
11096 {
111- UpDownSumObserverBuilder :: new (
112- self ,
113- name. into ( ) ,
114- Some ( AsyncRunner :: F64 ( Box :: new ( callback) ) ) ,
115- NumberKind :: F64 ,
116- )
97+ UpDownCounterBuilder :: new ( self , name. into ( ) , NumberKind :: F64 )
11798 }
11899
119- /// Creates a new floating point `ValueObserverBuilder ` for `f64 ` values with the given name and callback .
120- pub fn f64_value_observer < T , F > ( & self , name : T , callback : F ) -> ValueObserverBuilder < ' _ , f64 >
100+ /// Creates a new `ValueRecorderBuilder ` for `i64 ` values with the given name.
101+ pub fn i64_value_recorder < T > ( & self , name : T ) -> ValueRecorderBuilder < ' _ , i64 >
121102 where
122103 T : Into < String > ,
123- F : Fn ( ObserverResult < f64 > ) + Send + Sync + ' static ,
124104 {
125- ValueObserverBuilder :: new (
126- self ,
127- name. into ( ) ,
128- Some ( AsyncRunner :: F64 ( Box :: new ( callback) ) ) ,
129- NumberKind :: F64 ,
130- )
105+ ValueRecorderBuilder :: new ( self , name. into ( ) , NumberKind :: I64 )
131106 }
132107
133- /// Creates a new integer `CounterBuilder ` for `i64 ` values with the given name.
134- pub fn i64_counter < T > ( & self , name : T ) -> CounterBuilder < ' _ , i64 >
108+ /// Creates a new `ValueRecorderBuilder ` for `u64 ` values with the given name.
109+ pub fn u64_value_recorder < T > ( & self , name : T ) -> ValueRecorderBuilder < ' _ , u64 >
135110 where
136111 T : Into < String > ,
137112 {
138- CounterBuilder :: new ( self , name. into ( ) , NumberKind :: I64 )
113+ ValueRecorderBuilder :: new ( self , name. into ( ) , NumberKind :: U64 )
139114 }
140115
141- /// Creates a new integer `UpDownCounterBuilder ` for an `i64` up down counter with the given name.
142- pub fn i64_up_down_counter < T > ( & self , name : T ) -> UpDownCounterBuilder < ' _ , i64 >
116+ /// Creates a new `ValueRecorderBuilder ` for `f64` values with the given name.
117+ pub fn f64_value_recorder < T > ( & self , name : T ) -> ValueRecorderBuilder < ' _ , f64 >
143118 where
144119 T : Into < String > ,
145120 {
146- UpDownCounterBuilder :: new ( self , name. into ( ) , NumberKind :: I64 )
121+ ValueRecorderBuilder :: new ( self , name. into ( ) , NumberKind :: F64 )
147122 }
148123
149- /// Creates a new integer `ValueRecorderBuilder` for `i64` values with the given name.
150- pub fn i64_value_recorder < T > ( & self , name : T ) -> ValueRecorderBuilder < ' _ , i64 >
124+ /// Creates a new integer `SumObserverBuilder` for `u64` values with the given
125+ /// name and callback
126+ pub fn u64_sum_observer < T , F > ( & self , name : T , callback : F ) -> SumObserverBuilder < ' _ , u64 >
151127 where
152128 T : Into < String > ,
129+ F : Fn ( ObserverResult < u64 > ) + Send + Sync + ' static ,
153130 {
154- ValueRecorderBuilder :: new ( self , name. into ( ) , NumberKind :: I64 )
131+ SumObserverBuilder :: new (
132+ self ,
133+ name. into ( ) ,
134+ Some ( AsyncRunner :: U64 ( Box :: new ( callback) ) ) ,
135+ NumberKind :: U64 ,
136+ )
155137 }
156138
157- /// Creates a new integer `SumObserverBuilder` for `i64` values with the given name and callback.
158- pub fn i64_sum_observer < T , F > ( & self , name : T , callback : F ) -> SumObserverBuilder < ' _ , i64 >
139+ /// Creates a new floating point `SumObserverBuilder` for `f64` values with the
140+ /// given name and callback
141+ pub fn f64_sum_observer < T , F > ( & self , name : T , callback : F ) -> SumObserverBuilder < ' _ , f64 >
159142 where
160143 T : Into < String > ,
161- F : Fn ( ObserverResult < i64 > ) + Send + Sync + ' static ,
144+ F : Fn ( ObserverResult < f64 > ) + Send + Sync + ' static ,
162145 {
163146 SumObserverBuilder :: new (
164147 self ,
165148 name. into ( ) ,
166- Some ( AsyncRunner :: I64 ( Box :: new ( callback) ) ) ,
167- NumberKind :: I64 ,
149+ Some ( AsyncRunner :: F64 ( Box :: new ( callback) ) ) ,
150+ NumberKind :: F64 ,
168151 )
169152 }
170153
171- /// Creates a new integer `UpDownSumObserverBuilder` for `i64` values with the given name and callback.
154+ /// Creates a new integer `UpDownSumObserverBuilder` for `i64` values with the
155+ /// given name and callback.
172156 pub fn i64_up_down_sum_observer < T , F > (
173157 & self ,
174158 name : T ,
@@ -186,87 +170,67 @@ impl Meter {
186170 )
187171 }
188172
189- /// Creates a new integer `ValueObserverBuilder` for `i64` values with the given name and callback.
190- pub fn i64_value_observer < T , F > ( & self , name : T , callback : F ) -> ValueObserverBuilder < ' _ , i64 >
173+ /// Creates a new floating point `UpDownSumObserverBuilder` for `f64` values
174+ /// with the given name and callback
175+ pub fn f64_up_down_sum_observer < T , F > (
176+ & self ,
177+ name : T ,
178+ callback : F ,
179+ ) -> UpDownSumObserverBuilder < ' _ , f64 >
191180 where
192181 T : Into < String > ,
193- F : Fn ( ObserverResult < i64 > ) + Send + Sync + ' static ,
182+ F : Fn ( ObserverResult < f64 > ) + Send + Sync + ' static ,
194183 {
195- ValueObserverBuilder :: new (
184+ UpDownSumObserverBuilder :: new (
196185 self ,
197186 name. into ( ) ,
198- Some ( AsyncRunner :: I64 ( Box :: new ( callback) ) ) ,
199- NumberKind :: I64 ,
187+ Some ( AsyncRunner :: F64 ( Box :: new ( callback) ) ) ,
188+ NumberKind :: F64 ,
200189 )
201190 }
202191
203- /// Creates a new integer `CounterBuilder` for `u64` values with the given name.
204- pub fn u64_counter < T > ( & self , name : T ) -> CounterBuilder < ' _ , u64 >
205- where
206- T : Into < String > ,
207- {
208- CounterBuilder :: new ( self , name. into ( ) , NumberKind :: U64 )
209- }
210-
211- /// Creates a new integer `UpDownCounterBuilder` for an `u64` up down counter with the given name.
212- pub fn u64_up_down_counter < T > ( & self , name : T ) -> UpDownCounterBuilder < ' _ , u64 >
213- where
214- T : Into < String > ,
215- {
216- UpDownCounterBuilder :: new ( self , name. into ( ) , NumberKind :: U64 )
217- }
218-
219- /// Creates a new integer `ValueRecorderBuilder` for `u64` values with the given name.
220- pub fn u64_value_recorder < T > ( & self , name : T ) -> ValueRecorderBuilder < ' _ , u64 >
221- where
222- T : Into < String > ,
223- {
224- ValueRecorderBuilder :: new ( self , name. into ( ) , NumberKind :: U64 )
225- }
226-
227- /// Creates a new integer `SumObserverBuilder` for `u64` values with the given name and callback.
228- pub fn u64_sum_observer < T , F > ( & self , name : T , callback : F ) -> SumObserverBuilder < ' _ , u64 >
192+ /// Creates a new integer `ValueObserverBuilder` for `u64` values with the given
193+ /// name and callback
194+ pub fn u64_value_observer < T , F > ( & self , name : T , callback : F ) -> ValueObserverBuilder < ' _ , u64 >
229195 where
230196 T : Into < String > ,
231197 F : Fn ( ObserverResult < u64 > ) + Send + Sync + ' static ,
232198 {
233- SumObserverBuilder :: new (
199+ ValueObserverBuilder :: new (
234200 self ,
235201 name. into ( ) ,
236202 Some ( AsyncRunner :: U64 ( Box :: new ( callback) ) ) ,
237203 NumberKind :: U64 ,
238204 )
239205 }
240206
241- /// Creates a new integer `UpDownSumObserverBuilder` for `u64` values with the given name and callback.
242- pub fn u64_up_down_sum_observer < T , F > (
243- & self ,
244- name : T ,
245- callback : F ,
246- ) -> UpDownSumObserverBuilder < ' _ , u64 >
207+ /// Creates a new integer `ValueObserverBuilder` for `i64` values with the given
208+ /// name and callback
209+ pub fn i64_value_observer < T , F > ( & self , name : T , callback : F ) -> ValueObserverBuilder < ' _ , i64 >
247210 where
248211 T : Into < String > ,
249- F : Fn ( ObserverResult < u64 > ) + Send + Sync + ' static ,
212+ F : Fn ( ObserverResult < i64 > ) + Send + Sync + ' static ,
250213 {
251- UpDownSumObserverBuilder :: new (
214+ ValueObserverBuilder :: new (
252215 self ,
253216 name. into ( ) ,
254- Some ( AsyncRunner :: U64 ( Box :: new ( callback) ) ) ,
255- NumberKind :: U64 ,
217+ Some ( AsyncRunner :: I64 ( Box :: new ( callback) ) ) ,
218+ NumberKind :: I64 ,
256219 )
257220 }
258221
259- /// Creates a new integer `ValueObserverBuilder` for `u64` values with the given name and callback.
260- pub fn u64_value_observer < T , F > ( & self , name : T , callback : F ) -> ValueObserverBuilder < ' _ , u64 >
222+ /// Creates a new floating point `ValueObserverBuilder` for `f64` values with
223+ /// the given name and callback
224+ pub fn f64_value_observer < T , F > ( & self , name : T , callback : F ) -> ValueObserverBuilder < ' _ , f64 >
261225 where
262226 T : Into < String > ,
263- F : Fn ( ObserverResult < u64 > ) + Send + Sync + ' static ,
227+ F : Fn ( ObserverResult < f64 > ) + Send + Sync + ' static ,
264228 {
265229 ValueObserverBuilder :: new (
266230 self ,
267231 name. into ( ) ,
268- Some ( AsyncRunner :: U64 ( Box :: new ( callback) ) ) ,
269- NumberKind :: U64 ,
232+ Some ( AsyncRunner :: F64 ( Box :: new ( callback) ) ) ,
233+ NumberKind :: F64 ,
270234 )
271235 }
272236
0 commit comments