mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-14 17:44:06 -08:00
Merge pull request #14945 from roidelapluie/submillis
fix(web): properly format sub-millisecond durations in target status page
This commit is contained in:
commit
dfc6f4b5bc
|
@ -57,6 +57,12 @@ describe("humanizeDuration", () => {
|
|||
expect(humanizeDuration(0)).toBe("0s");
|
||||
});
|
||||
|
||||
test("formats submilliseconds correctly", () => {
|
||||
expect(humanizeDuration(0.1)).toBe("0ms");
|
||||
expect(humanizeDuration(0.6)).toBe("1ms");
|
||||
expect(humanizeDuration(0.000001)).toBe("0ms");
|
||||
});
|
||||
|
||||
test("formats milliseconds correctly", () => {
|
||||
expect(humanizeDuration(1)).toBe("1ms");
|
||||
expect(humanizeDuration(999)).toBe("999ms");
|
||||
|
|
|
@ -86,6 +86,9 @@ const formatDuration = (
|
|||
r.push(`${v}${unit}`);
|
||||
}
|
||||
}
|
||||
if (r.length == 0 && unit == "ms") {
|
||||
r.push(`${Math.round(ms)}ms`)
|
||||
}
|
||||
}
|
||||
|
||||
return sign + r.join(componentSeparator || "");
|
||||
|
|
Loading…
Reference in a new issue