INNER CODE UNIT · Python

simulate_tick

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

def simulate_tick(series: Series, spiking: bool, rate: int) -> None:
    """Fold ~one interval of synthetic traffic into the cumulative series.

    Normal: steady volume, ~0.5% errors, low latency (rules stay silent).
    Spike:  more volume, ~45% 500s, fat-tailed latency (p95 > 500ms) so the
            anomaly rules cross their thresholds.
    """
    n = random.randint(rate, rate + 10) if spiking else random.randint(rate, rate + 5)
    err_ratio = 0.45 if spiking else 0.005
    for _ in range(n):
        if random.random() < err_ratio:
            code = 500
            latency = random.uniform(0.8, 3.0) if spiking else random.uniform(0.2, 0.6)
        else:
            code = 200
            latency = random.uniform(0.6, 2.0) if spiking else random.uniform(0.02, 0.15)
        series.observe(code, latency)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…