public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) {
        if (all || changed()) {
            numSamples += intervalStat.numSamples();
            builder.addCounter(numSamplesName, numSamplesDesc, numSamples);
            builder.addGauge(avgValueName, avgValueDesc, lastStat().mean());
            if (extended) {
                builder.addGauge(stdevValueName, stdevValueDesc, lastStat().stddev());
                builder.addGauge(iMinValueName, iMinValueDesc, lastStat().min());
                builder.addGauge(iMaxValueName, iMaxValueDesc, lastStat().max());
                builder.addGauge(minValueName, minValueDesc, minMax.min());
                builder.addGauge(maxValueName, maxValueDesc, minMax.max());
            }
            if (changed()) {
                intervalStat.copyTo(prevStat);
                intervalStat.reset();
                clearChanged();
            }
        }
    }