MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / captureMcpShutdownSummary

Function captureMcpShutdownSummary

src/utils/sentry.ts:399–447  ·  view source on GitHub ↗
(summary: McpShutdownSummaryEvent)

Source from the content-addressed store, hash-verified

397}
398
399export function captureMcpShutdownSummary(summary: McpShutdownSummaryEvent): void {
400 if (!initialized || isSentryDisabled() || isTestEnv() || isSentryCaptureSealed()) {
401 return;
402 }
403
404 try {
405 const snapshotAnomalies = (summary.snapshot as { anomalies?: unknown }).anomalies;
406 const PEER_ANOMALIES: ReadonlySet<string> = new Set(['peer-count-high', 'peer-age-high']);
407 const localAnomalyCount = Array.isArray(snapshotAnomalies)
408 ? snapshotAnomalies.filter((a) => typeof a === 'string' && !PEER_ANOMALIES.has(a)).length
409 : 0;
410
411 const isCrashReason =
412 summary.reason === 'startup-failure' ||
413 summary.reason === 'uncaught-exception' ||
414 summary.reason === 'unhandled-rejection';
415
416 let level: 'error' | 'warning' | 'info';
417 if (isCrashReason) {
418 level = 'error';
419 } else if (summary.shutdownStepFailureCount > 0 || localAnomalyCount > 0) {
420 level = 'warning';
421 } else {
422 level = 'info';
423 }
424
425 Sentry.captureEvent({
426 level,
427 message: 'mcp.shutdown.summary',
428 tags: {
429 runtime: 'mcp',
430 reason: sanitizeTagValue(summary.reason),
431 phase: sanitizeTagValue(summary.phase),
432 },
433 extra: {
434 exitCode: summary.exitCode,
435 transportDisconnected: summary.transportDisconnected,
436 triggerError: summary.triggerError,
437 shutdownStepFailureCount: summary.shutdownStepFailureCount,
438 cleanupDiagnosticCount: summary.cleanupDiagnosticCount,
439 shutdownDurationMs: summary.shutdownDurationMs,
440 snapshot: summary.snapshot,
441 steps: summary.steps,
442 },
443 });
444 } catch {
445 // Shutdown summary is best effort.
446 }
447}
448
449interface ToolInvocationMetric {
450 toolName: string;

Callers 1

runMcpShutdownFunction · 0.90

Calls 4

isSentryCaptureSealedFunction · 0.90
isSentryDisabledFunction · 0.85
sanitizeTagValueFunction · 0.85
isTestEnvFunction · 0.70

Tested by

no test coverage detected