An open incident now shows "usually ~30m more (up to 1h 30m)", worked out
from how long earlier incidents with the same team and signature took.
GET /api/incidents/{id}/estimate returns the 50th and 90th percentile of
the time still to go, among earlier occurrences that lasted longer than this
one has so far. With fewer than five comparable occurrences it returns no
figures, and when this incident has outlived all of them it says
longer_than_usual instead of inventing a number.
Incidents closed by hand are left out: they record when someone gave up on
the incident, not when the problem ended. Archived incidents are left out
too, as in the stats. It is history, not a forecast; nothing about the
alert's current value is known to it, and the UI labels it as an estimate.
Added /similar to docs/api.md as well, which was missing from the table.
The stats page keeps its own median: it is the upper median, and switching
it to interpolated would change figures people already read.
19 lines
401 B
Go
19 lines
401 B
Go
package api
|
|
|
|
import "testing"
|
|
|
|
func TestPercentile(t *testing.T) {
|
|
xs := []int64{50, 10, 40, 20, 30}
|
|
for _, c := range []struct {
|
|
p float64
|
|
want float64
|
|
}{{0, 10}, {0.5, 30}, {0.9, 46}, {1, 50}} {
|
|
if got := percentile(xs, c.p); got != c.want {
|
|
t.Errorf("percentile(%v) = %v, want %v", c.p, got, c.want)
|
|
}
|
|
}
|
|
if xs[0] != 50 {
|
|
t.Errorf("percentile reordered its input: %v", xs)
|
|
}
|
|
}
|