Skip to content

Implement Prometheus boundary extrapolation for rate() and increase() #660

Description

@milindsrivastava1997

Context

PR #657 fixes counter-reset detection/correction for rate() and increase(), but the accumulator currently evaluates only the reset-corrected delta over the observed samples. It does not reproduce Prometheus boundary extrapolation.

Prometheus documents that increase() is extrapolated to cover the full range-vector window, and rate() uses the same extrapolated increase divided by the requested range duration.

This is a follow-up to #657.

Requirements

  • Implement Prometheus extrapolatedRate semantics for counter rate() and increase().
  • Preserve the required sample count in IncreaseAccumulator and merge it correctly across panes.
  • Persist the additional state in JSON, binary, and active Arroyo formats.
  • Pass the evaluated range-vector start/end boundaries through instant and range-query execution.
  • Apply the average-sample-interval threshold and half-interval edge extrapolation.
  • Apply Prometheus counter duration-to-zero handling.
  • Ensure range queries use the correct boundaries independently for every output step.
  • Preserve the reset correction behavior implemented by fix(precompute): correct counter resets in rate and increase #657.

TDD coverage

Add tests before implementation for:

  • No boundary gaps.
  • Small and large gaps at either edge.
  • Sparse samples and non-integer increases.
  • Counter resets combined with extrapolation.
  • Counter duration-to-zero clamping.
  • rate() versus increase() scaling.
  • Single-sample and degenerate-range behavior.
  • JSON, binary, and Arroyo round trips including sample count.
  • Per-step range-query boundaries.

Do not modify the legacy asap-summary-ingest templates as part of this issue.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions