public void run()

in collector/dropwizard/src/main/java/org/apache/karaf/decanter/collector/dropwizard/DecanterReporterCollector.java [65:126]


    public void run() {
        Map<String, Metric> metrics = metricRegistry.getMetrics();
        for (String metricName : metrics.keySet()) {
            Metric metric = metrics.get(metricName);
            Map<String, Object> data = new HashMap<>();
            data.put("type", "dropwizard");
            data.put("karafName", System.getProperty("karaf.name"));
            try {
                data.put("hostAddress", InetAddress.getLocalHost().getHostAddress());
                data.put("hostName", InetAddress.getLocalHost().getHostName());
            } catch (Exception e) {
                // nothing to do
            }
            if (metric instanceof Gauge) {
                Gauge gauge = (Gauge) metric;
                Object value = gauge.getValue();
                data.put("metric", "gauge");
                data.put("value", value);
            }
            if (metric instanceof Counter) {
                Counter counter = (Counter) metric;
                data.put("metric", "counter");
                data.put("count", counter.getCount());
            }
            if (metric instanceof Histogram) {
                Histogram histogram = (Histogram) metric;
                data.put("metric", "histogram");
                data.put("count", histogram.getCount());
                populateSnapshot(histogram.getSnapshot(), data);
            }
            if (metric instanceof Meter) {
                Meter meter = (Meter) metric;
                data.put("metric", "meter");
                data.put("count", meter.getCount());
                data.put("15 Minute Rate", meter.getFifteenMinuteRate());
                data.put("5 Minute Rate", meter.getFiveMinuteRate());
                data.put("1 Minute Rate", meter.getOneMinuteRate());
                data.put("Mean Rate", meter.getMeanRate());
            }
            if (metric instanceof Timer) {
                Timer timer = (Timer) metric;
                data.put("metric", "timer");
                data.put("count", timer.getCount());
                data.put("15 Minute Rate", timer.getFifteenMinuteRate());
                data.put("5 Minute Rate", timer.getFiveMinuteRate());
                data.put("1 Minute Rate", timer.getOneMinuteRate());
                data.put("Mean Rate", timer.getMeanRate());
                populateSnapshot(timer.getSnapshot(), data);
            }

            try {
                PropertiesPreparator.prepare(data, config);
            } catch (Exception e) {
                // nothing to do
            }

            String topic = (config.get(EventConstants.EVENT_TOPIC) != null) ? (String) config.get(EventConstants.EVENT_TOPIC) : "decanter/collect/dropwizard";

            Event event = new Event(topic, data);
            dispatcher.postEvent(event);
        }
    }