{"record":{"id":"c77b05b875c643db","repo":"mastra-ai/mastra","slug":"observability-storage-list-metrics-not-implemented","errorCode":"OBSERVABILITY_STORAGE_LIST_METRICS_NOT_IMPLEMENTED","errorMessage":"This storage provider does not support listing metrics","messagePattern":"This storage provider does not support listing metrics","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/observability/base.ts","lineNumber":441,"sourceCode":"\n  // ============================================================================\n  // Metrics\n  // ============================================================================\n\n  /**\n   * Creates multiple metric observations in a single batch.\n   */\n  async batchCreateMetrics(_args: BatchCreateMetricsArgs): Promise<void> {\n    throw new MastraError({\n      id: 'OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED',\n      domain: ErrorDomain.MASTRA_OBSERVABILITY,\n      category: ErrorCategory.SYSTEM,\n      text: 'This storage provider does not support batch creating metrics',\n    });\n  }\n\n  async listMetrics(_args: ListMetricsArgs): Promise<ListMetricsResponse> {\n    throw new MastraError({\n      id: 'OBSERVABILITY_STORAGE_LIST_METRICS_NOT_IMPLEMENTED',\n      domain: ErrorDomain.MASTRA_OBSERVABILITY,\n      category: ErrorCategory.SYSTEM,\n      text: 'This storage provider does not support listing metrics',\n    });\n  }\n\n  async getMetricAggregate(_args: GetMetricAggregateArgs): Promise<GetMetricAggregateResponse> {\n    throw new MastraError({\n      id: 'OBSERVABILITY_STORAGE_GET_METRIC_AGGREGATE_NOT_IMPLEMENTED',\n      domain: ErrorDomain.MASTRA_OBSERVABILITY,\n      category: ErrorCategory.SYSTEM,\n      text: 'This storage provider does not support metric aggregation',\n    });\n  }\n\n  async getMetricBreakdown(_args: GetMetricBreakdownArgs): Promise<GetMetricBreakdownResponse> {\n    throw new MastraError({","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/observability/base.ts#L423-L459","documentation":"MastraError OBSERVABILITY_STORAGE_LIST_METRICS_NOT_IMPLEMENTED is thrown by the abstract base class MastraStorage observability domain (packages/core/src/storage/domains/observability/base.ts:441) from listMetrics(). Storage adapters inherit this default implementation and it always throws; it fires when the configured storage provider does not implement observability metrics listing. It signals an adapter capability gap, not bad input from the caller.","triggerScenarios":"Calling listMetrics() (directly, or via Mastra observability APIs / Studio UI that enumerate metrics) on a storage adapter that has not overridden listMetrics — e.g. legacy or minimal providers like LibSQL/InMemory/D1-style adapters configured without metrics support.","commonSituations":"Developer wires a storage adapter that only implements traces/logs, then opens the metrics view in Mastra Studio or runs an observability query; upgrading Mastra where metrics APIs were added but the installed storage adapter (or a custom MastraStorage subclass) predates them; writing a custom storage adapter and forgetting to implement listMetrics.","solutions":["Switch to a storage adapter that implements the observability metrics domain (e.g. PostgreSQL/up-to-date official adapters) or upgrade the storage adapter package to the latest version.","Verify how listMetrics is being invoked (custom code vs Studio UI); if the UI is hitting it, disable the metrics feature or point the server at a metrics-capable storage.","If you wrote a custom MastraStorage subclass, implement listMetrics to return your provider's data (or an empty ListMetricsResponse) instead of inheriting the throwing default.","Feature-detect before calling: check whether the storage instance overrides listMetrics and show a 'not supported' state instead of crashing."],"exampleFix":"// before\nconst storage = new MinimalStorage(config); // no metrics support\nawait storage.listMetrics({}); // throws OBSERVABILITY_STORAGE_LIST_METRICS_NOT_IMPLEMENTED\n// after\nconst storage = new PostgresStore(config); // adapter implementing metrics domain\nawait storage.listMetrics({}); // returns ListMetricsResponse","handlingStrategy":"fallback","validationCode":"import { MastraStorage } from '@mastra/core/storage';\n\nfunction supportsListMetrics(storage: unknown): boolean {\n  return (\n    storage instanceof MastraStorage &&\n    (storage as MastraStorage).listMetrics !== MastraStorage.prototype.listMetrics\n  );\n}\n\nif (!supportsListMetrics(storage)) {\n  console.warn('Storage adapter does not support metric listing; skipping metrics view');\n}","typeGuard":"function supportsListMetrics(s: unknown): s is MastraStorage & { listMetrics: (a: ListMetricsArgs) => Promise<ListMetricsResponse> } {\n  return s instanceof MastraStorage && s.listMetrics !== MastraStorage.prototype.listMetrics;\n}","tryCatchPattern":"import { MastraError } from '@mastra/core/error';\n\ntry {\n  const metrics = await storage.listMetrics(args);\n} catch (err) {\n  if (err instanceof MastraError && err.id === 'OBSERVABILITY_STORAGE_LIST_METRICS_NOT_IMPLEMENTED') {\n    const metrics = { metrics: [] } as ListMetricsResponse; // graceful empty fallback\n  } else {\n    throw err;\n  }\n}","preventionTips":["Check the adapter's observability/metrics support matrix before choosing a storage provider.","Keep @mastra/core and the storage adapter package versions in lockstep.","When writing a custom MastraStorage subclass, override all metrics methods you intend to support and audit the rest.","Feature-detect listMetrics against MastraStorage.prototype before wiring metrics UI or jobs.","Add an integration test asserting which observability methods your adapter implements."],"tags":["storage","observability","metrics","not-implemented"],"backgroundTag":"storage-capability-not-implemented","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}