{"record":{"id":"94f249eeaef558d0","repo":"apache/iceberg","slug":"unable-to-load-metrics-class-falling-back-t-94f249","errorCode":null,"errorMessage":"Unable to load metrics class: '{}', falling back to null metrics","messagePattern":"Unable to load metrics class: '(.+?)', falling back to null metrics","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSFileIO.java","lineNumber":188,"sourceCode":"    initMetrics(properties);\n    this.azureProperties\n        .vendedAdlsCredentialProvider()\n        .ifPresent(provider -> this.vendedAdlsCredentialProvider = provider);\n  }\n\n  @SuppressWarnings(\"CatchBlockLogException\")\n  private void initMetrics(Map<String, String> props) {\n    // Report Hadoop metrics if Hadoop is available\n    try {\n      DynConstructors.Ctor<MetricsContext> ctor =\n          DynConstructors.builder(MetricsContext.class)\n              .hiddenImpl(DEFAULT_METRICS_IMPL, String.class)\n              .buildChecked();\n      MetricsContext context = ctor.newInstance(\"adls\");\n      context.initialize(props);\n      this.metrics = context;\n    } catch (NoClassDefFoundError | NoSuchMethodException | ClassCastException e) {\n      LOG.warn(\n          \"Unable to load metrics class: '{}', falling back to null metrics\", DEFAULT_METRICS_IMPL);\n    }\n  }\n\n  @Override\n  public void deleteFiles(Iterable<String> pathsToDelete) throws BulkDeletionFailureException {\n    // Azure batch operations are not supported in all cases, e.g. with a user\n    // delegation SAS token, so avoid using it for now\n\n    AtomicInteger failureCount = new AtomicInteger();\n    Tasks.foreach(pathsToDelete)\n        .executeWith(ThreadPools.getWorkerPool())\n        .noRetry()\n        .suppressFailureWhenFinished()\n        .onFailure(\n            (file, exc) -> {\n              failureCount.incrementAndGet();\n              LOG.warn(\"Failed to delete file {}\", file, exc);","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/azure/src/main/java/org/apache/iceberg/azure/adlsv2/ADLSFileIO.java#L170-L206","documentation":"ADLSFileIO.initMetrics() reflectively constructs the ADLS metrics context class at initialize(). If the class is missing (NoClassDefFoundError), has no matching constructor, or doesn't implement MetricsContext, it warns and falls back to null metrics — the FileIO still works, just without metrics instrumentation.","triggerScenarios":"Initializing ADLSFileIO without the metrics implementation on the classpath (e.g. the module providing DEFAULT_METRICS_IMPL is excluded), or with an incompatible version whose constructor signature changed.","commonSituations":"Shaded/minimal deployments missing the metrics module; dependency conflicts after upgrades; custom classpaths in Spark/Flink distributions.","solutions":["Add the module providing the default metrics implementation to the classpath","Check for dependency shading/conflicts that drop the metrics classes","Align library versions so the constructor signature matches what ADLSFileIO expects","If metrics are intentionally unwanted, ignore the warning"],"exampleFix":"// before (gradle)\nimplementation 'org.apache.iceberg:iceberg-azure'\n// after\nimplementation 'org.apache.iceberg:iceberg-azure'\nimplementation 'org.apache.iceberg:iceberg-azure-bundle' // pulls metrics impl","handlingStrategy":"fallback","validationCode":"try {\n  Class.forName(\"org.apache.iceberg.metrics.LoggingMetricsContext\");\n} catch (ClassNotFoundException e) {\n  LOG.warn(\"ADLS metrics impl missing from classpath; add iceberg-azure-bundle\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ship the bundle/jar containing the metrics implementation with the app","Verify shaded jars retain the metrics classes","Accept the null-metrics fallback only when instrumentation is intentionally disabled"],"tags":["azure","adls","metrics","reflection","class-not-found"],"backgroundTag":"class-not-found","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"}