public KafkaMetric addMetricIfAbsent(MetricName metricName, MetricConfig config, MetricValueProvider<?> metricValueProvider) {
        KafkaMetric metric = new KafkaMetric(new Object(),
                Objects.requireNonNull(metricName),
                Objects.requireNonNull(metricValueProvider),
                config == null ? this.config : config,
                time);

        KafkaMetric existingMetric = registerMetric(metric);
        return existingMetric == null ? metric : existingMetric;
    }
Create or get an existing metric to monitor an object that implements MetricValueProvider.
This metric won't be associated with any sensor. This is a way to expose existing values as metrics.
This method takes care of synchronisation while updating/accessing metrics by concurrent threads.

@param metricName The name of the metric
@param metricValueProvider The metric value provider associated with this metric
@return Existing KafkaMetric if already registered or else a newly created one
clients/src/main/java/org/apache/kafka/common/metrics/Metrics.java