Skip to main content

extrapolation_factor

Function extrapolation_factor 

Source
pub(super) fn extrapolation_factor(
    span: ExtrapolationSpan,
    eval_ts: i64,
    range_ms: i64,
    is_counter: bool,
    is_rate: bool,
    zero_point: Option<f64>,
) -> f64
Expand description

The factor extrapolatedRate scales the sampled increase by. zero_point is the first value over the increase, given only when Prometheus extrapolates a counter to zero: it is the share of the sampled interval that lies before span.sampled_from, so 0 says the counter’s zero point is span.sampled_from itself, which is what a synthetic zero is.

Floats and native histograms both come through here, and this is the only place the factor is computed; the two routes differ in the anchors they read, never in the arithmetic. The one deliberate difference is not in the formula: a zero sampled_interval makes this function answer 1.0 (1 / range for a rate), which is the identity a float window wants to multiply its increase by, while the histogram caller answers no value at all before calling this. Its buckets are all zero there, and an Inf or NaN rate would only poison what consumes it downstream; a float window has no such leftovers to hand on.