@@ -9,6 +9,9 @@ use sentry_types::protocol::latest::{Envelope, EnvelopeItem};
99
1010use crate :: client:: TransportArc ;
1111
12+ const BUCKET_INTERVAL : Duration = Duration :: from_secs ( 10 ) ;
13+ const FLUSH_INTERVAL : Duration = Duration :: from_secs ( 10 ) ;
14+
1215#[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord ) ]
1316enum MetricType {
1417 Counter ,
@@ -56,12 +59,14 @@ struct GaugeValue {
5659 sum : f64 ,
5760 count : u64 ,
5861}
62+
5963enum BucketValue {
6064 Counter ( f64 ) ,
6165 Distribution ( Vec < f64 > ) ,
6266 Set ( BTreeSet < String > ) ,
6367 Gauge ( GaugeValue ) ,
6468}
69+
6570impl BucketValue {
6671 fn distribution ( val : f64 ) -> BucketValue {
6772 Self :: Distribution ( vec ! [ val] )
@@ -89,7 +94,9 @@ impl BucketValue {
8994 ( BucketValue :: Distribution ( d1) , BucketValue :: Distribution ( d2) ) => {
9095 d1. extend ( d2) ;
9196 }
92- ( BucketValue :: Set ( s1) , BucketValue :: Set ( s2) ) => s1. extend ( s2) ,
97+ ( BucketValue :: Set ( s1) , BucketValue :: Set ( s2) ) => {
98+ s1. extend ( s2) ;
99+ }
93100 ( BucketValue :: Gauge ( g1) , BucketValue :: Gauge ( g2) ) => {
94101 g1. last = g2. last ;
95102 g1. min = g1. min . min ( g2. min ) ;
@@ -99,6 +106,7 @@ impl BucketValue {
99106 }
100107 _ => return Err ( ( ) ) ,
101108 }
109+
102110 Ok ( ( ) )
103111 }
104112}
@@ -124,9 +132,6 @@ pub struct MetricAggregator {
124132 handle : Option < JoinHandle < ( ) > > ,
125133}
126134
127- const BUCKET_INTERVAL : Duration = Duration :: from_secs ( 10 ) ;
128- const FLUSH_INTERVAL : Duration = Duration :: from_secs ( 10 ) ;
129-
130135impl MetricAggregator {
131136 pub fn new ( transport : TransportArc ) -> Self {
132137 let ( sender, receiver) = mpsc:: sync_channel ( 30 ) ;
0 commit comments