use of io.syndesis.common.model.metrics.IntegrationMetricsSummary in project syndesis-qe by syndesisio.
the class MonitoringValidationSteps method validateThatNumberOfAllMessagesOfIntegrationIsGreaterThanPeriodInMs.
@Then("^validate that number of all messages through integration \"([^\"]*)\" is greater than \"([^\"]*)\", period in ms: \"([^\"]*)\"$")
public void validateThatNumberOfAllMessagesOfIntegrationIsGreaterThanPeriodInMs(String integrationName, Integer nr, Integer ms) throws InterruptedException {
Thread.sleep(ms + 1000);
// 0. get integration id.
String integrationId = this.getIdByIntegrationName(integrationName);
Assertions.assertThat(integrationId).isNotNull();
// 1. get metrics:
IntegrationMetricsSummary summary = integrationsMetricsEndpoint.get(integrationId);
// 2. get metrics info:
Long nrOfMessages = summary.getMessages();
log.info("MESSAGES SUMMARY: *{}*", nrOfMessages);
Assertions.assertThat(nrOfMessages).isGreaterThan(nr);
Date lastProceded = summary.getLastProcessed().get();
log.info("LAST MESSAGE WAS PROCEEDED ON: *{}*", lastProceded);
}
use of io.syndesis.common.model.metrics.IntegrationMetricsSummary in project syndesis by syndesisio.
the class PrometheusMetricsProviderImplTest method testGetIntegrationMetricsSummary.
@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);
}
use of io.syndesis.common.model.metrics.IntegrationMetricsSummary in project syndesis by syndesisio.
the class MetricsCollector method run.
@Override
public void run() {
LOGGER.debug("Collecting metrics for active integration pods.");
try {
List<Pod> integrationPodList = kubernetes.pods().withLabel("integration").list().getItems();
Set<String> livePods = new HashSet<>();
for (Pod pod : integrationPodList) {
livePods.add(pod.getMetadata().getName());
}
integrationPodList.stream().filter(p -> Readiness.isReady(p)).forEach(p -> executor.execute(new PodMetricsReader(kubernetes, p.getMetadata().getName(), p.getMetadata().getAnnotations().get("syndesis.io/integration-name"), p.getMetadata().getLabels().get("syndesis.io/integration-id"), p.getMetadata().getLabels().get("syndesis.io/deployment-version"), rmh)));
Set<String> activeIntegrationIds = dataManager.fetchIds(Integration.class);
for (String integrationId : activeIntegrationIds) {
LOGGER.debug("Computing metrics for IntegrationId: {}", integrationId);
Map<String, RawMetrics> rawMetrics = rmh.getRawMetrics(integrationId);
IntegrationMetricsSummary imSummary = imh.compute(integrationId, rawMetrics, livePods);
imh.persist(imSummary);
rmh.curate(integrationId, rawMetrics, livePods);
}
rmh.curate(activeIntegrationIds);
imh.curate(activeIntegrationIds);
} catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception ex) {
LOGGER.error("Error while iterating integration pods.", ex);
}
}
use of io.syndesis.common.model.metrics.IntegrationMetricsSummary in project syndesis by syndesisio.
the class MetricsCollectorTest method testDeadPodCurator.
@Test
public void testDeadPodCurator() throws IOException, ParseException {
String integrationId = "intId1";
MetricsCollector collector = new MetricsCollector(null, jsondb, null);
// Update pod1 metrics and kill pod1
Set<String> livePodIds = new HashSet<String>(Arrays.asList("pod2", "pod3", "pod4", "pod5"));
jsondb.update(JsonDBRawMetrics.path("intId1", "pod1"), Json.writer().writeValueAsString(raw("intId1", "1", "pod1", 12L, "31-01-2018 10:22:56")));
Map<String, RawMetrics> metrics = jsondbRM.getRawMetrics(integrationId);
IntegrationMetricsSummary summary = intMH.compute(integrationId, metrics, livePodIds);
assertThat(summary.getMessages()).isEqualTo(18);
assertThat(summary.getErrors()).isEqualTo(3);
// Oldest living pod is now pod2
assertThat(summary.getStart().get()).isEqualTo(sdf.parse("31-01-2018 10:22:56"));
collector.close();
}
use of io.syndesis.common.model.metrics.IntegrationMetricsSummary in project syndesis by syndesisio.
the class MetricsCollectorTest method testDeletedIntegrationsCurator.
@Test
public void testDeletedIntegrationsCurator() throws IOException, ParseException {
String integrationId = "intId1";
Set<String> livePodIds = new HashSet<String>(Arrays.asList("pod1", "pod2"));
Map<String, RawMetrics> metrics = jsondbRM.getRawMetrics(integrationId);
IntegrationMetricsSummary summary = intMH.compute(integrationId, metrics, livePodIds);
dataManager.create(summary);
assertThat(metrics.size()).isEqualTo(3);
assertThat(dataManager.fetchAll(IntegrationMetricsSummary.class).getTotalCount()).isEqualTo(1);
// Now pretend to delete the integration itself and
// run the curator with no active integrations
jsondbRM.curate(new HashSet<String>());
intMH.curate(new HashSet<String>());
// expect all metrics to be deleted
Map<String, RawMetrics> metricsAfter = jsondbRM.getRawMetrics(integrationId);
assertThat(metricsAfter.size()).isEqualTo(0);
assertThat(dataManager.fetchAll(IntegrationMetricsSummary.class).getTotalCount()).isEqualTo(0);
}
Aggregations