Search in sources :

Example 1 with HistogramDto

use of ee.ria.xroad.monitor.common.dto.HistogramDto in project X-Road by nordic-institute.

the class SecurityServerMetricsMessage method createMetricsResponse.

private static SystemMetricsResponse createMetricsResponse() {
    HistogramDto histogramDto = new HistogramDto("exampleHistogram", 75, 95, 98, 99, 99.9, MAX_VALUE, 50, 51, MIN_VALUE, 2);
    MetricSetDto.Builder builder = new MetricSetDto.Builder(EXPECTED_METRIC_SET_NAME);
    builder.withMetric(histogramDto);
    return new SystemMetricsResponse(builder.build());
}
Also used : HistogramDto(ee.ria.xroad.monitor.common.dto.HistogramDto) SystemMetricsResponse(ee.ria.xroad.monitor.common.SystemMetricsResponse) MetricSetDto(ee.ria.xroad.monitor.common.dto.MetricSetDto)

Example 2 with HistogramDto

use of ee.ria.xroad.monitor.common.dto.HistogramDto in project X-Road by nordic-institute.

the class MetricTypes method of.

/**
 * MetricSetType factory
 */
public static MetricSetType of(MetricSetDto metrics) {
    final MetricSetType metricSet = new MetricSetType();
    metricSet.setName(metrics.getName());
    for (MetricDto metricDto : metrics.getMetrics()) {
        if (metricDto instanceof MetricSetDto) {
            metricSet.getMetrics().add(of((MetricSetDto) metricDto));
        } else if (metricDto instanceof HistogramDto) {
            metricSet.getMetrics().add(toMetricType((HistogramDto) metricDto));
        } else if (metricDto instanceof SimpleMetricDto) {
            metricSet.getMetrics().add(toMetricType((SimpleMetricDto<?>) metricDto));
        }
    }
    return metricSet;
}
Also used : HistogramDto(ee.ria.xroad.monitor.common.dto.HistogramDto) MetricDto(ee.ria.xroad.monitor.common.dto.MetricDto) SimpleMetricDto(ee.ria.xroad.monitor.common.dto.SimpleMetricDto) SimpleMetricDto(ee.ria.xroad.monitor.common.dto.SimpleMetricDto) MetricSetDto(ee.ria.xroad.monitor.common.dto.MetricSetDto) MetricSetType(ee.ria.xroad.proxymonitor.message.MetricSetType)

Example 3 with HistogramDto

use of ee.ria.xroad.monitor.common.dto.HistogramDto in project X-Road by nordic-institute.

the class MetricsProviderActorTest method testAllSystemMetricsRequest.

@Test
public void testAllSystemMetricsRequest() throws Exception {
    final Props props = Props.create(MetricsProviderActor.class);
    final TestActorRef<MetricsProviderActor> ref = TestActorRef.create(actorSystem, props, "testActorRef");
    Future<Object> future = Patterns.ask(ref, new SystemMetricsRequest(null, true), Timeout.apply(1, TimeUnit.MINUTES));
    Object result = Await.result(future, Duration.apply(1, TimeUnit.MINUTES));
    assertTrue(future.isCompleted());
    assertTrue(result instanceof SystemMetricsResponse);
    SystemMetricsResponse response = (SystemMetricsResponse) result;
    MetricSetDto metricSetDto = response.getMetrics();
    Set<MetricDto> dtoSet = metricSetDto.getMetrics();
    log.info("metricSetDto: " + metricSetDto);
    assertEquals(2, dtoSet.stream().count());
    for (MetricDto metricDto : dtoSet) {
        // Order of entries is undefined -> Must handle by name
        switch(metricDto.getName()) {
            case HISTOGRAM_NAME:
                log.info("metricDto: " + metricDto);
                assertEquals(HISTOGRAM_NAME, metricDto.getName());
                assertTrue(metricDto instanceof HistogramDto);
                HistogramDto h = (HistogramDto) metricDto;
                assertEquals(100L, (long) h.getMax());
                assertEquals(10L, (long) h.getMin());
                assertEquals(55L, (long) h.getMean());
                break;
            case GAUGE_NAME:
                log.info("metricDto: " + metricDto);
                assertEquals(GAUGE_NAME, metricDto.getName());
                break;
            default:
                Assert.fail("Unknown metric found in response.");
        }
    }
}
Also used : HistogramDto(ee.ria.xroad.monitor.common.dto.HistogramDto) SystemMetricsResponse(ee.ria.xroad.monitor.common.SystemMetricsResponse) MetricDto(ee.ria.xroad.monitor.common.dto.MetricDto) SystemMetricsRequest(ee.ria.xroad.monitor.common.SystemMetricsRequest) MetricSetDto(ee.ria.xroad.monitor.common.dto.MetricSetDto) Props(akka.actor.Props) Test(org.junit.Test)

Example 4 with HistogramDto

use of ee.ria.xroad.monitor.common.dto.HistogramDto in project X-Road by nordic-institute.

the class MetricsProviderActorTest method testParametrizedSystemMetricsRequest.

@Test
public void testParametrizedSystemMetricsRequest() throws Exception {
    final Props props = Props.create(MetricsProviderActor.class);
    final TestActorRef<MetricsProviderActor> ref = TestActorRef.create(actorSystem, props, "testActorRef");
    Future<Object> future = Patterns.ask(ref, new SystemMetricsRequest(Arrays.asList(HISTOGRAM_NAME), true), Timeout.apply(1, TimeUnit.MINUTES));
    Object result = Await.result(future, Duration.apply(1, TimeUnit.MINUTES));
    assertTrue(future.isCompleted());
    assertTrue(result instanceof SystemMetricsResponse);
    SystemMetricsResponse response = (SystemMetricsResponse) result;
    MetricSetDto metricSetDto = response.getMetrics();
    Set<MetricDto> dtoSet = metricSetDto.getMetrics();
    log.info("metricSetDto: " + metricSetDto);
    assertEquals(1, dtoSet.stream().count());
    // Note: findFirst() works only because of single result
    MetricDto metricDto = dtoSet.stream().findFirst().get();
    assertEquals(HISTOGRAM_NAME, metricDto.getName());
    assertTrue(metricDto instanceof HistogramDto);
    HistogramDto h = (HistogramDto) metricDto;
    assertEquals(100L, (long) h.getMax());
    assertEquals(10L, (long) h.getMin());
    assertEquals(55L, (long) h.getMean());
}
Also used : HistogramDto(ee.ria.xroad.monitor.common.dto.HistogramDto) SystemMetricsResponse(ee.ria.xroad.monitor.common.SystemMetricsResponse) MetricDto(ee.ria.xroad.monitor.common.dto.MetricDto) SystemMetricsRequest(ee.ria.xroad.monitor.common.SystemMetricsRequest) MetricSetDto(ee.ria.xroad.monitor.common.dto.MetricSetDto) Props(akka.actor.Props) Test(org.junit.Test)

Aggregations

HistogramDto (ee.ria.xroad.monitor.common.dto.HistogramDto)4 MetricSetDto (ee.ria.xroad.monitor.common.dto.MetricSetDto)4 SystemMetricsResponse (ee.ria.xroad.monitor.common.SystemMetricsResponse)3 MetricDto (ee.ria.xroad.monitor.common.dto.MetricDto)3 Props (akka.actor.Props)2 SystemMetricsRequest (ee.ria.xroad.monitor.common.SystemMetricsRequest)2 Test (org.junit.Test)2 SimpleMetricDto (ee.ria.xroad.monitor.common.dto.SimpleMetricDto)1 MetricSetType (ee.ria.xroad.proxymonitor.message.MetricSetType)1