fix: web-probe 降噪 DOM 诊断分组 (#585)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -1633,14 +1633,15 @@ function groupDomDiagnostics(events) {
|
||||
const groups = new Map();
|
||||
for (const item of events || []) {
|
||||
const preview = String(item?.preview || "").trim();
|
||||
if (!isReportableDomDiagnostic(item, preview)) continue;
|
||||
const normalizedPreview = normalizeDiagnosticPreview(preview);
|
||||
const key = [
|
||||
item?.source || "",
|
||||
item?.diagnosticCode || "",
|
||||
normalizedPreview
|
||||
].join("|");
|
||||
const existing = groups.get(key) || {
|
||||
source: item?.source || null,
|
||||
sources: new Set(),
|
||||
diagnosticCode: item?.diagnosticCode || null,
|
||||
textHash: item?.textHash || null,
|
||||
normalizedPreview,
|
||||
@@ -1652,6 +1653,7 @@ function groupDomDiagnostics(events) {
|
||||
traceIds: new Set(),
|
||||
sampleSeqs: []
|
||||
};
|
||||
if (item?.source) existing.sources.add(String(item.source));
|
||||
existing.count += 1;
|
||||
existing.firstAt = minIso(existing.firstAt, item?.ts || null);
|
||||
existing.lastAt = maxIso(existing.lastAt, item?.ts || null);
|
||||
@@ -1663,6 +1665,7 @@ function groupDomDiagnostics(events) {
|
||||
return Array.from(groups.values())
|
||||
.map((item) => ({
|
||||
source: item.source,
|
||||
sources: Array.from(item.sources).sort(),
|
||||
diagnosticCode: item.diagnosticCode,
|
||||
textHash: item.textHash,
|
||||
normalizedPreview: item.normalizedPreview,
|
||||
@@ -1677,6 +1680,11 @@ function groupDomDiagnostics(events) {
|
||||
.sort((a, b) => (b.count - a.count) || String(a.firstAt || "").localeCompare(String(b.firstAt || "")));
|
||||
}
|
||||
|
||||
function isReportableDomDiagnostic(item, preview) {
|
||||
if (item?.source === "diagnostic-node" || item?.source === "execution-row") return true;
|
||||
return /trace_id=|HTTP\s+\d{3}\b|Failed to load resource|ERR_[A-Z_]+|provider-unavailable|AgentRun error|超过\s*\d+\s*ms\s*无新活动|代理暂时无法连接上游|Trace 更新超时|加载失败/iu.test(String(preview || ""));
|
||||
}
|
||||
|
||||
function normalizeDiagnosticPreview(text) {
|
||||
return String(text || "")
|
||||
.replace(/trace_id=[A-Za-z0-9_-]+/gu, "trace_id=:traceId")
|
||||
@@ -1684,6 +1692,7 @@ function normalizeDiagnosticPreview(text) {
|
||||
.replace(/\bses_[A-Za-z0-9_-]+\b/gu, "ses_:sessionId")
|
||||
.replace(/\brun_[A-Za-z0-9_-]+\b/gu, "run_:runId")
|
||||
.replace(/\bcmd_[A-Za-z0-9_-]+\b/gu, "cmd_:commandId")
|
||||
.replace(/[!!]+$/gu, "")
|
||||
.replace(/\s+/gu, " ")
|
||||
.trim();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user