{"record":{"id":"75d177d4f9084bdb","repo":"mastra-ai/mastra","slug":"observability-storage-batch-create-metrics-not-imp","errorCode":"OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED","errorMessage":"This storage provider does not support batch creating metrics","messagePattern":"This storage provider does not support batch creating metrics","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/observability/base.ts","lineNumber":432,"sourceCode":"   */\n  async listLogs(_args: ListLogsArgs): Promise<ListLogsResponse> {\n    throw new MastraError({\n      id: 'OBSERVABILITY_STORAGE_LIST_LOGS_NOT_IMPLEMENTED',\n      domain: ErrorDomain.MASTRA_OBSERVABILITY,\n      category: ErrorCategory.SYSTEM,\n      text: 'This storage provider does not support listing logs',\n    });\n  }\n\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({","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/observability/base.ts#L414-L450","documentation":"This error is thrown by the base MastraObservabilityStorage class's batchCreateMetrics method, a default implementation that always throws. It means the storage provider has not implemented persisting multiple metric observations in a single batch. The library throws to signal the optional capability is unavailable rather than silently dropping metrics.","triggerScenarios":"Calling storage.batchCreateMetrics(args) (BatchCreateMetricsArgs) on a provider that inherits the base default, e.g. an OpenTelemetry-style metrics exporter flushing a batch of observations through the observability storage domain.","commonSituations":"Enabling metrics collection with a minimal storage adapter that only supports traces/spans; a custom driver extending the base class without overriding batch methods; buffered metric exporters that assume batch writes are supported; upgrading to a Mastra version that routes metrics through the batch API while the provider lags behind.","solutions":["Switch to a storage provider that implements batchCreateMetrics.","Fall back to creating metric observations one at a time via the single-record create API if available.","If you own the provider, override batchCreateMetrics with a bulk insert.","Catch this error in the metrics flush loop and fall back to sequential writes (or skip with a warning if metrics are best-effort)."],"exampleFix":"// before\nawait storage.batchCreateMetrics({ metrics });\n// after\ntry {\n  await storage.batchCreateMetrics({ metrics });\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED') {\n    for (const m of metrics) await storage.createMetric(m);\n  } else {\n    throw e;\n  }\n}","handlingStrategy":"try-catch","validationCode":"const supportsBatchCreateMetrics = typeof storage.batchCreateMetrics === 'function' && storage.batchCreateMetrics !== MastraObservabilityStorage.prototype.batchCreateMetrics;\nif (!supportsBatchCreateMetrics) { /* flush metrics individually or skip */ }","typeGuard":"function supportsBatchCreateMetrics(s: unknown): s is MastraObservabilityStorage & { batchCreateMetrics: (a: BatchCreateMetricsArgs) => Promise<void> } {\n  return s instanceof MastraObservabilityStorage && (s as any).batchCreateMetrics !== MastraObservabilityStorage.prototype.batchCreateMetrics;\n}","tryCatchPattern":"try {\n  await storage.batchCreateMetrics({ metrics });\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED') {\n    for (const m of metrics) await storage.createMetric(m);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Confirm metric support in the storage provider before enabling metrics collection/export.","Instantiate a concrete provider with the metrics domain implemented, not the base class.","Feature-detect batchCreateMetrics against the base prototype before flushing batches.","Implement batchCreateMetrics with a bulk insert in custom providers.","Treat metrics as best-effort: catch the error and fall back to sequential writes with a warning."],"tags":["storage","observability","not-implemented","metrics","batch"],"backgroundTag":"storage-method-not-implemented","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}