mastra-ai/mastra · error · MastraError
OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED
OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED
Error message
This storage provider does not support batch creating metrics
What it means
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.
Source
Thrown at packages/core/src/storage/domains/observability/base.ts:432
*/
async listLogs(_args: ListLogsArgs): Promise<ListLogsResponse> {
throw new MastraError({
id: 'OBSERVABILITY_STORAGE_LIST_LOGS_NOT_IMPLEMENTED',
domain: ErrorDomain.MASTRA_OBSERVABILITY,
category: ErrorCategory.SYSTEM,
text: 'This storage provider does not support listing logs',
});
}
// ============================================================================
// Metrics
// ============================================================================
/**
* Creates multiple metric observations in a single batch.
*/
async batchCreateMetrics(_args: BatchCreateMetricsArgs): Promise<void> {
throw new MastraError({
id: 'OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED',
domain: ErrorDomain.MASTRA_OBSERVABILITY,
category: ErrorCategory.SYSTEM,
text: 'This storage provider does not support batch creating metrics',
});
}
async listMetrics(_args: ListMetricsArgs): Promise<ListMetricsResponse> {
throw new MastraError({
id: 'OBSERVABILITY_STORAGE_LIST_METRICS_NOT_IMPLEMENTED',
domain: ErrorDomain.MASTRA_OBSERVABILITY,
category: ErrorCategory.SYSTEM,
text: 'This storage provider does not support listing metrics',
});
}
async getMetricAggregate(_args: GetMetricAggregateArgs): Promise<GetMetricAggregateResponse> {
throw new MastraError({View on GitHub (pinned to 75dd419e61)
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).
Example fix
// before
await storage.batchCreateMetrics({ metrics });
// after
try {
await storage.batchCreateMetrics({ metrics });
} catch (e) {
if (e instanceof MastraError && e.id === 'OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED') {
for (const m of metrics) await storage.createMetric(m);
} else {
throw e;
}
} Defensive patterns
Strategy: try-catch
Validate before calling
const supportsBatchCreateMetrics = typeof storage.batchCreateMetrics === 'function' && storage.batchCreateMetrics !== MastraObservabilityStorage.prototype.batchCreateMetrics;
if (!supportsBatchCreateMetrics) { /* flush metrics individually or skip */ } Type guard
function supportsBatchCreateMetrics(s: unknown): s is MastraObservabilityStorage & { batchCreateMetrics: (a: BatchCreateMetricsArgs) => Promise<void> } {
return s instanceof MastraObservabilityStorage && (s as any).batchCreateMetrics !== MastraObservabilityStorage.prototype.batchCreateMetrics;
} Try / catch
try {
await storage.batchCreateMetrics({ metrics });
} catch (e) {
if (e instanceof MastraError && e.id === 'OBSERVABILITY_STORAGE_BATCH_CREATE_METRICS_NOT_IMPLEMENTED') {
for (const m of metrics) await storage.createMetric(m);
} else {
throw e;
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- OBSERVABILITY_STORAGE_BATCH_UPDATE_SPANS_NOT_IMPLEMENTED
- OBSERVABILITY_STORAGE_BATCH_CREATE_LOGS_NOT_IMPLEMENTED
- OBSERVABILITY_STORAGE_LIST_METRICS_NOT_IMPLEMENTED
- OBSERVABILITY_STORAGE_GET_METRIC_AGGREGATE_NOT_IMPLEMENTED
- OBSERVABILITY_STORAGE_GET_METRIC_BREAKDOWN_NOT_IMPLEMENTED
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/75d177d4f9084bdb.
Report an issue: GitHub.