{"record":{"id":"eccb48f32ffd2fb4","repo":"mastra-ai/mastra","slug":"observability-storage-get-metric-aggregate-not-imp","errorCode":"OBSERVABILITY_STORAGE_GET_METRIC_AGGREGATE_NOT_IMPLEMENTED","errorMessage":"This storage provider does not support metric aggregation","messagePattern":"This storage provider does not support metric aggregation","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/observability/base.ts","lineNumber":450,"sourceCode":"    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({\n      id: 'OBSERVABILITY_STORAGE_GET_METRIC_BREAKDOWN_NOT_IMPLEMENTED',\n      domain: ErrorDomain.MASTRA_OBSERVABILITY,\n      category: ErrorCategory.SYSTEM,\n      text: 'This storage provider does not support metric breakdown',\n    });\n  }\n\n  async getMetricTimeSeries(_args: GetMetricTimeSeriesArgs): Promise<GetMetricTimeSeriesResponse> {\n    throw new MastraError({","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/observability/base.ts#L432-L468","documentation":"MastraError OBSERVABILITY_STORAGE_GET_METRIC_AGGREGATE_NOT_IMPLEMENTED is thrown by the default getMetricAggregate() implementation in the observability storage base class (packages/core/src/storage/domains/observability/base.ts:450). It indicates the active storage adapter does not implement metric aggregation (e.g. sum/count/avg over metric observations). The base class throws for every unimplemented method so adapters only need to override what they support.","triggerScenarios":"Calling getMetricAggregate(args) on a storage adapter that has not overridden it — typically through the metrics API/Studio metric summary view while connected to a provider lacking metrics aggregation support.","commonSituations":"Requesting an aggregate (count/sum/avg) for a metric in Studio against an adapter that only stores spans; custom MastraStorage subclass missing getMetricAggregate; mixing a newer core version that queries aggregates with an older storage package.","solutions":["Use a storage adapter that implements getMetricAggregate or upgrade the existing adapter package to a version that does.","Change storage configuration to a metrics-capable provider (e.g. PostgreSQL) if you need metric aggregates.","If you own a custom adapter, implement getMetricAggregate returning the computed GetMetricAggregateResponse for your backend.","Guard the call site: detect missing support (instance does not override getMetricAggregate) and return null/empty instead of throwing."],"exampleFix":"// before\nawait storage.getMetricAggregate({ metricName: 'agent_tokens' }); // throws\n// after\nconst aggregate = storage.getMetricAggregate !== MastraStorage.prototype.getMetricAggregate\n  ? await storage.getMetricAggregate({ metricName: 'agent_tokens' })\n  : null;","handlingStrategy":"fallback","validationCode":"import { MastraStorage } from '@mastra/core/storage';\n\nfunction supportsMetricAggregate(storage: unknown): boolean {\n  return (\n    storage instanceof MastraStorage &&\n    (storage as MastraStorage).getMetricAggregate !== MastraStorage.prototype.getMetricAggregate\n  );\n}\n\nif (!supportsMetricAggregate(storage)) {\n  console.warn('Aggregate metric queries unsupported by this storage adapter');\n}","typeGuard":"function supportsMetricAggregate(s: unknown): s is MastraStorage & { getMetricAggregate: (a: GetMetricAggregateArgs) => Promise<GetMetricAggregateResponse> } {\n  return s instanceof MastraStorage && s.getMetricAggregate !== MastraStorage.prototype.getMetricAggregate;\n}","tryCatchPattern":"import { MastraError } from '@mastra/core/error';\n\ntry {\n  const agg = await storage.getMetricAggregate(args);\n} catch (err) {\n  if (err instanceof MastraError && err.id === 'OBSERVABILITY_STORAGE_GET_METRIC_AGGREGATE_NOT_IMPLEMENTED') {\n    const agg = null; // render 'aggregates unavailable' instead of failing\n  } else {\n    throw err;\n  }\n}","preventionTips":["Verify the provider implements metric aggregation (sum/count/avg) before building dashboards on it.","Pin matching versions of @mastra/core and the storage adapter to avoid capability skew.","Override getMetricAggregate in custom adapters, or intentionally return an empty response.","Add a startup capability probe that logs which observability methods the adapter overrides.","Keep an integration test covering getMetricAggregate against your storage backend."],"tags":["storage","observability","metrics","aggregation","not-implemented"],"backgroundTag":"storage-capability-not-implemented","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}