@Test public void testGetIntegrationMetricsSummary() throws Exception { final IntegrationMetricsSummary summary = metricsProvider.getIntegrationMetricsSummary(TEST_INTEGRATION_ID); assertThat(summary.getMessages()).isNotNull(); final Optional<List<IntegrationDeploymentMetrics>> deploymentMetrics = summary .getIntegrationDeploymentMetrics(); assertThat(deploymentMetrics).isNotEmpty().map(List::isEmpty).hasValue(false); }
@Override public IntegrationMetricsSummary getIntegrationMetricsSummary(String integrationId) { final Map<String, Long> totalMessagesMap = getMetricValues(integrationId, METRIC_TOTAL, deploymentVersionLabel, Long.class, PrometheusMetricsProviderImpl::sum); final Map<String, Long> failedMessagesMap = getMetricValues(integrationId, METRIC_FAILED, deploymentVersionLabel, Long.class, PrometheusMetricsProviderImpl::sum); final Map<String, Instant> startTimeMap = getMetricValues(integrationId, METRIC_START_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastCompletedTimeMap = getMetricValues(integrationId, METRIC_COMPLETED_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastFailedTimeMap = getMetricValues(integrationId, METRIC_FAILURE_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastProcessedTimeMap = Stream.concat(lastCompletedTimeMap.entrySet().stream(), lastFailedTimeMap.entrySet().stream()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, PrometheusMetricsProviderImpl::max)); final Optional<Instant> startTime = getAggregateMetricValue(integrationId, METRIC_START_TIMESTAMP, Instant.class, MIN); final Optional<Instant> lastCompletedTime = getAggregateMetricValue(integrationId, METRIC_COMPLETED_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastFailureTime = getAggregateMetricValue(integrationId, METRIC_FAILURE_TIMESTAMP, Instant.class, MAX); final Instant lastProcessedTime = max(lastCompletedTime.orElse(null), lastFailureTime.orElse(null)); return createIntegrationMetricsSummary(totalMessagesMap, failedMessagesMap, startTimeMap, lastProcessedTimeMap, startTime, Optional.ofNullable(lastProcessedTime)); }
PrometheusMetricsProviderImpl implements MetricsProvider { @Override public IntegrationMetricsSummary getIntegrationMetricsSummary(String integrationId) { final Map<String, Long> totalMessagesMap = getMetricValues(integrationId, METRIC_TOTAL, deploymentVersionLabel, Long.class, PrometheusMetricsProviderImpl::sum); final Map<String, Long> failedMessagesMap = getMetricValues(integrationId, METRIC_FAILED, deploymentVersionLabel, Long.class, PrometheusMetricsProviderImpl::sum); final Map<String, Instant> startTimeMap = getMetricValues(integrationId, METRIC_START_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastCompletedTimeMap = getMetricValues(integrationId, METRIC_COMPLETED_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastFailedTimeMap = getMetricValues(integrationId, METRIC_FAILURE_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastProcessedTimeMap = Stream.concat(lastCompletedTimeMap.entrySet().stream(), lastFailedTimeMap.entrySet().stream()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, PrometheusMetricsProviderImpl::max)); final Optional<Instant> startTime = getAggregateMetricValue(integrationId, METRIC_START_TIMESTAMP, Instant.class, MIN); final Optional<Instant> lastCompletedTime = getAggregateMetricValue(integrationId, METRIC_COMPLETED_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastFailureTime = getAggregateMetricValue(integrationId, METRIC_FAILURE_TIMESTAMP, Instant.class, MAX); final Instant lastProcessedTime = max(lastCompletedTime.orElse(null), lastFailureTime.orElse(null)); return createIntegrationMetricsSummary(totalMessagesMap, failedMessagesMap, startTimeMap, lastProcessedTimeMap, startTime, Optional.ofNullable(lastProcessedTime)); } }
PrometheusMetricsProviderImpl implements MetricsProvider { @Override public IntegrationMetricsSummary getIntegrationMetricsSummary(String integrationId) { final Map<String, Long> totalMessagesMap = getMetricValues(integrationId, METRIC_TOTAL, deploymentVersionLabel, Long.class, PrometheusMetricsProviderImpl::sum); final Map<String, Long> failedMessagesMap = getMetricValues(integrationId, METRIC_FAILED, deploymentVersionLabel, Long.class, PrometheusMetricsProviderImpl::sum); final Map<String, Instant> startTimeMap = getMetricValues(integrationId, METRIC_START_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastCompletedTimeMap = getMetricValues(integrationId, METRIC_COMPLETED_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastFailedTimeMap = getMetricValues(integrationId, METRIC_FAILURE_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastProcessedTimeMap = Stream.concat(lastCompletedTimeMap.entrySet().stream(), lastFailedTimeMap.entrySet().stream()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, PrometheusMetricsProviderImpl::max)); final Optional<Instant> startTime = getAggregateMetricValue(integrationId, METRIC_START_TIMESTAMP, Instant.class, MIN); final Optional<Instant> lastCompletedTime = getAggregateMetricValue(integrationId, METRIC_COMPLETED_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastFailureTime = getAggregateMetricValue(integrationId, METRIC_FAILURE_TIMESTAMP, Instant.class, MAX); final Instant lastProcessedTime = max(lastCompletedTime.orElse(null), lastFailureTime.orElse(null)); return createIntegrationMetricsSummary(totalMessagesMap, failedMessagesMap, startTimeMap, lastProcessedTimeMap, startTime, Optional.ofNullable(lastProcessedTime)); } protected  PrometheusMetricsProviderImpl(PrometheusConfigurationProperties config, NamespacedOpenShiftClient openShiftClient); }
PrometheusMetricsProviderImpl implements MetricsProvider { @Override public IntegrationMetricsSummary getIntegrationMetricsSummary(String integrationId) { final Map<String, Long> totalMessagesMap = getMetricValues(integrationId, METRIC_TOTAL, deploymentVersionLabel, Long.class, PrometheusMetricsProviderImpl::sum); final Map<String, Long> failedMessagesMap = getMetricValues(integrationId, METRIC_FAILED, deploymentVersionLabel, Long.class, PrometheusMetricsProviderImpl::sum); final Map<String, Instant> startTimeMap = getMetricValues(integrationId, METRIC_START_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastCompletedTimeMap = getMetricValues(integrationId, METRIC_COMPLETED_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastFailedTimeMap = getMetricValues(integrationId, METRIC_FAILURE_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastProcessedTimeMap = Stream.concat(lastCompletedTimeMap.entrySet().stream(), lastFailedTimeMap.entrySet().stream()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, PrometheusMetricsProviderImpl::max)); final Optional<Instant> startTime = getAggregateMetricValue(integrationId, METRIC_START_TIMESTAMP, Instant.class, MIN); final Optional<Instant> lastCompletedTime = getAggregateMetricValue(integrationId, METRIC_COMPLETED_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastFailureTime = getAggregateMetricValue(integrationId, METRIC_FAILURE_TIMESTAMP, Instant.class, MAX); final Instant lastProcessedTime = max(lastCompletedTime.orElse(null), lastFailureTime.orElse(null)); return createIntegrationMetricsSummary(totalMessagesMap, failedMessagesMap, startTimeMap, lastProcessedTimeMap, startTime, Optional.ofNullable(lastProcessedTime)); } 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 getIntegrationMetricsSummary(String integrationId) { final Map<String, Long> totalMessagesMap = getMetricValues(integrationId, METRIC_TOTAL, deploymentVersionLabel, Long.class, PrometheusMetricsProviderImpl::sum); final Map<String, Long> failedMessagesMap = getMetricValues(integrationId, METRIC_FAILED, deploymentVersionLabel, Long.class, PrometheusMetricsProviderImpl::sum); final Map<String, Instant> startTimeMap = getMetricValues(integrationId, METRIC_START_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastCompletedTimeMap = getMetricValues(integrationId, METRIC_COMPLETED_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastFailedTimeMap = getMetricValues(integrationId, METRIC_FAILURE_TIMESTAMP, deploymentVersionLabel, Instant.class, PrometheusMetricsProviderImpl::max); final Map<String, Instant> lastProcessedTimeMap = Stream.concat(lastCompletedTimeMap.entrySet().stream(), lastFailedTimeMap.entrySet().stream()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, PrometheusMetricsProviderImpl::max)); final Optional<Instant> startTime = getAggregateMetricValue(integrationId, METRIC_START_TIMESTAMP, Instant.class, MIN); final Optional<Instant> lastCompletedTime = getAggregateMetricValue(integrationId, METRIC_COMPLETED_TIMESTAMP, Instant.class, MAX); final Optional<Instant> lastFailureTime = getAggregateMetricValue(integrationId, METRIC_FAILURE_TIMESTAMP, Instant.class, MAX); final Instant lastProcessedTime = max(lastCompletedTime.orElse(null), lastFailureTime.orElse(null)); return createIntegrationMetricsSummary(totalMessagesMap, failedMessagesMap, startTimeMap, lastProcessedTimeMap, startTime, Optional.ofNullable(lastProcessedTime)); } 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; }