Buckets:
| // Copyright (c) 2026 the Zuke contributors | |
| // SPDX-License-Identifier: MIT | |
| /** | |
| * The bounds check of the `azureMonitor(...)` canary analysis. Internal to the | |
| * package. | |
| * | |
| * `@zuke/canary` has the same check for its `prometheus(...)` and | |
| * `metricThreshold(...)` analyses, and this one reports in the same words so | |
| * a rollout reads alike whichever analysis failed it. It is not imported | |
| * from there because a wrapper package depends on `@zuke/core` alone. | |
| * | |
| * @module | |
| */ | |
| /** Inclusive bounds a metric must stay within; either side may be open. */ | |
| interface Bounds { | |
| /** The lowest acceptable value, if any. */ | |
| min?: number; | |
| /** The highest acceptable value, if any. */ | |
| max?: number; | |
| } | |
| /** | |
| * The bounds `min` and `max` describe, refusing a set that cannot work. Each | |
| * is finite already: the analysis's setters refuse anything else. | |
| */ | |
| export function boundsOf( | |
| label: string, | |
| min: number | undefined, | |
| max: number | undefined, | |
| ): Bounds { | |
| if (min === undefined && max === undefined) { | |
| throw new Error(`"${label}" sets no bound — call .min(...) or .max(...).`); | |
| } | |
| if (min !== undefined && max !== undefined && min > max) { | |
| throw new Error( | |
| `"${label}" can never pass: its minimum ${min} is above its maximum ` + | |
| `${max}.`, | |
| ); | |
| } | |
| return { | |
| ...(min === undefined ? {} : { min }), | |
| ...(max === undefined ? {} : { max }), | |
| }; | |
| } | |
| /** | |
| * Throw when `value` is outside `bounds`, naming the metric. An Azure Monitor | |
| * value arrives through JSON, which has no NaN, and a KQL value that does not | |
| * parse as a number is refused where it is read, so unlike canary's check | |
| * this one has no NaN case to report. | |
| */ | |
| export function checkThreshold( | |
| label: string, | |
| value: number, | |
| bounds: Bounds, | |
| ): void { | |
| if (bounds.max !== undefined && value > bounds.max) { | |
| throw new Error(`${label} is ${value}, above the maximum ${bounds.max}.`); | |
| } | |
| if (bounds.min !== undefined && value < bounds.min) { | |
| throw new Error(`${label} is ${value}, below the minimum ${bounds.min}.`); | |
| } | |
| } | |
Xet Storage Details
- Size:
- 2.05 kB
- Xet hash:
- cd4cbb6797b06d69004c6df1b122d530b0e4bae750cba07377abdad6b8d3ac28
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.