Search in sources :

Example 1 with IntegrationDeploymentMetrics

use of io.syndesis.common.model.metrics.IntegrationDeploymentMetrics in project syndesis by syndesisio.

the class IntegrationMetricsHandler method compute.

/**
 * Computes the IntegrationMetricsSummary from the RawMetrics available for the
 * current integration.
 *
 * @param integrationId
 * @param metrics
 * @param livePodIds
 * @return
 */
public IntegrationMetricsSummary compute(String integrationId, Map<String, RawMetrics> metrics, Set<String> livePodIds) {
    Map<String, Metrics> m = new HashMap<>();
    Metrics tm = new Metrics();
    for (RawMetrics raw : metrics.values()) {
        String version = raw.getVersion();
        Metrics mh = m.containsKey(version) ? m.get(version) : new Metrics();
        mh.add(livePodIds, raw);
        m.put(version, mh);
        tm = tm.add(livePodIds, raw);
    }
    List<IntegrationDeploymentMetrics> dmList = new ArrayList<>();
    for (Metrics mh : m.values()) {
        IntegrationDeploymentMetrics dm = new IntegrationDeploymentMetrics.Builder().version(mh.getVersion()).messages(mh.getMessages()).errors(mh.getErrors()).start(mh.getStartDate()).lastProcessed(mh.getLastProcessed()).build();
        dmList.add(dm);
    }
    return new IntegrationMetricsSummary.Builder().id(integrationId).messages(tm.getMessages()).errors(tm.getErrors()).start(tm.getStartDate()).lastProcessed(tm.getLastProcessed()).integrationDeploymentMetrics(dmList).build();
}
Also used : IntegrationDeploymentMetrics(io.syndesis.common.model.metrics.IntegrationDeploymentMetrics) HashMap(java.util.HashMap) IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) ArrayList(java.util.ArrayList) IntegrationDeploymentMetrics(io.syndesis.common.model.metrics.IntegrationDeploymentMetrics)

Example 2 with IntegrationDeploymentMetrics

use of io.syndesis.common.model.metrics.IntegrationDeploymentMetrics in project syndesis by syndesisio.

the class PrometheusMetricsProviderImpl method createIntegrationMetricsSummary.

private IntegrationMetricsSummary createIntegrationMetricsSummary(Map<String, Long> totalMessagesMap, Map<String, Long> failedMessagesMap, Map<String, Date> startTimeMap, Map<String, Date> lastProcessingTimeMap, Optional<Date> startTime, Optional<Date> lastProcessedTime) {
    final long[] totalMessages = { 0L };
    final long[] totalErrors = { 0L };
    final List<IntegrationDeploymentMetrics> deploymentMetrics = totalMessagesMap.entrySet().stream().map(entry -> {
        final String version = entry.getKey();
        final Long messages = entry.getValue();
        final Long errors = failedMessagesMap.get(version);
        final Date start = startTimeMap.get(version);
        final Date lastProcessed = lastProcessingTimeMap.get(version);
        // aggregate values while we are at it
        totalMessages[0] = SUM_LONGS.apply(totalMessages[0], messages);
        totalErrors[0] = SUM_LONGS.apply(totalErrors[0], errors);
        return new IntegrationDeploymentMetrics.Builder().version(version).messages(messages).errors(errors).start(Optional.ofNullable(start)).lastProcessed(Optional.ofNullable(lastProcessed)).build();
    }).sorted(Comparator.comparing(IntegrationDeploymentMetrics::getVersion)).collect(Collectors.toList());
    return new IntegrationMetricsSummary.Builder().metricsProvider("prometheus").integrationDeploymentMetrics(deploymentMetrics).start(startTime).lastProcessed(lastProcessedTime).messages(totalMessages[0]).errors(totalErrors[0]).build();
}
Also used : IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) IntegrationDeploymentMetrics(io.syndesis.common.model.metrics.IntegrationDeploymentMetrics) Date(java.util.Date)

Aggregations

IntegrationDeploymentMetrics (io.syndesis.common.model.metrics.IntegrationDeploymentMetrics)2 IntegrationMetricsSummary (io.syndesis.common.model.metrics.IntegrationMetricsSummary)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1