public <T> void addThreadLevelMutableMetric(final String name,
                                                final String description,
                                                final String threadId,
                                                final Gauge<T> valueProvider) {
        final MetricName metricName = metrics.metricName(
            name, THREAD_LEVEL_GROUP, description, threadLevelTagMap(threadId));
        synchronized (threadLevelMetrics) {
            threadLevelMetrics.computeIfAbsent(
                threadSensorPrefix(threadId),
                tid -> new LinkedList<>()
            ).add(metricName);
            metrics.addMetric(metricName, valueProvider);
        }
    }
@Test
    public void shouldAddThreadLevelMutableMetric() {
        final int measuredValue = 123;
        final StreamsMetricsImpl streamsMetrics
            = new StreamsMetricsImpl(metrics, THREAD_ID1, VERSION, time);

        streamsMetrics.addThreadLevelMutableMetric(
            "foobar",
            "test metric",
            "t1",
            (c, t) -> measuredValue
        );

        final MetricName name = metrics.metricName(
            "foobar",
            THREAD_LEVEL_GROUP,
            Collections.singletonMap("thread-id", "t1")
        );
        assertThat(metrics.metric(name), notNullValue());
        assertThat(metrics.metric(name).metricValue(), equalTo(measuredValue));
    }