public void run()

in collector/prometheus/src/main/java/org/apache/karaf/decanter/collector/prometheus/PrometheusCollector.java [71:100]


    public void run() {
        try {
            URLConnection connection = prometheusURL.openConnection();
            Map<String, Object> data = new HashMap<>();
            data.put("type", "prometheus");
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
                String line;
                while ((line = reader.readLine()) != null) {
                    if (line.matches("# TYPE .* gauge")) {
                        line = reader.readLine();
                        if (line == null) {
                            break;
                        }
                        String[] split = line.split(" ");
                        if (split.length == 2) {
                            String property = split[0];
                            double value = Double.parseDouble(split[1]);
                            data.put(property, value);
                        }
                    }
                }
            }
            PropertiesPreparator.prepare(data, properties);
            String topic = (properties.get(EventConstants.EVENT_TOPIC) != null) ? (String) properties.get(EventConstants.EVENT_TOPIC) : "decanter/collect/prometheus";
            dispatcher.postEvent(new Event(topic, data));
        } catch (Exception e) {
            LOGGER.warn("Can't get Prometheus metrics", e);
            e.printStackTrace();
        }
    }