{"record":{"id":"505ce45db0c97dca","repo":"mastra-ai/mastra","slug":"getmetricsbytype-has-been-removed-metrictype-is","errorCode":null,"errorMessage":"getMetricsByType() has been removed: metricType is no longer stored. Use getMetricsByName(metricName) instead to filter metrics by name.","messagePattern":"getMetricsByType\\(\\) has been removed: metricType is no longer stored\\. Use getMetricsByName\\(metricName\\) instead to filter metrics by name\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"observability/mastra/src/exporters/test.ts","lineNumber":701,"sourceCode":"  /**\n   * Get all collected metrics (unwrapped from events)\n   */\n  getAllMetrics(): ExportedMetric[] {\n    return this.#metricEvents.map(e => e.metric);\n  }\n\n  /**\n   * Get metrics filtered by name\n   */\n  getMetricsByName(name: string): ExportedMetric[] {\n    return this.#metricEvents.filter(e => e.metric.name === name).map(e => e.metric);\n  }\n\n  /**\n   * @deprecated MetricType is no longer stored. Use getMetricsByName() instead.\n   */\n  getMetricsByType(_metricType: string): ExportedMetric[] {\n    throw new Error(\n      'getMetricsByType() has been removed: metricType is no longer stored. ' +\n        'Use getMetricsByName(metricName) instead to filter metrics by name.',\n    );\n  }\n\n  // ============================================================================\n  // Score Query Methods\n  // ============================================================================\n\n  /**\n   * Get all collected score events\n   */\n  getScoreEvents(): ScoreEvent[] {\n    return [...this.#scoreEvents];\n  }\n\n  /**\n   * Get all collected scores (unwrapped from events)","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/observability/mastra/src/exporters/test.ts#L683-L719","documentation":"TestExporter previously keyed stored metrics by metricType; the metrics format no longer stores metricType, so this public method was turned into a hard-throwing tombstone. It exists purely to point migrators to the replacement API getMetricsByName(metricName).","triggerScenarios":"Calling exporter.getMetricsByType(anyType) on a TestExporter instance after upgrading to the version that removed metricType storage.","commonSituations":"Post-upgrade test suites or custom reporters filtering exported metrics by type; stale utilities written against the old metric storage format.","solutions":["Replace the call with getMetricsByName(metricName) to filter by metric name","If type-based filtering is needed, collect metrics via the export path and filter the returned ExportedMetric objects yourself","Remove the call if the type filter was vestigial"],"exampleFix":"// before\nconst counters = exporter.getMetricsByType('counter');\n// after\nconst counters = exporter.getMetricsByName('my.counter').filter(m => m.type === 'counter');","handlingStrategy":"type-guard","validationCode":"if (typeof (exporter as any).getMetricsByName !== 'function') {\n  throw new Error('TestExporter version without getMetricsByName; upgrade before using name-based filtering.');\n}","typeGuard":"function supportsGetMetricsByName(e: unknown): e is { getMetricsByName(name: string): unknown[] } {\n  return typeof e === 'object' && e !== null && typeof (e as any).getMetricsByName === 'function';\n}","tryCatchPattern":"let metrics: ExportedMetric[];\ntry {\n  metrics = exporter.getMetricsByName('my.metric');\n} catch (err) {\n  if ((err as Error).message.startsWith('getMetricsByType() has been removed')) {\n    metrics = []; // migrate call site\n  } else throw err;\n}","preventionTips":["Search the codebase for getMetricsByType before upgrading","Use getMetricsByName as the canonical filter API","Wrap deprecated APIs behind a small adapter you migrate in one place"],"tags":["deprecated","removed-api","metrics","migration"],"backgroundTag":"removed-api-migration","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}