public static PrometheusMetric create(MetricMetadata meta, DataPointSnapshot snapshot) {
        MetricType type;
        double value = 0;

        // detect type and value from the snapshot class type
        if (snapshot instanceof CounterSnapshot.CounterDataPointSnapshot) {
            type = MetricType.COUNTER;
            value = ((CounterSnapshot.CounterDataPointSnapshot) snapshot).getValue();
        } else if (snapshot instanceof GaugeSnapshot.GaugeDataPointSnapshot) {
            type = MetricType.GAUGE;
            value = ((GaugeSnapshot.GaugeDataPointSnapshot) snapshot).getValue();
        } else {
            throw new RuntimeException(
                    String.format("unknown create metric from prometheus type: %s", snapshot.getClass().getName()));
        }

        MetricUnit unit = MetricUnit.NOUNIT;
        if (meta.hasUnit()) {
            unit = UNIT_MAPPING.get(meta.getUnit());
            if (unit == null) {
                unit = MetricUnit.NOUNIT;
            }
        }

        PrometheusMetric metric = new PrometheusMetric(meta.getName(), type, unit, meta.getHelp());
        for (Label label : snapshot.getLabels()) {
            metric.addLabel(new MetricLabel(label.getName(), label.getValue()));
        }
        metric.setValue(value);
        return metric;
    }
@Test
    public void testBasic() throws Exception {
        MetricMetadata data = new MetricMetadata("test_prometheus_metric");
        CounterSnapshot.CounterDataPointSnapshot s1 = CounterSnapshot.CounterDataPointSnapshot.builder().value(1.0).build();
        GaugeSnapshot.GaugeDataPointSnapshot s2 = GaugeSnapshot.GaugeDataPointSnapshot.builder().value(1.0).build();
        PrometheusMetric m1 = PrometheusMetric.create(data, s1);
        PrometheusMetric m2 = PrometheusMetric.create(data, s2);
        Assert.assertEquals(m1.getType(), Metric.MetricType.COUNTER);
        Assert.assertEquals(m2.getType(), Metric.MetricType.GAUGE);
    }