@Test
    public void testUpdatingMetricConfigIsReflectedInTheSensor() {
        final Time time = new MockTime(0, System.currentTimeMillis(), 0);
        final Metrics metrics = new Metrics(time);
        final Sensor sensor = metrics.sensor("sensor");

        final MeasurableStat stat = Mockito.mock(MeasurableStat.class);
        final MetricName statName = metrics.metricName("stat", "test-group");
        final MetricConfig statConfig = new MetricConfig().quota(Quota.upperBound(5));
        sensor.add(statName, stat, statConfig);

        sensor.record(10, 1);
        Mockito.verify(stat).record(statConfig, 10, 1);

        sensor.checkQuotas(2);
        Mockito.verify(stat).measure(statConfig, 2);

        // Update the config of the KafkaMetric
        final MetricConfig newConfig = new MetricConfig().quota(Quota.upperBound(10));
        metrics.metric(statName).config(newConfig);

        sensor.record(10, 3);
        Mockito.verify(stat).record(newConfig, 10, 3);

        sensor.checkQuotas(4);
        Mockito.verify(stat).measure(newConfig, 4);

        metrics.close();
    }
The Sensor#checkQuotas should be thread-safe since the method may be used by many ReplicaFetcherThreads.
clients/src/test/java/org/apache/kafka/common/metrics/SensorTest.java