@@ -16,6 +16,9 @@ pub struct LogicalMeterConfig {
1616 pub ( crate ) resampling_function : Option < ResamplingFunction < f32 , Sample < f32 > > > ,
1717 /// Resampler overrides.
1818 pub ( crate ) resampling_overrides : HashMap < Metric , ResamplingFunction < f32 , Sample < f32 > > > ,
19+ /// The maximum age of samples to be considered for resampling, in number of
20+ /// intervals.
21+ pub ( crate ) max_age_in_intervals : u32 ,
1922}
2023
2124impl LogicalMeterConfig {
@@ -25,6 +28,7 @@ impl LogicalMeterConfig {
2528 resampling_interval,
2629 resampling_function : None ,
2730 resampling_overrides : HashMap :: new ( ) ,
31+ max_age_in_intervals : 3 ,
2832 }
2933 }
3034
@@ -55,4 +59,17 @@ impl LogicalMeterConfig {
5559
5660 self
5761 }
62+
63+ /// Sets the maximum age of samples to be considered for resampling, in
64+ /// number of intervals.
65+ ///
66+ /// Must be at least 1. If a smaller value is provided, it will be clamped
67+ /// to 1.
68+ ///
69+ /// If not set, the default value is 3.
70+ pub fn with_max_age_in_intervals ( mut self , max_age_in_intervals : u32 ) -> Self {
71+ // Ensure that the maximum age is at least 1 interval.
72+ self . max_age_in_intervals = max_age_in_intervals. max ( 1 ) ;
73+ self
74+ }
5875}
0 commit comments