Search in sources :

Example 1 with IntegrationMetricsSummary

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);
}
Also used : IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) Date(java.util.Date) Then(cucumber.api.java.en.Then)

Example 2 with IntegrationMetricsSummary

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);
}
Also used : IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) List(java.util.List) Test(org.junit.Test)

Example 3 with IntegrationMetricsSummary

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);
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) HashSet(java.util.HashSet) Service(org.springframework.stereotype.Service) Map(java.util.Map) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DataManager(io.syndesis.server.dao.manager.DataManager) Integration(io.syndesis.common.model.integration.Integration) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty) ExecutorService(java.util.concurrent.ExecutorService) Logger(org.slf4j.Logger) CustomizableThreadFactory(org.springframework.scheduling.concurrent.CustomizableThreadFactory) Set(java.util.Set) Pod(io.fabric8.kubernetes.api.model.Pod) IOException(java.io.IOException) JsonDB(io.syndesis.server.jsondb.JsonDB) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Closeable(java.io.Closeable) PostConstruct(javax.annotation.PostConstruct) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Readiness(io.fabric8.kubernetes.client.internal.readiness.Readiness) Collections(java.util.Collections) IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) Pod(io.fabric8.kubernetes.api.model.Pod) IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 4 with IntegrationMetricsSummary

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();
}
Also used : IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with IntegrationMetricsSummary

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);
}
Also used : IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

IntegrationMetricsSummary (io.syndesis.common.model.metrics.IntegrationMetricsSummary)10 Test (org.junit.Test)5 HashSet (java.util.HashSet)4 Date (java.util.Date)3 List (java.util.List)3 IntegrationDeploymentMetrics (io.syndesis.common.model.metrics.IntegrationDeploymentMetrics)2 Then (cucumber.api.java.en.Then)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 Readiness (io.fabric8.kubernetes.client.internal.readiness.Readiness)1 Integration (io.syndesis.common.model.integration.Integration)1 SyndesisServerException (io.syndesis.common.util.SyndesisServerException)1 DataManager (io.syndesis.server.dao.manager.DataManager)1 JsonDB (io.syndesis.server.jsondb.JsonDB)1 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1