(metric: ToolInvocationMetric)
| 474 | return initialized && !isSentryDisabled() && !isTestEnv() && !isSentryCaptureSealed(); |
| 475 | } |
| 476 | export function recordToolInvocationMetric(metric: ToolInvocationMetric): void { |
| 477 | if (!shouldEmitMetrics()) { |
| 478 | return; |
| 479 | } |
| 480 | |
| 481 | const tags = { |
| 482 | tool_name: sanitizeTagValue(metric.toolName), |
| 483 | runtime: metric.runtime, |
| 484 | transport: metric.transport, |
| 485 | outcome: metric.outcome, |
| 486 | }; |
| 487 | |
| 488 | try { |
| 489 | Sentry.metrics.count('xcodebuildmcp.tool.invocation.count', 1, { attributes: tags }); |
| 490 | Sentry.metrics.distribution( |
| 491 | 'xcodebuildmcp.tool.invocation.duration_ms', |
| 492 | Math.max(0, metric.durationMs), |
| 493 | { attributes: tags }, |
| 494 | ); |
| 495 | } catch { |
| 496 | // Metrics are best effort and must never affect tool execution. |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | export function recordInternalErrorMetric(metric: InternalErrorMetric): void { |
| 501 | if (!shouldEmitMetrics()) { |
no test coverage detected