@Test
public void testExportCompass() {

    AlibabaMetricsExports exports = new AlibabaMetricsExports(clock);
    Compass compass = new CompassImpl(ReservoirType.UNIFORM, clock,  5, 1, 2, 2);
    MetricManager.getIMetricManager().register("test",
            MetricName.build("prom.test.compass").level(MetricLevel.CRITICAL), compass);
    int min = Integer.MAX_VALUE;
    int max = 0;
    for (int i = 0; i < 10; i++) {
        int value = (int)(1000 * Math.random());
        compass.update(value, TimeUnit.MILLISECONDS);
        Compass.Context c = compass.time();
        if (i % 2 == 0) {
            c.success();
            c.markAddon("hit");
        } else {
            c.error("random");
        }
        if (value < min) {
            min = value;
        }
        if (value > max) {
            max = value;
        }
    }
    clock.addSeconds(1);
    List<Collector.MetricFamilySamples> samples = exports.collect();
    Assert.assertEquals(11, samples.size());
    Assert.assertEquals("prom_test_compass_summary", samples.get(0).name);
    Assert.assertEquals(Collector.Type.SUMMARY, samples.get(0).type);
    Assert.assertEquals("should contain p50/p75/p95/p99 percentiles", 4, samples.get(0).samples.size());
    Assert.assertEquals("prom_test_compass_min", samples.get(1).name);
    Assert.assertEquals(min, samples.get(1).samples.get(0).value, 0.0001d);
    Assert.assertEquals("prom_test_compass_max", samples.get(2).name);
    Assert.assertEquals(max, samples.get(2).samples.get(0).value, 0.0001d);
    Assert.assertEquals("prom_test_compass_mean", samples.get(3).name);
    Assert.assertEquals("prom_test_compass_stddev", samples.get(4).name);
    Assert.assertEquals("prom_test_compass_count", samples.get(5).name);
    Assert.assertEquals("prom_test_compass_m1", samples.get(6).name);
    Assert.assertEquals("prom_test_compass_m5", samples.get(7).name);
    Assert.assertEquals("prom_test_compass_m15", samples.get(8).name);
    Assert.assertEquals("prom_test_compass_bucket_count", samples.get(9).name);
    Assert.assertEquals("success count", 5, samples.get(9).samples.get(0).value, 0.0001d);
    Assert.assertEquals("failure count", 5, samples.get(9).samples.get(1).value, 0.0001d);
    Assert.assertEquals("prom_test_compass_addon_bucket_count", samples.get(10).name);
    Assert.assertEquals("hit count", 5, samples.get(10).samples.get(0).value, 0.0001d);
}