openzipkin/zipkin · error · NullPointerException

metrics == null

Error message

metrics == null

What it means

RabbitMQCollector.Builder.metrics(CollectorMetrics) throws NullPointerException on a null argument. The metrics instance is scoped to the 'rabbitmq' transport and forwarded to the delegate Collector; the builder requires it non-null so metric registration can never fail later with a confusing NPE.

Source

Thrown at zipkin-collector/rabbitmq/src/main/java/zipkin2/collector/rabbitmq/RabbitMQCollector.java:66

    ConnectionFactory connectionFactory = new ConnectionFactory();
    Address[] addresses;
    int concurrency = 1;

    @Override
    public Builder storage(StorageComponent storage) {
      this.delegate.storage(storage);
      return this;
    }

    @Override
    public Builder sampler(CollectorSampler sampler) {
      this.delegate.sampler(sampler);
      return this;
    }

    @Override
    public Builder metrics(CollectorMetrics metrics) {
      if (metrics == null) throw new NullPointerException("metrics == null");
      this.metrics = metrics.forTransport("rabbitmq");
      this.delegate.metrics(this.metrics);
      return this;
    }

    public Builder addresses(List<String> addresses) {
      this.addresses = convertAddresses(addresses);
      return this;
    }

    public Builder concurrency(int concurrency) {
      this.concurrency = concurrency;
      return this;
    }

    public Builder connectionFactory(ConnectionFactory connectionFactory) {
      if (connectionFactory == null) throw new NullPointerException("connectionFactory == null");
      this.connectionFactory = connectionFactory;

View on GitHub (pinned to 878ce2a1fa)

Solutions

  1. Pass CollectorMetrics.NOOP_METRICS (or a real implementation) instead of null
  2. Provide a default metrics bean in DI setups
  3. Omit the metrics() call — the builder defaults to NOOP metrics already

Example fix

// before
builder.metrics(metricsEnabled ? metricsImpl : null);

// after
builder.metrics(metricsEnabled ? metricsImpl : CollectorMetrics.NOOP_METRICS);
Defensive patterns

Strategy: validation

Validate before calling

builder.metrics(metrics != null ? metrics : CollectorMetrics.NOOP_METRICS);

Prevention

When it happens

Trigger: Calling .metrics(null) — e.g. a DI container injecting a missing CollectorMetrics bean, or a conditional expression that yields null when metrics are 'disabled'.

Common situations: Custom server integrations where metrics are treated as optional and null is used to mean 'none'.

Related errors


AI-assisted analysis of openzipkin/zipkin@878ce2a1fa (2026-08-14). Data as JSON: /api/errors/01777995a110fbd9. Report an issue: GitHub.