Skip to content

Commit d62eca0

Browse files
committed
chore(dogstatsd): update default minimum sample rate
1 parent 1b13d5f commit d62eca0

File tree

2 files changed

+11
-8
lines changed
  • lib
    • saluki-components/src/sources/dogstatsd
    • saluki-io/src/deser/codec/dogstatsd

2 files changed

+11
-8
lines changed

lib/saluki-components/src/sources/dogstatsd/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const fn default_dogstatsd_permissive_decoding() -> bool {
126126
}
127127

128128
const fn default_dogstatsd_minimum_sample_rate() -> f64 {
129-
0.00000025
129+
0.000000003845
130130
}
131131

132132
const fn default_enable_payloads_series() -> bool {
@@ -291,7 +291,7 @@ pub struct DogStatsDConfiguration {
291291
///
292292
/// A warning log will be emitted when clamping occurs, as this represents an effective loss of metric samples.
293293
///
294-
/// Defaults to `0.00000025`. (4,000,000 samples)
294+
/// Defaults to `0.000000003845`. (~260M samples)
295295
#[serde(
296296
rename = "dogstatsd_minimum_sample_rate",
297297
default = "default_dogstatsd_minimum_sample_rate"

lib/saluki-io/src/deser/codec/dogstatsd/mod.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)