@@ -1882,6 +1882,37 @@ invoked.
18821882added: v11.10.0
18831883-->
18841884
1885+ ### ` histogram.burnRate(sloTarget) `
1886+
1887+ <!-- YAML
1888+ added: REPLACEME
1889+ -->
1890+
1891+ * ` sloTarget ` {number} The SLO target as a fraction between 0 and 1
1892+ (exclusive). For example, ` 0.999 ` for a 99.9% SLO.
1893+ * Returns: {number}
1894+
1895+ Returns the SLO burn rate: ` ewmaErrorRate / (1 - sloTarget) ` . A burn rate
1896+ of 1 means the error budget will be exactly exhausted over the SLO window.
1897+ A burn rate greater than 1 means it is being consumed faster than allowed.
1898+ Requires the histogram to have been created with both ` halfLife ` and
1899+ ` threshold ` options.
1900+
1901+ ``` js
1902+ const { createHistogram } = require (' node:perf_hooks' );
1903+
1904+ // Track latency with a 200ms SLO threshold, half-life of 100 samples
1905+ const h = createHistogram ({ halfLife: 100 , threshold: 200_000_000 });
1906+
1907+ // ... record latency values ...
1908+
1909+ // Check burn rate against a 99.9% SLO
1910+ const rate = h .burnRate (0.999 );
1911+ if (rate > 1 ) {
1912+ console .log (` SLO burn rate: ${ rate .toFixed (2 )} x — error budget depleting` );
1913+ }
1914+ ```
1915+
18851916### ` histogram.count `
18861917
18871918<!-- YAML
@@ -2073,37 +2104,6 @@ The EWMA-smoothed probability of a recorded value exceeding the configured
20732104and ` threshold ` options. Returns ` 0 ` when not enabled or no values have been
20742105recorded.
20752106
2076- ### ` histogram.burnRate(sloTarget) `
2077-
2078- <!-- YAML
2079- added: REPLACEME
2080- -->
2081-
2082- * ` sloTarget ` {number} The SLO target as a fraction between 0 and 1
2083- (exclusive). For example, ` 0.999 ` for a 99.9% SLO.
2084- * Returns: {number}
2085-
2086- Returns the SLO burn rate: ` ewmaErrorRate / (1 - sloTarget) ` . A burn rate
2087- of 1 means the error budget will be exactly exhausted over the SLO window.
2088- A burn rate greater than 1 means it is being consumed faster than allowed.
2089- Requires the histogram to have been created with both ` halfLife ` and
2090- ` threshold ` options.
2091-
2092- ``` js
2093- const { createHistogram } = require (' node:perf_hooks' );
2094-
2095- // Track latency with a 200ms SLO threshold, half-life of 100 samples
2096- const h = createHistogram ({ halfLife: 100 , threshold: 200_000_000 });
2097-
2098- // ... record latency values ...
2099-
2100- // Check burn rate against a 99.9% SLO
2101- const rate = h .burnRate (0.999 );
2102- if (rate > 1 ) {
2103- console .log (` SLO burn rate: ${ rate .toFixed (2 )} x — error budget depleting` );
2104- }
2105- ```
2106-
21072107### ` histogram.ksTest(other) `
21082108
21092109<!-- YAML
0 commit comments