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
A warning emitted when the Iceberg writer's Dropwizard-based histogram metrics cannot be initialized because the flink-metrics-dropwizard module (or its Codahale/Dropwizard metrics classes) is not on the classpath. Metrics are disabled (returns null) but the write itself continues normally.
Solutions
- Add org.apache.flink:flink-metrics-dropwizard to the job's classpath (drop it in Flink's lib/ or ship it with the user jar)
- If metrics are not needed, ignore the warning — the writer works without the histogram
- Check the Flink version's package location for DropwizardHistogramWrapper if the dependency is present but still failing
Example fix
// build.gradle
// before: (no metrics dep)
// after
implementation("org.apache.flink:flink-metrics-dropwizard:1.18.1") Defensive patterns
Strategy: fallback
Validate before calling
try {
Class.forName("org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper");
} catch (ClassNotFoundException e) {
// dropwizard metrics unavailable; proceed without histograms
} Prevention
- Ship flink-metrics-dropwizard with deployment artifacts
- Verify optional metrics plugins in the base Flink image
- Document that writer histograms are optional
When it happens
Trigger: Running a Flink job whose IcebergStreamWriterMetrics tries to construct org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper via DynConstructors, throwing ClassNotFoundException/NoSuchMethodException because the flink-metrics-dropwizard jar is absent.
Common situations: Deploying to a slim Flink distribution without optional metrics plugins; fat jars that exclude optional dependencies; Flink versions where the Dropwizard wrapper package moved.
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/a2021d960dd299d5.
Report an issue: GitHub.
Appendix: source
Thrown at flink/v2.3/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)