File tree Expand file tree Collapse file tree
lib/vector-core/src/metrics Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -200,50 +200,6 @@ impl Controller {
200200 }
201201}
202202
203- #[ macro_export]
204- /// This macro is used to emit metrics as a `counter` while simultaneously
205- /// converting from absolute values to incremental values.
206- ///
207- /// Values that do not arrive in strictly monotonically increasing order are
208- /// ignored and will not be emitted.
209- macro_rules! update_counter {
210- ( $label: literal, $value: expr) => { {
211- use :: std:: sync:: atomic:: { AtomicU64 , Ordering } ;
212-
213- static PREVIOUS_VALUE : AtomicU64 = AtomicU64 :: new( 0 ) ;
214-
215- let new_value = $value;
216- let mut previous_value = PREVIOUS_VALUE . load( Ordering :: Relaxed ) ;
217-
218- loop {
219- // Either a new greater value has been emitted before this thread updated the counter
220- // or values were provided that are not in strictly monotonically increasing order.
221- // Ignore.
222- if new_value <= previous_value {
223- break ;
224- }
225-
226- match PREVIOUS_VALUE . compare_exchange_weak(
227- previous_value,
228- new_value,
229- Ordering :: SeqCst ,
230- Ordering :: Relaxed ,
231- ) {
232- // Another thread has written a new value before us. Re-enter loop.
233- Err ( value) => previous_value = value,
234- // Calculate delta to last emitted value and emit it.
235- Ok ( _) => {
236- let delta = new_value - previous_value;
237- // Albeit very unlikely, note that this sequence of deltas might be emitted in
238- // a different order than they were calculated.
239- counter!( $label) . increment( delta) ;
240- break ;
241- }
242- }
243- }
244- } } ;
245- }
246-
247203#[ cfg( test) ]
248204mod tests {
249205 use super :: * ;
You can’t perform that action at this time.
0 commit comments