openzipkin/zipkin · error · NullPointerException
metrics == null
Error message
metrics == null
What it means
ScribeCollector.Builder.metrics(CollectorMetrics) throws NullPointerException when metrics is null. The metrics instance is scoped to the 'scribe' transport and passed through to the delegate Collector; the builder requires it non-null at configuration time. Omitting the call is fine — the builder defaults to NOOP metrics.
Source
Thrown at zipkin-collector/scribe/src/main/java/zipkin2/collector/scribe/ScribeCollector.java:39
public static Builder newBuilder() {
return new Builder();
}
/** Configuration including defaults needed to receive spans from a Scribe category. */
public static final class Builder extends CollectorComponent.Builder {
Collector.Builder delegate = Collector.newBuilder(ScribeCollector.class);
CollectorMetrics metrics = CollectorMetrics.NOOP_METRICS;
String category = "zipkin";
int port = 9410;
@Override public Builder storage(StorageComponent storage) {
delegate.storage(storage);
return this;
}
@Override public Builder metrics(CollectorMetrics metrics) {
if (metrics == null) throw new NullPointerException("metrics == null");
this.metrics = metrics.forTransport("scribe");
delegate.metrics(this.metrics);
return this;
}
@Override public Builder sampler(CollectorSampler sampler) {
delegate.sampler(sampler);
return this;
}
/** Category zipkin spans will be consumed from. Defaults to "zipkin" */
public Builder category(String category) {
if (category == null) throw new NullPointerException("category == null");
this.category = category;
return this;
}
/** The port to listen on. Defaults to 9410 */View on GitHub (pinned to 878ce2a1fa)
Solutions
- Pass CollectorMetrics.NOOP_METRICS or a real metrics implementation
- Provide a default CollectorMetrics bean in the DI container
- Do not call metrics() at all to keep the NOOP default
Example fix
// before builder.metrics(enabled ? metricsImpl : null); // after builder.metrics(enabled ? metricsImpl : CollectorMetrics.NOOP_METRICS);
Defensive patterns
Strategy: validation
Validate before calling
builder.metrics(metrics != null ? metrics : CollectorMetrics.NOOP_METRICS);
Prevention
- Use NOOP_METRICS instead of null for 'no metrics'
- Provide a DI default for CollectorMetrics
When it happens
Trigger: Calling .metrics(null) — typically a DI wiring path where no CollectorMetrics bean exists, or a conditional that uses null to mean 'metrics disabled'.
Common situations: Custom server bootstrap code where metrics are optional and null is used as a sentinel.
Related errors
AI-assisted analysis of openzipkin/zipkin@878ce2a1fa (2026-08-14).
Data as JSON: /api/errors/2a94ea03e8f74bb8.
Report an issue: GitHub.