Search in sources :

Example 11 with CentralisedMetrics

use of com.hotels.styx.metrics.CentralisedMetrics in project styx by ExpediaGroup.

the class HttpPipelineHandlerTest method decrementsRequestsOngoingCountOnChannelInactiveWhenRequestIsOngoing.

@Test
public void decrementsRequestsOngoingCountOnChannelInactiveWhenRequestIsOngoing() throws Exception {
    MeterRegistry registry = new MicrometerRegistry(new SimpleMeterRegistry());
    HttpPipelineHandler adapter = handlerWithMocks(doNotRespondHandler).responseEnhancer(DO_NOT_MODIFY_RESPONSE).progressListener(new RequestStatsCollector(new CentralisedMetrics(registry))).build();
    ChannelHandlerContext ctx = mockCtx();
    adapter.channelActive(ctx);
    adapter.channelRead0(ctx, get("/foo").build());
    assertThat(requestOutstandingValue(registry), is(1.0));
    adapter.channelInactive(ctx);
    assertThat(requestOutstandingValue(registry), is(0.0));
}
Also used : RequestStatsCollector(com.hotels.styx.server.RequestStatsCollector) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) CentralisedMetrics(com.hotels.styx.metrics.CentralisedMetrics) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(com.hotels.styx.api.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 12 with CentralisedMetrics

use of com.hotels.styx.metrics.CentralisedMetrics in project styx by ExpediaGroup.

the class CoreMetricsTest method registersOperatingSystemMetrics.

@Test
public void registersOperatingSystemMetrics() {
    MeterRegistry registry = new MicrometerRegistry(new SimpleMeterRegistry());
    CoreMetricsKt.registerCoreMetrics(new CentralisedMetrics(registry));
    List<String> gauges = registry.getMeters().stream().map(meter -> meter.getId().getName()).collect(Collectors.toList());
    assertThat(gauges, hasItems("os.process.cpu.load", "os.process.cpu.time", "os.system.cpu.load", "os.memory.physical.free", "os.memory.physical.total", "os.memory.virtual.committed", "os.swapSpace.free", "os.swapSpace.total"));
}
Also used : Test(org.junit.jupiter.api.Test) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) List(java.util.List) MeterRegistry(com.hotels.styx.api.MeterRegistry) Matchers.hasSize(org.hamcrest.Matchers.hasSize) CentralisedMetrics(com.hotels.styx.metrics.CentralisedMetrics) Version(com.hotels.styx.Version) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Collectors(java.util.stream.Collectors) Matchers.hasItems(org.hamcrest.Matchers.hasItems) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) CentralisedMetrics(com.hotels.styx.metrics.CentralisedMetrics) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(com.hotels.styx.api.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 13 with CentralisedMetrics

use of com.hotels.styx.metrics.CentralisedMetrics in project styx by ExpediaGroup.

the class CoreMetricsTest method registersJvmMetrics.

@Test
public void registersJvmMetrics() {
    MeterRegistry registry = new MicrometerRegistry(new SimpleMeterRegistry());
    CoreMetricsKt.registerCoreMetrics(new CentralisedMetrics(registry));
    assertThat(registry.find("jvm.uptime").gauges(), hasSize(1));
    assertThat(registry.find("proxy.netty.buffers.memory").tags("allocator", "pooled", "memoryType", "direct").gauges(), hasSize(1));
    assertThat(registry.find("proxy.netty.buffers.memory").tags("allocator", "pooled", "memoryType", "heap").gauges(), hasSize(1));
    assertThat(registry.find("proxy.netty.buffers.memory").tags("allocator", "unpooled", "memoryType", "direct").gauges(), hasSize(1));
    assertThat(registry.find("proxy.netty.buffers.memory").tags("allocator", "unpooled", "memoryType", "heap").gauges(), hasSize(1));
}
Also used : MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) CentralisedMetrics(com.hotels.styx.metrics.CentralisedMetrics) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(com.hotels.styx.api.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 14 with CentralisedMetrics

use of com.hotels.styx.metrics.CentralisedMetrics in project styx by ExpediaGroup.

the class ChannelStatisticsHandlerTest method createHandler.

@BeforeEach
public void createHandler() {
    this.meterRegistry = new MicrometerRegistry(new SimpleMeterRegistry());
    this.handler = new ChannelStatisticsHandler(new CentralisedMetrics(this.meterRegistry));
}
Also used : MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) CentralisedMetrics(com.hotels.styx.metrics.CentralisedMetrics) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with CentralisedMetrics

use of com.hotels.styx.metrics.CentralisedMetrics in project styx by ExpediaGroup.

the class RequestStatsCollectorTest method setUp.

@BeforeEach
public void setUp() {
    metrics = new MicrometerRegistry(new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock));
    clock.setNanoTime(0);
    CentralisedMetrics centralisedMetrics = new CentralisedMetrics(metrics);
    sink = new RequestStatsCollector(centralisedMetrics);
}
Also used : MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) CentralisedMetrics(com.hotels.styx.metrics.CentralisedMetrics) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

CentralisedMetrics (com.hotels.styx.metrics.CentralisedMetrics)15 MicrometerRegistry (com.hotels.styx.api.MicrometerRegistry)12 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)12 Test (org.junit.jupiter.api.Test)9 MeterRegistry (com.hotels.styx.api.MeterRegistry)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 ConnectionPool (com.hotels.styx.client.connectionpool.ConnectionPool)3 RequestStatsCollector (com.hotels.styx.server.RequestStatsCollector)3 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)3 Origin (com.hotels.styx.api.extension.Origin)2 DisableOrigin (com.hotels.styx.client.origincommands.DisableOrigin)2 EnableOrigin (com.hotels.styx.client.origincommands.EnableOrigin)2 EventBus (com.google.common.eventbus.EventBus)1 Version (com.hotels.styx.Version)1 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)1 Origin.newOriginBuilder (com.hotels.styx.api.extension.Origin.newOriginBuilder)1 OriginsSnapshot (com.hotels.styx.api.extension.OriginsSnapshot)1 Connection (com.hotels.styx.client.Connection)1 OriginHealthStatusMonitor (com.hotels.styx.client.healthcheck.OriginHealthStatusMonitor)1 LoggingTestSupport (com.hotels.styx.support.matchers.LoggingTestSupport)1