Skip to content

Commit

Permalink
Merge pull request #7142 from claudio4j/fix_metric_dates_ENTESB-12268
Browse files Browse the repository at this point in the history
ENTESB-12268 Integration uptime doesn't contain any data
  • Loading branch information
claudio4j committed Nov 20, 2019
2 parents cc4b169 + f1eb4ec commit a8daee4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package io.syndesis.server.metrics.prometheus;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.time.Duration;
import java.time.Instant;
import java.util.Comparator;
Expand All @@ -26,6 +24,8 @@
import java.util.function.BinaryOperator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import io.fabric8.kubernetes.api.model.LabelSelector;
import io.fabric8.kubernetes.api.model.Pod;
Expand Down Expand Up @@ -156,17 +156,19 @@ private static IntegrationMetricsSummary createIntegrationMetricsSummary(Map<Str
.version(version)
.messages(messages)
.errors(errors)
.start(start)
.lastProcessed(lastProcessed)
// set as long values instead of long and nano parts as the UI don't need to handle the nano part
.start(start.map(st -> Instant.ofEpochMilli(st.toEpochMilli() * 1000)))
.lastProcessed(lastProcessed.map(lp -> Instant.ofEpochMilli(lp.toEpochMilli() * 1000)))
.uptimeDuration(start.map(date -> Duration.between(date, Instant.now()).toMillis()).orElse(0L))
.build();
}).sorted(Comparator.comparing(IntegrationDeploymentMetrics::getVersion)).collect(Collectors.toList());

return new IntegrationMetricsSummary.Builder()
.metricsProvider("prometheus")
.integrationDeploymentMetrics(deploymentMetrics)
.start(startTime)
.lastProcessed(lastProcessedTime)
// set as long values instead of long and nano parts as the UI don't need to handle the nano part
.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[0])
.errors(totalErrors[0])
Expand Down Expand Up @@ -197,8 +199,9 @@ public IntegrationMetricsSummary getTotalIntegrationMetricsSummary() {
// get top 5 integrations by total messages
return new IntegrationMetricsSummary.Builder()
.metricsProvider("prometheus")
.start(startTime)
.lastProcessed(lastProcessedTime)
// set as long values instead of long and nano parts as the UI don't need to handle the nano part
.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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public final class Utils {
.registerModules(new Jdk8Module(), new EpochMillisTimeModule(), new JavaTimeModule())
.setPropertyInclusion(JsonInclude.Value.construct(JsonInclude.Include.NON_EMPTY, JsonInclude.Include.NON_EMPTY))
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// disable read as nanoseconds as the values are read as integers from prometheus, with no nano part
.disable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
Expand Down

0 comments on commit a8daee4

Please sign in to comment.