private InstantAndValue<Double> delta(MetricKey metricKey, Instant now, Double value) {
            Optional<InstantAndValue<Double>> lastValue = doubleDeltas.getAndSet(metricKey, now, value);

            return lastValue
                .map(last -> new InstantAndValue<>(last.getIntervalStart(), value - last.getValue()))
                .orElse(new InstantAndValue<>(instantAdded(metricKey), value));
        }
Keeps track of the state of metrics, e.g. when they were added, what their getAndSet value is,
and clearing them out when they're removed.
clients/src/main/java/org/apache/kafka/common/telemetry/internals/KafkaMetricsCollector.java