fix(web-probe): configure observe alert thresholds from yaml (#726)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -125,6 +125,16 @@ export type HwlabRuntimeWebProbeOriginSpec = HwlabRuntimeWebProbeServiceOriginSp
|
||||
export interface HwlabRuntimeWebProbeSpec {
|
||||
readonly browserProxyMode?: "auto" | "direct";
|
||||
readonly defaultOrigin?: HwlabRuntimeWebProbeOriginSpec;
|
||||
readonly alertThresholds?: HwlabRuntimeWebProbeAlertThresholdsSpec;
|
||||
}
|
||||
|
||||
export interface HwlabRuntimeWebProbeAlertThresholdsSpec {
|
||||
readonly sameOriginApiSlowMs: number;
|
||||
readonly partialApiSlowMs: number;
|
||||
readonly longLivedStreamOpenSlowMs: number;
|
||||
readonly visibleLoadingSlowMs: number;
|
||||
readonly turnTimingSampleSlackSeconds: number;
|
||||
readonly sessionRailFallbackRatio: number;
|
||||
}
|
||||
|
||||
export interface HwlabRuntimeBuildkitSpec {
|
||||
@@ -692,6 +702,21 @@ function webProbeConfig(value: unknown, path: string): HwlabRuntimeWebProbeSpec
|
||||
return {
|
||||
...(browserProxyMode === undefined ? {} : { browserProxyMode }),
|
||||
...(raw.defaultOrigin === undefined ? {} : { defaultOrigin: webProbeOriginConfig(raw.defaultOrigin, `${path}.defaultOrigin`) }),
|
||||
...(raw.alertThresholds === undefined ? {} : { alertThresholds: webProbeAlertThresholdsConfig(raw.alertThresholds, `${path}.alertThresholds`) }),
|
||||
};
|
||||
}
|
||||
|
||||
function webProbeAlertThresholdsConfig(value: unknown, path: string): HwlabRuntimeWebProbeAlertThresholdsSpec {
|
||||
const raw = asRecord(value, path);
|
||||
const sessionRailFallbackRatio = positiveNumberField(raw, "sessionRailFallbackRatio", path);
|
||||
if (sessionRailFallbackRatio > 1) throw new Error(`${path}.sessionRailFallbackRatio must be <= 1`);
|
||||
return {
|
||||
sameOriginApiSlowMs: positiveNumberField(raw, "sameOriginApiSlowMs", path),
|
||||
partialApiSlowMs: positiveNumberField(raw, "partialApiSlowMs", path),
|
||||
longLivedStreamOpenSlowMs: positiveNumberField(raw, "longLivedStreamOpenSlowMs", path),
|
||||
visibleLoadingSlowMs: positiveNumberField(raw, "visibleLoadingSlowMs", path),
|
||||
turnTimingSampleSlackSeconds: positiveNumberField(raw, "turnTimingSampleSlackSeconds", path),
|
||||
sessionRailFallbackRatio,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user