{"record":{"id":"954147433b150c08","repo":"apache/iceberg","slug":"histogram-is-not-supported","errorCode":null,"errorMessage":"Histogram is not supported.","messagePattern":"Histogram is not supported\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/metrics/MetricsContext.java","lineNumber":153,"sourceCode":"   * @return a {@link org.apache.iceberg.metrics.Counter} implementation\n   */\n  default org.apache.iceberg.metrics.Counter counter(String name) {\n    return counter(name, Unit.COUNT);\n  }\n\n  /**\n   * Get a named timer.\n   *\n   * @param name name of the metric\n   * @param unit the time unit designation of the metric\n   * @return a timer implementation\n   */\n  default Timer timer(String name, TimeUnit unit) {\n    throw new UnsupportedOperationException(\"Timer is not supported.\");\n  }\n\n  default Histogram histogram(String name) {\n    throw new UnsupportedOperationException(\"Histogram is not supported.\");\n  }\n\n  /**\n   * Utility method for producing no metrics.\n   *\n   * @return a non-recording metrics context\n   */\n  static MetricsContext nullMetrics() {\n    return new MetricsContext() {\n\n      @Override\n      public Timer timer(String name, TimeUnit unit) {\n        return Timer.NOOP;\n      }\n\n      @Override\n      @SuppressWarnings(\"unchecked\")\n      public <T extends Number> Counter<T> counter(String name, Class<T> type, Unit unit) {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/metrics/MetricsContext.java#L135-L171","documentation":"MetricsContext.histogram(String) is a default stub throwing UnsupportedOperationException('Histogram is not supported.'). The base interface offers no histogram support by default; implementations must override it to provide one.","triggerScenarios":"Calling histogram(name) on a MetricsContext that doesn't override it, then recording values into the histogram.","commonSituations":"Custom MetricsContext implementations lacking histogram support; code assuming all contexts (including minimal test contexts) provide histograms.","solutions":["Use a MetricsContext implementation that overrides histogram()","Override histogram(String) in your custom context","If histograms aren't needed, avoid calling this method or return a NOOP histogram","Feature-check before requesting a histogram"],"exampleFix":"// before\nHistogram h = ctx.histogram(\"distribution\"); // throws\n// after\nHistogram h = supportedContext.histogram(\"distribution\");","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { histogram } catch (UnsupportedOperationException e) { skip }","preventionTips":["Override histogram() where needed","Capability-check before use"],"tags":["java","metrics","histogram","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}