mastra-ai/mastra · error · MastraError

OBSERVABILITY_STORAGE_GET_METRIC_PERCENTILES_NOT_IMPLEMENTED

OBSERVABILITY_STORAGE_GET_METRIC_PERCENTILES_NOT_IMPLEMENTED

Error message

This storage provider does not support metric percentiles

What it means

MastraError OBSERVABILITY_STORAGE_GET_METRIC_PERCENTILES_NOT_IMPLEMENTED is thrown by the default getMetricPercentiles() in the observability storage base class (packages/core/src/storage/domains/observability/base.ts:477). It means the storage adapter does not implement percentile (p50/p90/p99-style) metric queries. Like its sibling methods, the base implementation always throws so unsupported providers fail loudly with a typed MastraError.

Source

Thrown at packages/core/src/storage/domains/observability/base.ts:477

    throw new MastraError({
      id: 'OBSERVABILITY_STORAGE_GET_METRIC_BREAKDOWN_NOT_IMPLEMENTED',
      domain: ErrorDomain.MASTRA_OBSERVABILITY,
      category: ErrorCategory.SYSTEM,
      text: 'This storage provider does not support metric breakdown',
    });
  }

  async getMetricTimeSeries(_args: GetMetricTimeSeriesArgs): Promise<GetMetricTimeSeriesResponse> {
    throw new MastraError({
      id: 'OBSERVABILITY_STORAGE_GET_METRIC_TIME_SERIES_NOT_IMPLEMENTED',
      domain: ErrorDomain.MASTRA_OBSERVABILITY,
      category: ErrorCategory.SYSTEM,
      text: 'This storage provider does not support metric time series',
    });
  }

  async getMetricPercentiles(_args: GetMetricPercentilesArgs): Promise<GetMetricPercentilesResponse> {
    throw new MastraError({
      id: 'OBSERVABILITY_STORAGE_GET_METRIC_PERCENTILES_NOT_IMPLEMENTED',
      domain: ErrorDomain.MASTRA_OBSERVABILITY,
      category: ErrorCategory.SYSTEM,
      text: 'This storage provider does not support metric percentiles',
    });
  }

  // ============================================================================
  // Discovery / Metadata Methods
  // ============================================================================

  async getMetricNames(_args: GetMetricNamesArgs): Promise<GetMetricNamesResponse> {
    throw new MastraError({
      id: 'OBSERVABILITY_STORAGE_GET_METRIC_NAMES_NOT_IMPLEMENTED',
      domain: ErrorDomain.MASTRA_OBSERVABILITY,
      category: ErrorCategory.SYSTEM,
      text: 'This storage provider does not support metric name discovery',
    });

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Switch to or upgrade a storage adapter that implements getMetricPercentiles (e.g. PostgreSQL-based adapters).
  2. If percentiles are not essential, drop the percentile query/panel or replace it with an aggregate the adapter supports.
  3. For a custom adapter, implement getMetricPercentiles (compute quantiles over stored observations) or return an explicit empty response.
  4. Check capabilities at startup (method override check) and disable percentile-dependent features before users hit the error.

Example fix

// before
const pct = await storage.getMetricPercentiles({ metricName: 'llm_latency', percentiles: [50, 95, 99] }); // throws
// after
const pct = supportsMetricPercentiles(storage)
  ? await storage.getMetricPercentiles({ metricName: 'llm_latency', percentiles: [50, 95, 99] })
  : null;
Defensive patterns

Strategy: fallback

Validate before calling

import { MastraStorage } from '@mastra/core/storage';

function supportsMetricPercentiles(storage: unknown): boolean {
  return (
    storage instanceof MastraStorage &&
    (storage as MastraStorage).getMetricPercentiles !== MastraStorage.prototype.getMetricPercentiles
  );
}

if (!supportsMetricPercentiles(storage)) {
  console.warn('Metric percentiles unsupported by this storage adapter');
}

Type guard

function supportsMetricPercentiles(s: unknown): s is MastraStorage & { getMetricPercentiles: (a: GetMetricPercentilesArgs) => Promise<GetMetricPercentilesResponse> } {
  return s instanceof MastraStorage && s.getMetricPercentiles !== MastraStorage.prototype.getMetricPercentiles;
}

Try / catch

import { MastraError } from '@mastra/core/error';

try {
  const pct = await storage.getMetricPercentiles(args);
} catch (err) {
  if (err instanceof MastraError && err.id === 'OBSERVABILITY_STORAGE_GET_METRIC_PERCENTILES_NOT_IMPLEMENTED') {
    const pct = null; // hide percentile panel instead of failing
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Calling getMetricPercentiles(args) on a storage adapter that has not overridden it — e.g. requesting latency percentiles through the metrics API or Studio metrics view.

Common situations: Requesting p50/p95/p99 latency panels in Studio against an adapter without percentile support; custom storage adapter missing getMetricPercentiles; version skew between @mastra/core and the storage adapter after percentile APIs shipped.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/ec0c75b44b0b2f5f. Report an issue: GitHub.