{"record":{"id":"2f7897567f42a6e5","repo":"apache/beam","slug":"beamaccumulatorprovider-doesn-t-support-getcounter-string","errorCode":null,"errorMessage":"BeamAccumulatorProvider doesn't support getCounter(String name). Please specify namespace and name.","messagePattern":"BeamAccumulatorProvider doesn't support getCounter\\(String name\\)\\. Please specify namespace and name\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/euphoria/src/main/java/org/apache/beam/sdk/extensions/euphoria/core/translate/BeamAccumulatorProvider.java","lineNumber":56,"sourceCode":" */\n@Deprecated\npublic class BeamAccumulatorProvider implements AccumulatorProvider {\n\n  private static final Logger LOG = LoggerFactory.getLogger(BeamAccumulatorProvider.class);\n  private static final String KEY_METRIC_SEPARATOR = \"::\";\n\n  private final Map<String, Counter> counterMap = new ConcurrentHashMap<>();\n  private final Map<String, Histogram> histogramMap = new ConcurrentHashMap<>();\n\n  private BeamAccumulatorProvider() {}\n\n  public static Factory getFactory() {\n    return Factory.get();\n  }\n\n  @Override\n  public Counter getCounter(String name) {\n    throw new UnsupportedOperationException(\n        \"BeamAccumulatorProvider doesn't support\"\n            + \" getCounter(String name). Please specify namespace and name.\");\n  }\n\n  @Override\n  public Counter getCounter(final String namespace, final String name) {\n    return counterMap.computeIfAbsent(\n        getMetricsKey(namespace, name), key -> new BeamMetricsCounter(namespace, name));\n  }\n\n  @Override\n  public Histogram getHistogram(String name) {\n    throw new UnsupportedOperationException(\n        \"BeamAccumulatorProvider doesn't support\"\n            + \" getHistogram(String name). Please specify namespace and name.\");\n  }\n\n  @Override","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/euphoria/src/main/java/org/apache/beam/sdk/extensions/euphoria/core/translate/BeamAccumulatorProvider.java#L38-L74","documentation":"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).","triggerScenarios":"Calling new BeamAccumulatorProvider(...).getCounter(\"someName\") — i.e. using the name-only Counter lookup — anywhere in code executing under the Beam runner.","commonSituations":"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.","solutions":["Call getCounter(namespace, name) instead, supplying a namespace (e.g. the operator or step name).","In runner-agnostic code, branch on the backend and use the two-argument form when running on Beam.","If name-only API must work, implement a wrapper provider that injects a default namespace before delegating."],"exampleFix":"// before\nCounter c = accumulatorProvider.getCounter(\"requests\");\n// after\nCounter c = accumulatorProvider.getCounter(\"myOperator\", \"requests\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  counter = provider.getCounter(name);\n} catch (UnsupportedOperationException e) {\n  counter = provider.getCounter(defaultNamespace, name);\n}","preventionTips":["Always use the namespace+name overloads when targeting Beam.","Abstract metric creation behind a helper that takes both namespace and name.","Document backend requirements when porting Flink/Spark metrics code."],"tags":["java","unsupported-operation","metrics","euphoria"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}