fix: align performance summary problem counts (#1703)

This commit is contained in:
Lyon
2026-06-20 13:49:10 +08:00
committed by GitHub
parent bd4bc1fa36
commit d2e147c019
2 changed files with 25 additions and 1 deletions
+23
View File
@@ -251,6 +251,29 @@ test("web performance summary exposes Workbench p75 and low-sample diagnostics w
assert.doesNotMatch(json, /trc_secret|ses_secret|run_secret|cmd_secret|traceId|sessionId|runId|commandId|conversationId|prompt|api key/iu);
});
test("web performance summary does not count low-sample Workbench errors as performance problems", () => {
const store = createWebPerformanceStore({ env: { HWLAB_METRICS_NAMESPACE: "hwlab-v03", HWLAB_GITOPS_TARGET: "v03" } });
store.record({
schemaVersion: "hwlab-web-performance-v2",
page: "/workbench/sessions/ses_secret",
events: [
{ kind: "workbench_journey", journey: "session_switch_first_visible", route: "/workbench/sessions/ses_secret", source: "deeplink", targetState: "unknown", cache: "cold", outcome: "ok", valueMs: 560, sessionId: "ses_secret" },
{ kind: "workbench_journey", journey: "session_switch_full_load", route: "/workbench/sessions/ses_secret", source: "deeplink", targetState: "unknown", cache: "cold", outcome: "error", valueMs: 620, sessionId: "ses_secret" }
]
} as Record<string, unknown>);
const summary = store.summary();
const fullLoad = summary.workbenchJourneys.find((row) => row.metric === "session_switch_full_load");
const problemCard = summary.dashboard.cards.find((card) => card.id === "problems");
assert.equal(fullLoad?.sampleState, "low-sample");
assert.equal(fullLoad?.tone, "source");
assert.equal(fullLoad?.problem, "low-sample");
assert.equal(summary.summary.problemCount, 0);
assert.equal(summary.problems.length, 0);
assert.equal(problemCard?.value, 0);
});
test("web performance collection health only requires backend attribution for backend-scoped Workbench series", () => {
const frontendOnly = createWebPerformanceStore({ env: { HWLAB_METRICS_NAMESPACE: "hwlab-v03", HWLAB_GITOPS_TARGET: "v03" } });
frontendOnly.record({
+2 -1
View File
@@ -1298,6 +1298,7 @@ function summaryProblemForRow(row: PerformanceSummaryRow, p95: number, count: nu
}
function isPerformanceProblemRow(row: PerformanceSummaryRow) {
if ((row.kind === "workbench_journey" || row.kind === "workbench_event_phase" || row.kind === "workbench_backend_event_visible") && row.sampleState !== "ok") return false;
return row.tone === "blocked" || row.tone === "warn" || row.outcome !== "ok" || row.statusClass === "network" || row.statusClass === "5xx" || row.statusClass === "4xx";
}
@@ -1508,8 +1509,8 @@ function performanceProblem(labels: Record<string, string>, p95: number, count:
function workbenchProblem(outcome: string, metric: string, count: number, tone: string) {
if (count <= 0) return "no-sample";
if (outcome !== "ok") return outcome;
if (count < LOW_SAMPLE_THRESHOLD) return "low-sample";
if (outcome !== "ok") return outcome;
if (tone === "blocked" || tone === "warn") return `slow-${metric}`;
return "ok";
}