public static Map<String, Object> map(String metricName, Metric metric) {
        final Map<String, Object> metricMap = Maps.newHashMap();
        metricMap.put("full_name", metricName);
        metricMap.put("name", metricName.substring(metricName.lastIndexOf(".") + 1));

        if (metric instanceof Timer) {
            metricMap.put("metric", buildTimerMap((Timer) metric));
            metricMap.put("type", "timer");
        } else if(metric instanceof Meter) {
            metricMap.put("metric", buildMeterMap((Meter) metric));
            metricMap.put("type", "meter");
        } else if(metric instanceof Histogram) {
            metricMap.put("metric", buildHistogramMap((Histogram) metric));
            metricMap.put("type", "histogram");
        } else if(metric instanceof Counter) {
            metricMap.put("metric", metric);
            metricMap.put("type", "counter");
        } else if(metric instanceof Gauge) {
            metricMap.put("metric", metric);
            metricMap.put("type", "gauge");
        } else {
            throw new IllegalArgumentException("Unknown metric type " + metric.getClass());
        }
        return metricMap;
    }
@Test
    public void mapThrowsIllegalArgumentExceptionForUnknownMetricType() {
        final Metric metric = new Metric() {};

        assertThatIllegalArgumentException()
                .isThrownBy(() -> MetricUtils.map("metric", metric))
                .withMessageStartingWith("Unknown metric type class org.graylog2.shared.metrics.MetricUtilsTest");
    }