@Test
public void testExportClusterHistogram() {

    AlibabaMetricsExports exports = new AlibabaMetricsExports(clock);
    long [] buckets = new long[]{0, 10, 100, 1000};
    ClusterHistogram ch = new ClusterHistogramImpl(buckets, 1, clock);
    MetricManager.getIMetricManager().register("test",
            MetricName.build("prom.test.ch").level(MetricLevel.CRITICAL), ch);
    for (int i = 0; i < 10; i++) {
        int value = (int)(1000 * Math.random());
        ch.update(value);
    }
    clock.addSeconds(1);
    List<Collector.MetricFamilySamples> samples = exports.collect();
    Assert.assertEquals(1, samples.size());
    Assert.assertEquals("prom_test_ch_cluster_percentile", samples.get(0).name);
    Assert.assertEquals(Collector.Type.HISTOGRAM, samples.get(0).type);
    Assert.assertEquals("should contain one more bucket called +Inf", buckets.length+1,
            samples.get(0).samples.size());
}