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();
}
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();
}
Aggregations