@Test public void testGetTotalIntegrationMetricsSummary() throws Exception { final IntegrationMetricsSummary summary = metricsProvider.getTotalIntegrationMetricsSummary(); assertThat(summary.getMessages()).isNotNull(); final Optional<List<IntegrationDeploymentMetrics>> deploymentMetrics = summary .getIntegrationDeploymentMetrics(); assertThat(deploymentMetrics).isEmpty(); }
@Override public IntegrationMetricsSummary getTotalIntegrationMetricsSummary() { final Optional<Long> totalMessages = getSummaryMetricValue(METRIC_TOTAL, Long.class, "sum"); final Optional<Long> failedMessages = getSummaryMetricValue(METRIC_FAILED, Long.class, "sum"); final List<Pod> serverList = openShiftClient.pods().withLabelSelector(SELECTOR).list().getItems(); final Optional<Instant> startTime; if (!serverList.isEmpty()) { startTime = Optional.of(Instant.parse(serverList.get(0).getStatus().getStartTime())); } else { if (LOG.isWarnEnabled()) { LOG.warn("Missing syndesis-server pod in lookup with selector " + LABELS); } startTime = Optional.empty(); } final Optional<Instant> lastCompletedTime = getAggregateMetricValue(METRIC_COMPLETED_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastFailureTime = getAggregateMetricValue(METRIC_FAILURE_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastProcessedTime = Optional.ofNullable(max(lastCompletedTime.orElse(null), lastFailureTime.orElse(null))); return new IntegrationMetricsSummary.Builder() .metricsProvider("prometheus") .start(startTime.map(st -> Instant.ofEpochMilli(st.toEpochMilli() * 1000))) .lastProcessed(lastProcessedTime.map(lp -> Instant.ofEpochMilli(lp.toEpochMilli() * 1000))) .uptimeDuration(startTime.map(date -> Duration.between(date, Instant.now()).toMillis()).orElse(0L)) .messages(totalMessages.orElse(0L)) .errors(failedMessages.orElse(0L)) .topIntegrations(getTopIntegrations()) .build(); }
PrometheusMetricsProviderImpl implements MetricsProvider { @Override public IntegrationMetricsSummary getTotalIntegrationMetricsSummary() { final Optional<Long> totalMessages = getSummaryMetricValue(METRIC_TOTAL, Long.class, "sum"); final Optional<Long> failedMessages = getSummaryMetricValue(METRIC_FAILED, Long.class, "sum"); final List<Pod> serverList = openShiftClient.pods().withLabelSelector(SELECTOR).list().getItems(); final Optional<Instant> startTime; if (!serverList.isEmpty()) { startTime = Optional.of(Instant.parse(serverList.get(0).getStatus().getStartTime())); } else { if (LOG.isWarnEnabled()) { LOG.warn("Missing syndesis-server pod in lookup with selector " + LABELS); } startTime = Optional.empty(); } final Optional<Instant> lastCompletedTime = getAggregateMetricValue(METRIC_COMPLETED_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastFailureTime = getAggregateMetricValue(METRIC_FAILURE_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastProcessedTime = Optional.ofNullable(max(lastCompletedTime.orElse(null), lastFailureTime.orElse(null))); return new IntegrationMetricsSummary.Builder() .metricsProvider("prometheus") .start(startTime.map(st -> Instant.ofEpochMilli(st.toEpochMilli() * 1000))) .lastProcessed(lastProcessedTime.map(lp -> Instant.ofEpochMilli(lp.toEpochMilli() * 1000))) .uptimeDuration(startTime.map(date -> Duration.between(date, Instant.now()).toMillis()).orElse(0L)) .messages(totalMessages.orElse(0L)) .errors(failedMessages.orElse(0L)) .topIntegrations(getTopIntegrations()) .build(); } }
PrometheusMetricsProviderImpl implements MetricsProvider { @Override public IntegrationMetricsSummary getTotalIntegrationMetricsSummary() { final Optional<Long> totalMessages = getSummaryMetricValue(METRIC_TOTAL, Long.class, "sum"); final Optional<Long> failedMessages = getSummaryMetricValue(METRIC_FAILED, Long.class, "sum"); final List<Pod> serverList = openShiftClient.pods().withLabelSelector(SELECTOR).list().getItems(); final Optional<Instant> startTime; if (!serverList.isEmpty()) { startTime = Optional.of(Instant.parse(serverList.get(0).getStatus().getStartTime())); } else { if (LOG.isWarnEnabled()) { LOG.warn("Missing syndesis-server pod in lookup with selector " + LABELS); } startTime = Optional.empty(); } final Optional<Instant> lastCompletedTime = getAggregateMetricValue(METRIC_COMPLETED_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastFailureTime = getAggregateMetricValue(METRIC_FAILURE_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastProcessedTime = Optional.ofNullable(max(lastCompletedTime.orElse(null), lastFailureTime.orElse(null))); return new IntegrationMetricsSummary.Builder() .metricsProvider("prometheus") .start(startTime.map(st -> Instant.ofEpochMilli(st.toEpochMilli() * 1000))) .lastProcessed(lastProcessedTime.map(lp -> Instant.ofEpochMilli(lp.toEpochMilli() * 1000))) .uptimeDuration(startTime.map(date -> Duration.between(date, Instant.now()).toMillis()).orElse(0L)) .messages(totalMessages.orElse(0L)) .errors(failedMessages.orElse(0L)) .topIntegrations(getTopIntegrations()) .build(); } protected  PrometheusMetricsProviderImpl(PrometheusConfigurationProperties config, NamespacedOpenShiftClient openShiftClient); }
PrometheusMetricsProviderImpl implements MetricsProvider { @Override public IntegrationMetricsSummary getTotalIntegrationMetricsSummary() { final Optional<Long> totalMessages = getSummaryMetricValue(METRIC_TOTAL, Long.class, "sum"); final Optional<Long> failedMessages = getSummaryMetricValue(METRIC_FAILED, Long.class, "sum"); final List<Pod> serverList = openShiftClient.pods().withLabelSelector(SELECTOR).list().getItems(); final Optional<Instant> startTime; if (!serverList.isEmpty()) { startTime = Optional.of(Instant.parse(serverList.get(0).getStatus().getStartTime())); } else { if (LOG.isWarnEnabled()) { LOG.warn("Missing syndesis-server pod in lookup with selector " + LABELS); } startTime = Optional.empty(); } final Optional<Instant> lastCompletedTime = getAggregateMetricValue(METRIC_COMPLETED_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastFailureTime = getAggregateMetricValue(METRIC_FAILURE_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastProcessedTime = Optional.ofNullable(max(lastCompletedTime.orElse(null), lastFailureTime.orElse(null))); return new IntegrationMetricsSummary.Builder() .metricsProvider("prometheus") .start(startTime.map(st -> Instant.ofEpochMilli(st.toEpochMilli() * 1000))) .lastProcessed(lastProcessedTime.map(lp -> Instant.ofEpochMilli(lp.toEpochMilli() * 1000))) .uptimeDuration(startTime.map(date -> Duration.between(date, Instant.now()).toMillis()).orElse(0L)) .messages(totalMessages.orElse(0L)) .errors(failedMessages.orElse(0L)) .topIntegrations(getTopIntegrations()) .build(); } protected  PrometheusMetricsProviderImpl(PrometheusConfigurationProperties config, NamespacedOpenShiftClient openShiftClient); @PostConstruct void init(); @PreDestroy void destroy(); @Override IntegrationMetricsSummary getIntegrationMetricsSummary(String integrationId); @Override IntegrationMetricsSummary getTotalIntegrationMetricsSummary(); }
PrometheusMetricsProviderImpl implements MetricsProvider { @Override public IntegrationMetricsSummary getTotalIntegrationMetricsSummary() { final Optional<Long> totalMessages = getSummaryMetricValue(METRIC_TOTAL, Long.class, "sum"); final Optional<Long> failedMessages = getSummaryMetricValue(METRIC_FAILED, Long.class, "sum"); final List<Pod> serverList = openShiftClient.pods().withLabelSelector(SELECTOR).list().getItems(); final Optional<Instant> startTime; if (!serverList.isEmpty()) { startTime = Optional.of(Instant.parse(serverList.get(0).getStatus().getStartTime())); } else { if (LOG.isWarnEnabled()) { LOG.warn("Missing syndesis-server pod in lookup with selector " + LABELS); } startTime = Optional.empty(); } final Optional<Instant> lastCompletedTime = getAggregateMetricValue(METRIC_COMPLETED_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastFailureTime = getAggregateMetricValue(METRIC_FAILURE_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastProcessedTime = Optional.ofNullable(max(lastCompletedTime.orElse(null), lastFailureTime.orElse(null))); return new IntegrationMetricsSummary.Builder() .metricsProvider("prometheus") .start(startTime.map(st -> Instant.ofEpochMilli(st.toEpochMilli() * 1000))) .lastProcessed(lastProcessedTime.map(lp -> Instant.ofEpochMilli(lp.toEpochMilli() * 1000))) .uptimeDuration(startTime.map(date -> Duration.between(date, Instant.now()).toMillis()).orElse(0L)) .messages(totalMessages.orElse(0L)) .errors(failedMessages.orElse(0L)) .topIntegrations(getTopIntegrations()) .build(); } protected  PrometheusMetricsProviderImpl(PrometheusConfigurationProperties config, NamespacedOpenShiftClient openShiftClient); @PostConstruct void init(); @PreDestroy void destroy(); @Override IntegrationMetricsSummary getIntegrationMetricsSummary(String integrationId); @Override IntegrationMetricsSummary getTotalIntegrationMetricsSummary(); static final String OPERATOR_TOPK; static final String MIN; static final String MAX; }