@Test
public void testExportTimer() {

    AlibabaMetricsExports exports = new AlibabaMetricsExports(clock);
    Timer timer = new TimerImpl(ReservoirType.UNIFORM, clock, 1);
    MetricManager.getIMetricManager().register("test",
            MetricName.build("prom.test.timer").level(MetricLevel.CRITICAL), timer);
    int min = Integer.MAX_VALUE;
    int max = 0;
    for (int i = 0; i < 10; i++) {
        int value = (int)(1000 * Math.random());
        timer.update(value, TimeUnit.MILLISECONDS);
        if (value < min) {
            min = value;
        }
        if (value > max) {
            max = value;
        }
    }
    clock.addSeconds(1);
    List<Collector.MetricFamilySamples> samples = exports.collect();
    Assert.assertEquals(10, samples.size());
    Assert.assertEquals("prom_test_timer_summary", samples.get(0).name);
    Assert.assertEquals("should contain p50/p75/p95/p99 percentiles", 4, samples.get(0).samples.size());
    Assert.assertEquals("prom_test_timer_min", samples.get(1).name);
    Assert.assertEquals(min, samples.get(1).samples.get(0).value, 0.0001d);
    Assert.assertEquals("prom_test_timer_max", samples.get(2).name);
    Assert.assertEquals(max, samples.get(2).samples.get(0).value, 0.0001d);
    Assert.assertEquals("prom_test_timer_mean", samples.get(3).name);
    Assert.assertEquals("prom_test_timer_stddev", samples.get(4).name);
    Assert.assertEquals("prom_test_timer_count", samples.get(5).name);
    Assert.assertEquals(10, samples.get(5).samples.get(0).value, 0.0001d);
    Assert.assertEquals("prom_test_timer_m1", samples.get(6).name);
    Assert.assertEquals("prom_test_timer_m5", samples.get(7).name);
    Assert.assertEquals("prom_test_timer_m15", samples.get(8).name);
    Assert.assertEquals("prom_test_timer_bucket_count", samples.get(9).name);
    Assert.assertEquals(10, samples.get(9).samples.get(0).value, 0.0001d);
}