Skip to content

Commit 037d651

Browse files
jasnelladuh95
authored andcommitted
doc: move histogram.burnRate to correct location in doc
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #65434 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 587b921 commit 037d651

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

doc/api/perf_hooks.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,37 @@ invoked.
18801880
added: v11.10.0
18811881
-->
18821882

1883+
### `histogram.burnRate(sloTarget)`
1884+
1885+
<!-- YAML
1886+
added: v26.8.0
1887+
-->
1888+
1889+
* `sloTarget` {number} The SLO target as a fraction between 0 and 1
1890+
(exclusive). For example, `0.999` for a 99.9% SLO.
1891+
* Returns: {number}
1892+
1893+
Returns the SLO burn rate: `ewmaErrorRate / (1 - sloTarget)`. A burn rate
1894+
of 1 means the error budget will be exactly exhausted over the SLO window.
1895+
A burn rate greater than 1 means it is being consumed faster than allowed.
1896+
Requires the histogram to have been created with both `halfLife` and
1897+
`threshold` options.
1898+
1899+
```js
1900+
const { createHistogram } = require('node:perf_hooks');
1901+
1902+
// Track latency with a 200ms SLO threshold, half-life of 100 samples
1903+
const h = createHistogram({ halfLife: 100, threshold: 200_000_000 });
1904+
1905+
// ... record latency values ...
1906+
1907+
// Check burn rate against a 99.9% SLO
1908+
const rate = h.burnRate(0.999);
1909+
if (rate > 1) {
1910+
console.log(`SLO burn rate: ${rate.toFixed(2)}x — error budget depleting`);
1911+
}
1912+
```
1913+
18831914
### `histogram.count`
18841915

18851916
<!-- YAML
@@ -2071,37 +2102,6 @@ The EWMA-smoothed probability of a recorded value exceeding the configured
20712102
and `threshold` options. Returns `0` when not enabled or no values have been
20722103
recorded.
20732104

2074-
### `histogram.burnRate(sloTarget)`
2075-
2076-
<!-- YAML
2077-
added: v26.8.0
2078-
-->
2079-
2080-
* `sloTarget` {number} The SLO target as a fraction between 0 and 1
2081-
(exclusive). For example, `0.999` for a 99.9% SLO.
2082-
* Returns: {number}
2083-
2084-
Returns the SLO burn rate: `ewmaErrorRate / (1 - sloTarget)`. A burn rate
2085-
of 1 means the error budget will be exactly exhausted over the SLO window.
2086-
A burn rate greater than 1 means it is being consumed faster than allowed.
2087-
Requires the histogram to have been created with both `halfLife` and
2088-
`threshold` options.
2089-
2090-
```js
2091-
const { createHistogram } = require('node:perf_hooks');
2092-
2093-
// Track latency with a 200ms SLO threshold, half-life of 100 samples
2094-
const h = createHistogram({ halfLife: 100, threshold: 200_000_000 });
2095-
2096-
// ... record latency values ...
2097-
2098-
// Check burn rate against a 99.9% SLO
2099-
const rate = h.burnRate(0.999);
2100-
if (rate > 1) {
2101-
console.log(`SLO burn rate: ${rate.toFixed(2)}x — error budget depleting`);
2102-
}
2103-
```
2104-
21052105
### `histogram.ksTest(other)`
21062106

21072107
<!-- YAML

0 commit comments

Comments
 (0)