class PodMetricsReader implements Runnable {

    @Override
    public void run() {
        try {
            LOGGER.debug("Collecting stats from integrationId: {}", integrationId);
            List<Map<String, String>> routeStats = getRoutes(integration, "[a-zA-z0-9_-]+");

            routeStats.forEach(
                m -> {

                    long messages = toLong(m.getOrDefault(EXCHANGES_TOTAL, "0"));
                    long errors = toLong(m.getOrDefault(EXCHANGES_FAILED, "0"));
                    Instant lastCompleted = toInstant(m.get(LAST_COMPLETED_TIMESTAMP));
                    Instant lastFailed = toInstant(m.get(LAST_FAILED_TIMESTAMP));
                    Instant lastMessage =
                            (lastCompleted == null && lastFailed != null) ||
                            (lastCompleted != null && lastFailed != null && lastFailed.isAfter(lastCompleted))
                        ? lastFailed
                        : lastCompleted;

                    Instant resetDate = toInstant(m.get(RESET_TIMESTAMP));
                    Instant startDate = toInstant(m.get(START_TIMESTAMP));


                    handler.persist(new RawMetrics.Builder()
                        .pod(pod)
                        .integrationId(integrationId)
                        .version(version)
                        .messages(messages)
                        .errors(errors)
                        .startDate(startDate)
                        .lastProcessed(Optional.ofNullable(lastMessage))
                        .resetDate(resetDate)
                        .build());
                }
            );

        } catch (MalformedObjectNameException | J4pException e) {
            LOGGER.error("Collecting stats from integrationId: {}", integrationId);
            LOGGER.debug("Collecting stats from integrationId: {}", integrationId, e);
        }
    }

    public  PodMetricsReader(KubernetesClient kubernetes, String pod, String integration, String integrationId, String version,
            RawMetricsHandler handler);

}