From bc1f54be75b37854d1253141a86dc60735d8e59b Mon Sep 17 00:00:00 2001 From: Cameron Cooke Date: Tue, 31 Mar 2026 12:09:31 +0100 Subject: [PATCH] fix(sentry): Exclude peer anomalies from shutdown summary level escalation Peer anomalies (peer-count-high, peer-age-high) are environmental observations common in multi-client setups, not indicators of a problem with the shutting-down process. Exclude them from the level escalation logic so normal shutdowns emit at info instead of warning. Peer anomaly data is still captured in the event snapshot extra data and tracked independently via recordMcpLifecycleAnomalyMetric. Only process-local anomalies (high-rss, long-lived-high-rss) and cleanup failures now escalate to warning. Fixes XCODEBUILDMCP-Z Co-Authored-By: Claude Opus 4.6 (1M context) --- src/utils/sentry.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/sentry.ts b/src/utils/sentry.ts index 90bdc55a..992ab865 100644 --- a/src/utils/sentry.ts +++ b/src/utils/sentry.ts @@ -402,7 +402,10 @@ export function captureMcpShutdownSummary(summary: McpShutdownSummaryEvent): voi try { const snapshotAnomalies = (summary.snapshot as { anomalies?: unknown }).anomalies; - const anomalyCount = Array.isArray(snapshotAnomalies) ? snapshotAnomalies.length : 0; + const PEER_ANOMALIES: ReadonlySet = new Set(['peer-count-high', 'peer-age-high']); + const localAnomalyCount = Array.isArray(snapshotAnomalies) + ? snapshotAnomalies.filter((a) => typeof a === 'string' && !PEER_ANOMALIES.has(a)).length + : 0; const isCrashReason = summary.reason === 'startup-failure' || @@ -412,7 +415,7 @@ export function captureMcpShutdownSummary(summary: McpShutdownSummaryEvent): voi let level: 'error' | 'warning' | 'info'; if (isCrashReason) { level = 'error'; - } else if (summary.cleanupFailureCount > 0 || anomalyCount > 0) { + } else if (summary.cleanupFailureCount > 0 || localAnomalyCount > 0) { level = 'warning'; } else { level = 'info';