fix: depollute v02 web performance telemetry

This commit is contained in:
Codex Agent
2026-06-05 13:03:09 +08:00
parent aec6903407
commit ac2d3001fa
8 changed files with 83 additions and 5 deletions
+8
View File
@@ -111,6 +111,8 @@ export function createWebPerformanceStore(options: WebPerformanceStoreOptions =
if (!Number.isFinite(rawValue) || rawValue < 0) return null;
const value = isCls ? Math.min(rawValue, 10) : Math.min(rawValue, 120);
const route = webPerformanceRouteTemplate(input.route ?? payload.page ?? "/workspace");
const pageRoute = webPerformanceRouteTemplate(payload.page ?? "/workspace");
if (isObservabilityNoise({ kind, metric, route, pageRoute })) return null;
const labels = {
...baseLabels,
kind,
@@ -259,6 +261,12 @@ function sampleLabels(labels: Record<string, string>) {
};
}
function isObservabilityNoise(event: { kind: string; metric: string; route: string; pageRoute: string }) {
if (event.pageRoute === "/performance") return true;
if (event.route === "/performance" && (event.kind === "navigation" || event.kind === "web_vital" || event.kind === "long_task")) return true;
return event.route === "/v1/web-performance" || event.route.startsWith("/v1/web-performance/");
}
function recordHistogram(series: Map<string, HistogramSeries>, labels: Record<string, string>, value: number, buckets: number[], maxSeries: number) {
const key = stableLabelKey(labels);
let entry = series.get(key);