apache/beam · error · UnsupportedOperationException

This runner does not currently support committed metrics res

Error message

This runner does not currently support committed metrics results. Please use 'attempted' instead.

What it means

MetricResult.getCommitted returns the runner-verified committed metric value. Many runners (especially streaming or testing runners) do not compute committed metrics and store null; in that case getCommitted throws UnsupportedOperationException and callers must use getAttempted().

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricResult.java:53

})
public abstract class MetricResult<T> {
  /** Return the name of the metric. */
  public MetricName getName() {
    return getKey().metricName();
  }

  public abstract MetricKey getKey();

  /**
   * Return the value of this metric across all successfully completed parts of the pipeline.
   *
   * <p>Not all runners will support committed metrics. If they are not supported, the runner will
   * throw an {@link UnsupportedOperationException}.
   */
  public T getCommitted() {
    T committed = getCommittedOrNull();
    if (committed == null) {
      throw new UnsupportedOperationException(
          "This runner does not currently support committed"
              + " metrics results. Please use 'attempted' instead.");
    }
    return committed;
  }

  public boolean hasCommitted() {
    return getCommittedOrNull() != null;
  }

  /** Return the value of this metric across all attempts of executing all parts of the pipeline. */
  public abstract @Nullable T getCommittedOrNull();

  /** Return the value of this metric across all attempts of executing all parts of the pipeline. */
  public abstract T getAttempted();

  public <V> MetricResult<V> transform(Function<T, V> fn) {
    T committed = getCommittedOrNull();

View on GitHub (pinned to 12126d8942)

Solutions

  1. Use getAttempted() instead when committed metrics are unavailable.
  2. Guard with a null check: MetricsFilter results where getCommittedOrNull() != null before calling getCommitted().
  3. Run with a runner that supports committed metrics (e.g. DirectRunner/Dataflow) if committed values are required.
  4. Treat committed as best-effort: fall back to attempted in reporting code.

Example fix

// before
long committed = result.getCommitted();
// after
Long committed = result.getCommittedOrNull();
long value = committed != null ? committed : result.getAttempted();
Defensive patterns

Strategy: fallback

Validate before calling

Long committed = result.getCommittedOrNull();

Try / catch

try { v = result.getCommitted(); } catch (UnsupportedOperationException e) { v = result.getAttempted(); }

Prevention

When it happens

Trigger: Reading metricResults().committed() on a pipeline run by a runner that doesn't support committed metrics (e.g. a runner whose MonitoringInfo rendering leaves committed null), or in unit tests with non-Direct runners.

Common situations: Test assertions on pipeline metrics against unsupported runners, monitoring dashboards reading committed values on streaming pipelines, and runner migrations where metric semantics differ.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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