@@ -6,9 +6,9 @@ use std::{
66 time:: SystemTime ,
77} ;
88
9- use opentelemetry:: KeyValue ;
10-
119use crate :: metrics:: { data:: Aggregation , Temporality } ;
10+ use opentelemetry:: time:: now;
11+ use opentelemetry:: KeyValue ;
1212
1313use super :: {
1414 exponential_histogram:: ExpoHistogram , histogram:: Histogram , last_value:: LastValue ,
@@ -71,7 +71,7 @@ pub(crate) struct AggregateTimeInitiator(Mutex<SystemTime>);
7171
7272impl AggregateTimeInitiator {
7373 pub ( crate ) fn delta ( & self ) -> AggregateTime {
74- let current_time = SystemTime :: now ( ) ;
74+ let current_time = now ( ) ;
7575 let start_time = self
7676 . 0
7777 . lock ( )
@@ -84,7 +84,7 @@ impl AggregateTimeInitiator {
8484 }
8585
8686 pub ( crate ) fn cumulative ( & self ) -> AggregateTime {
87- let current_time = SystemTime :: now ( ) ;
87+ let current_time = now ( ) ;
8888 let start_time = self . 0 . lock ( ) . map ( |start| * start) . unwrap_or ( current_time) ;
8989 AggregateTime {
9090 start : start_time,
@@ -95,7 +95,7 @@ impl AggregateTimeInitiator {
9595
9696impl Default for AggregateTimeInitiator {
9797 fn default ( ) -> Self {
98- Self ( Mutex :: new ( SystemTime :: now ( ) ) )
98+ Self ( Mutex :: new ( now ( ) ) )
9999 }
100100}
101101
@@ -203,7 +203,7 @@ mod tests {
203203 ExponentialBucket , ExponentialHistogram , ExponentialHistogramDataPoint , Gauge ,
204204 GaugeDataPoint , Histogram , HistogramDataPoint , Sum , SumDataPoint ,
205205 } ;
206- use std:: { time :: SystemTime , vec} ;
206+ use std:: vec;
207207
208208 use super :: * ;
209209
@@ -217,8 +217,8 @@ mod tests {
217217 value: 1u64 ,
218218 exemplars: vec![ ] ,
219219 } ] ,
220- start_time : Some ( SystemTime :: now ( ) ) ,
221- time : SystemTime :: now ( ) ,
220+ start_time : Some ( now ( ) ) ,
221+ time : now ( ) ,
222222 } ;
223223 let new_attributes = [ KeyValue :: new ( "b" , 2 ) ] ;
224224 measure. call ( 2 , & new_attributes[ ..] ) ;
@@ -250,8 +250,8 @@ mod tests {
250250 exemplars: vec![ ] ,
251251 } ,
252252 ] ,
253- start_time : SystemTime :: now ( ) ,
254- time : SystemTime :: now ( ) ,
253+ start_time : now ( ) ,
254+ time : now ( ) ,
255255 temporality : if temporality == Temporality :: Delta {
256256 Temporality :: Cumulative
257257 } else {
@@ -292,8 +292,8 @@ mod tests {
292292 exemplars: vec![ ] ,
293293 } ,
294294 ] ,
295- start_time : SystemTime :: now ( ) ,
296- time : SystemTime :: now ( ) ,
295+ start_time : now ( ) ,
296+ time : now ( ) ,
297297 temporality : if temporality == Temporality :: Delta {
298298 Temporality :: Cumulative
299299 } else {
@@ -332,8 +332,8 @@ mod tests {
332332 sum: 3u64 ,
333333 exemplars: vec![ ] ,
334334 } ] ,
335- start_time : SystemTime :: now ( ) ,
336- time : SystemTime :: now ( ) ,
335+ start_time : now ( ) ,
336+ time : now ( ) ,
337337 temporality : if temporality == Temporality :: Delta {
338338 Temporality :: Cumulative
339339 } else {
@@ -384,8 +384,8 @@ mod tests {
384384 zero_threshold: 1.0 ,
385385 exemplars: vec![ ] ,
386386 } ] ,
387- start_time : SystemTime :: now ( ) ,
388- time : SystemTime :: now ( ) ,
387+ start_time : now ( ) ,
388+ time : now ( ) ,
389389 temporality : if temporality == Temporality :: Delta {
390390 Temporality :: Cumulative
391391 } else {
0 commit comments