Code Room
Code reviewMedium
Question
Review this Python code that summarizes latency once per scrape interval.
`scrape` runs on a fixed timer regardless of whether any traffic arrived in the window.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
def avg_latency(samples): total = 0 for s in samples: total += s.latency_ms return total / len(samples) def scrape(window): samples = collect(window) # whatever arrived this interval avg = avg_latency(samples) emit_gauge("latency.avg_ms", avg) return avgRun or narrate your approach, then ask the coach.