A remote sensor went quiet. The dashboard already said when its last sample arrived, but that is only half the question a reader wants answered: is this silence ordinary, or is it longer than usual?

We added one line to answer that. It took longer to decide what not to measure than to write the code.

Two clocks, one gap

The first trap was the start of the gap. The sensor writes its own timestamp; the collector that reads it has its own sampling schedule. Those clocks can differ by a sampling interval. Measuring the silence from the sensor's last log row and measuring it from the last fresh collector row give two different durations, and neither is wrong — they answer different questions.

We measure from the last fresh collector row, and print that clock next to the duration. A number without its start point is a number you cannot check.

The baseline cannot include the thing being measured

The obvious comparison is "how does this gap compare with recent gaps?" The obvious implementation takes every gap in the last seven days, including the one still open.

That fails in a quiet way. The open gap grows as you watch it; the longer it gets, the more it drags the baseline upward, until it looks ordinary by its own standard. A metric that includes its own subject cannot report a surprise.

So the line compares only completed gaps that ended inside the trailing seven days. The ongoing one is excluded. If four out of five completed gaps lasted at least as long, it says so. If none did, it says zero out of five. The number can only become more striking as the silence continues; it cannot reassure itself.

In the committed test fixture, a 100-minute open silence reads "2/2 completed gaps in 7d lasted at least this long". Make the open silence longer than every completed gap and the same line reads "0/1". Nothing about the code depends on those particular numbers; they are fixtures, not field observations.

When there is nothing to compare, say so

There may be no completed gap in the window — a sensor that has only just started reporting, or a week in which nothing broke. The line then reads UNKNOWN: no completed gaps to compare. It does not say "normal", and it does not fall back to a lifetime average.

Malformed history, unreadable files, future-dated rows and a newest row that is actually fresh all leave the line out entirely. A missing line is not a GREEN line. The sensor's own verdict is untouched by any of this: the comparison is context, not an alarm.

A small rule worth keeping

The pattern generalises beyond sensors. For any ongoing condition — an outage, a queue, a run of failed attempts — a baseline built from closed episodes is a claim about the past, and a baseline that swallows the open episode is a claim that nothing unusual is happening. Only one of those can tell you something you did not already assume.

We kept the one that can.