apache/beam · error · Error

Unknown metric type

Error message

Unknown metric type: ${spec.metricType}

What it means

createMetric looked up spec.metricType in the metricTypes registry (the map of supported MonitoringInfo metric types to MetricCell constructors) and found no entry. The metricType string on the MetricSpec is the input at fault: the runner sent or the SDK produced a metric kind this worker cannot instantiate.

Solutions

  1. Compare the printed metricType against the keys registered in metricTypes and fix whichever side (runner protocol or SDK version) is out of date.
  2. Upgrade the TypeScript SDK so newly defined metric types are recognized.
  3. Filter unknown specs before calling getMetric if you control the producer and only known types matter.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at sdks/typescript/src/apache_beam/worker/metrics.ts:295 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/d03cfafb3ab02af4. Report an issue: GitHub.

Appendix: source

Thrown at sdks/typescript/src/apache_beam/worker/metrics.ts:295

        .filter((metric) => metric.is_set)
        .map((metric) => [
          shortIdCache.getShortId(metric),
          metric.value.payload(),
        ]),
    );
  }

  reset(): void {
    for (const [_, cell] of this.metrics) {
      cell.reset();
    }
  }
}

function createMetric(spec: MetricSpec): MetricCell<unknown> {
  const constructor = metricTypes.get(spec.metricType);
  if (constructor === undefined) {
    throw new Error("Unknown metric type: " + spec.metricType);
  }
  return constructor(spec);
}

export class MetricsShortIdCache {
  private idToInfo = new Map<string, MonitoringInfo>();
  private keyToId = new Map<string, string>();

  getShortId(metric: ScopedMetricCell<unknown>): string {
    var shortId = this.keyToId.get(metric.key);
    if (shortId === undefined) {
      shortId = "m" + this.keyToId.size;
      this.idToInfo.set(shortId, metric.toEmptyMonitoringInfo());
      this.keyToId.set(metric.key, shortId);
    }
    return shortId;
  }

View on GitHub (pinned to 12126d8942)