@Override
    public void close(Duration timeout) {
        if (this.closeException != null) {
            throw this.closeException;
        }

        this.closed = true;
    }
Set a mock metric for testing purpose
clients/src/main/java/org/apache/kafka/clients/producer/MockProducer.java