histogram.burnRate(sloTarget)


  • sloTarget <number> SLO 目标是一个介于 0 和 1 之间的分数(不包括 0 和 1)。例如,99.9% 的 SLO 可以写成 0.999。
  • 返回:<number>

返回 SLO 消耗速率:ewmaErrorRate / (1 - sloTarget)。消耗速率为 1 表示在 SLO 窗口期内错误预算将被完全耗尽。消耗速率大于 1 表示消耗速度超过允许值。要求直方图必须使用 halfLife 和 threshold 选项创建。

🌐 Returns the SLO burn rate: ewmaErrorRate / (1 - sloTarget). A burn rate of 1 means the error budget will be exactly exhausted over the SLO window. A burn rate greater than 1 means it is being consumed faster than allowed. Requires the histogram to have been created with both halfLife and threshold options.

const { createHistogram } = require('node:perf_hooks');

// Track latency with a 200ms SLO threshold, half-life of 100 samples
const h = createHistogram({ halfLife: 100, threshold: 200_000_000 });

// ... record latency values ...

// Check burn rate against a 99.9% SLO
const rate = h.burnRate(0.999);
if (rate > 1) {
  console.log(`SLO burn rate: ${rate.toFixed(2)}x — error budget depleting`);
}