File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
lading_payload/src/dogstatsd Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ pub(crate) struct MetricGenerator {
2727 pub ( crate ) sampling : ConfRange < f32 > ,
2828 pub ( crate ) sampling_probability : f32 ,
2929 pub ( crate ) num_value_generator : NumValueGenerator ,
30+ pub ( crate ) ctx_idx : std:: cell:: Cell < usize > ,
3031}
3132
3233impl MetricGenerator {
@@ -86,6 +87,7 @@ impl MetricGenerator {
8687 sampling,
8788 sampling_probability,
8889 num_value_generator : NumValueGenerator :: new ( value_conf) ,
90+ ctx_idx : std:: cell:: Cell :: new ( 0 ) ,
8991 } )
9092 }
9193}
@@ -102,8 +104,10 @@ impl<'a> Generator<'a> for MetricGenerator {
102104 // and the program should crash prior to this point.
103105 let template: & Template = self
104106 . templates
105- . choose ( & mut rng)
106- . expect ( "failed to choose templates" ) ;
107+ . get ( self . ctx_idx . get ( ) )
108+ . expect ( "failed to get template" ) ;
109+ self . ctx_idx
110+ . set ( ( self . ctx_idx . get ( ) + 1 ) % self . templates . len ( ) ) ;
107111
108112 let container_id = choose_or_not_ref ( & mut rng, & self . container_ids ) . map ( String :: as_str) ;
109113 // https://docs.datadoghq.com/metrics/custom_metrics/dogstatsd_metrics_submission/#sample-rates
You can’t perform that action at this time.
0 commit comments