@@ -18,11 +18,14 @@ type NomParserError<'a> = nom::Err<nom::error::Error<&'a [u8]>>;
1818//
1919// Our logic here is:
2020// - DogStatsD payloads are limited to 8KiB by default
21- // - a valid distribution metric could have a multi-value payload with ~4093 values (value of `1`, when factoring for protocol overhead)
22- // - to avoid overflow in resulting sketch, total count of all values must be less than or equal to 2^32
23- // - 2^32 / 4093 = 1,049,344... or 1,000,000 to be safe
24- // - 1 / 1,000,000 = 0.000001
25- const MINIMUM_SAFE_DEFAULT_SAMPLE_RATE : f64 = 0.000001 ;
21+ // - a valid distribution metric could have a multi-value payload with ~4093 values (value of `1`, when factoring for
22+ // protocol overhead)
23+ // - to avoid overflow in resulting sketch, total count of all values must be less than or equal to 2^64
24+ // - 2^64 / 4093 = 4.5069006e+15.. which is really big
25+ // - our DDSketch implementation we write into, however, is effectively capped at ~270M (4096 bins max, `u16` for bin
26+ // count, so 4096 * 2^16 = 268,435,456)
27+ // - we take 260M to be safe, which when calculating the sample rate, gives us 1 / 260,000,000, or 0.000000003845
28+ const MINIMUM_SAFE_DEFAULT_SAMPLE_RATE : f64 = 0.000000003845 ;
2629
2730/// Parser error.
2831#[ derive( Debug ) ]
@@ -132,7 +135,7 @@ impl DogstatsdCodecConfiguration {
132135 /// This is the minimum sample rate that is allowed for a metric payload. If the sample rate is less than this limit,
133136 /// the sample rate is clamped to this value and a log message is emitted.
134137 ///
135- /// Defaults to `0.000001 `.
138+ /// Defaults to `0.000000003845 `.
136139 pub fn with_minimum_sample_rate ( mut self , minimum_sample_rate : f64 ) -> Self {
137140 self . minimum_sample_rate = minimum_sample_rate;
138141 self
0 commit comments