apache/beam · error · UnsupportedOperationException

BeamAccumulatorProvider doesn't support getCounter(String…

Error message

BeamAccumulatorProvider doesn't support getCounter(String name). Please specify namespace and name.

What it means

BeamAccumulatorProvider is a metrics (accumulator) provider backed by Beam's Metrics API, which requires metrics to be identified by both a namespace and a name. The single-name getCounter(String) overload is intentionally unsupported and always throws UnsupportedOperationException, directing callers to getCounter(namespace, name).

Solutions

  1. Call getCounter(namespace, name) instead, supplying a namespace (e.g. the operator or step name).
  2. In runner-agnostic code, branch on the backend and use the two-argument form when running on Beam.
  3. If name-only API must work, implement a wrapper provider that injects a default namespace before delegating.

Example fix

// before
Counter c = accumulatorProvider.getCounter("requests");
// after
Counter c = accumulatorProvider.getCounter("myOperator", "requests");
Defensive patterns

Strategy: try-catch

Try / catch

try {
  counter = provider.getCounter(name);
} catch (UnsupportedOperationException e) {
  counter = provider.getCounter(defaultNamespace, name);
}

Prevention

When it happens

Trigger: Calling new BeamAccumulatorProvider(...).getCounter("someName") — i.e. using the name-only Counter lookup — anywhere in code executing under the Beam runner.

Common situations: Porting code written against a Flink/Spark accumulator provider that supports name-only lookups to the Beam backend; shared pipeline code that branches on the runner and calls the wrong overload.

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/2f7897567f42a6e5. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/extensions/euphoria/src/main/java/org/apache/beam/sdk/extensions/euphoria/core/translate/BeamAccumulatorProvider.java:56

 */
@Deprecated
public class BeamAccumulatorProvider implements AccumulatorProvider {

  private static final Logger LOG = LoggerFactory.getLogger(BeamAccumulatorProvider.class);
  private static final String KEY_METRIC_SEPARATOR = "::";

  private final Map<String, Counter> counterMap = new ConcurrentHashMap<>();
  private final Map<String, Histogram> histogramMap = new ConcurrentHashMap<>();

  private BeamAccumulatorProvider() {}

  public static Factory getFactory() {
    return Factory.get();
  }

  @Override
  public Counter getCounter(String name) {
    throw new UnsupportedOperationException(
        "BeamAccumulatorProvider doesn't support"
            + " getCounter(String name). Please specify namespace and name.");
  }

  @Override
  public Counter getCounter(final String namespace, final String name) {
    return counterMap.computeIfAbsent(
        getMetricsKey(namespace, name), key -> new BeamMetricsCounter(namespace, name));
  }

  @Override
  public Histogram getHistogram(String name) {
    throw new UnsupportedOperationException(
        "BeamAccumulatorProvider doesn't support"
            + " getHistogram(String name). Please specify namespace and name.");
  }

  @Override

View on GitHub (pinned to 12126d8942)