apache/iceberg · warning
Cannot load Dropwizard metrics; is…
Error message
Cannot load Dropwizard metrics; is org.apache.flink:flink-metrics-dropwizard on the classpath?
What it means
Iceberg's Flink sink tries to construct Flink's DropwizardHistogramWrapper to expose codahale histograms as Flink metrics. This requires the optional org.apache.flink:flink-metrics-dropwizard artifact on the classpath. When the class or constructor cannot be loaded, the sink logs this warning and returns null, disabling Dropwizard-based writer metrics; writes continue normally without them.
Solutions
- Add the flink-metrics-dropwizard JAR matching your Flink version to Flink's lib/ directory (or shade it into your job jar).
- Verify the org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper class is loadable in the taskmanager classloader.
- If metrics are not needed, ignore this warning; the sink falls back to null and runs without Dropwizard histograms.
Example fix
// before (pom.xml: optional metric dependency omitted)
<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-flink-runtime-1.20</artifactId>
</dependency>
// after
<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-flink-runtime-1.20</artifactId>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-metrics-dropwizard</artifactId>
<version>${flink.version}</version>
</dependency> Defensive patterns
Strategy: validation
Validate before calling
try {
Class.forName("org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper");
} catch (ClassNotFoundException e) {
LOG.info("flink-metrics-dropwizard not on classpath; writer histograms disabled");
} Prevention
- Ship flink-metrics-dropwizard with your Flink deployment (lib/) in every environment.
- Keep optional metric dependency versions aligned with the Flink version.
- Treat this warning as expected-and-harmless if Dropwizard metrics are intentionally disabled.
When it happens
Trigger: IcebergStreamWriterMetrics.loadDropwizardCtors runs DynConstructors.builder(Histogram.class).impl("org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper", codahaleHistogramClass).buildChecked() and catches ClassNotFoundException/NoSuchMethodException when flink-metrics-dropwizard is absent or its version is incompatible with the codahale Histogram class.
Common situations: Deploying the Iceberg Flink sink JAR without the metrics connector JAR in Flink's lib/ directory; using a shaded/uber job jar that excludes optional Flink metrics dependencies; Flink distribution upgrades where metrics-dropwizard was not carried over.
Understand the failure class
Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.
Related errors
- Cannot load Dropwizard metrics; is…
- Cannot load Dropwizard metrics; is…
- Cannot load Dropwizard metrics; is…
- Class does not implement DynamicRecordGeneratorSQL
- Could not deserialize the WriteResult object
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/50dc2ecae5b71f82.
Report an issue: GitHub.
Appendix: source
Thrown at flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/IcebergStreamWriterMetrics.java:150
try {
Class<?> reservoirInterface =
DynClasses.builder().impl("com.codahale.metrics.Reservoir").buildChecked();
Class<?> codahaleHistogramClass =
DynClasses.builder().impl("com.codahale.metrics.Histogram").buildChecked();
return new DropwizardCtors(
DynConstructors.builder()
.impl("com.codahale.metrics.SlidingWindowReservoir", int.class)
.buildChecked(),
DynConstructors.builder()
.impl("com.codahale.metrics.Histogram", reservoirInterface)
.buildChecked(),
DynConstructors.builder(Histogram.class)
.impl(
"org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper",
codahaleHistogramClass)
.buildChecked());
} catch (ClassNotFoundException | NoSuchMethodException e) {
LOG.warn(
"Cannot load Dropwizard metrics; is org.apache.flink:flink-metrics-dropwizard on the classpath?",
e);
return null;
}
}
private record DropwizardCtors(
DynConstructors.Ctor<?> reservoirCtor,
DynConstructors.Ctor<?> histogramCtor,
DynConstructors.Ctor<Histogram> wrapperCtor) {}
}
View on GitHub (pinned to 86d9c8fc54)