INNER CODE UNIT · Python

Series

VersusControl/versus-incident · scripts/generate_fake_metrics.py:93

class Series:
    """Accumulates cumulative counter + histogram state for one service.

    Counters are cumulative (monotonically increasing) across the whole run
    so Prometheus `rate(...)` works once the pushgateway is scraped twice.
    Histogram buckets are cumulative per Prometheus convention: the count at
    `le=X` includes every observation with duration <= X.
    """

    def __init__(self) -> None:
        # requests[code] -> cumulative count
        self.requests: dict[str, int] = {}
        # cumulative count of observations with duration <= BUCKETS[i]
        self.bucket_counts = [0] * len(BUCKETS)
        self.inf_count = 0
        self.duration_sum = 0.0
        self.duration_count = 0

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…