{"record":{"id":"1ff5a02775f9934f","repo":"apache/beam","slug":"this-runner-does-not-currently-support-committed-metrics","errorCode":null,"errorMessage":"This runner does not currently support committed metrics results. Please use 'attempted' instead.","messagePattern":"This runner does not currently support committed metrics results\\. Please use 'attempted' instead\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricResult.java","lineNumber":53,"sourceCode":"})\npublic abstract class MetricResult<T> {\n  /** Return the name of the metric. */\n  public MetricName getName() {\n    return getKey().metricName();\n  }\n\n  public abstract MetricKey getKey();\n\n  /**\n   * Return the value of this metric across all successfully completed parts of the pipeline.\n   *\n   * <p>Not all runners will support committed metrics. If they are not supported, the runner will\n   * throw an {@link UnsupportedOperationException}.\n   */\n  public T getCommitted() {\n    T committed = getCommittedOrNull();\n    if (committed == null) {\n      throw new UnsupportedOperationException(\n          \"This runner does not currently support committed\"\n              + \" metrics results. Please use 'attempted' instead.\");\n    }\n    return committed;\n  }\n\n  public boolean hasCommitted() {\n    return getCommittedOrNull() != null;\n  }\n\n  /** Return the value of this metric across all attempts of executing all parts of the pipeline. */\n  public abstract @Nullable T getCommittedOrNull();\n\n  /** Return the value of this metric across all attempts of executing all parts of the pipeline. */\n  public abstract T getAttempted();\n\n  public <V> MetricResult<V> transform(Function<T, V> fn) {\n    T committed = getCommittedOrNull();","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricResult.java#L35-L71","documentation":"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().","triggerScenarios":"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.","commonSituations":"Test assertions on pipeline metrics against unsupported runners, monitoring dashboards reading committed values on streaming pipelines, and runner migrations where metric semantics differ.","solutions":["Use getAttempted() instead when committed metrics are unavailable.","Guard with a null check: MetricsFilter results where getCommittedOrNull() != null before calling getCommitted().","Run with a runner that supports committed metrics (e.g. DirectRunner/Dataflow) if committed values are required.","Treat committed as best-effort: fall back to attempted in reporting code."],"exampleFix":"// before\nlong committed = result.getCommitted();\n// after\nLong committed = result.getCommittedOrNull();\nlong value = committed != null ? committed : result.getAttempted();","handlingStrategy":"fallback","validationCode":"Long committed = result.getCommittedOrNull();","typeGuard":null,"tryCatchPattern":"try { v = result.getCommitted(); } catch (UnsupportedOperationException e) { v = result.getAttempted(); }","preventionTips":["Default to getAttempted() in reporting code","Know your runner's committed-metrics support before asserting on committed values","Use getCommittedOrNull() for explicit null handling"],"tags":["apache-beam","metrics","runner-compatibility"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}