Search in sources :

Example 6 with MeterRegistry

use of com.hotels.styx.api.MeterRegistry 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 7 with MeterRegistry

use of com.hotels.styx.api.MeterRegistry 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)

Aggregations

MeterRegistry (com.hotels.styx.api.MeterRegistry)7 MicrometerRegistry (com.hotels.styx.api.MicrometerRegistry)7 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)7 Test (org.junit.jupiter.api.Test)7 CentralisedMetrics (com.hotels.styx.metrics.CentralisedMetrics)6 RequestStatsCollector (com.hotels.styx.server.RequestStatsCollector)3 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)3 Origin.newOriginBuilder (com.hotels.styx.api.extension.Origin.newOriginBuilder)2 Tags (io.micrometer.core.instrument.Tags)2 Environment (com.hotels.styx.Environment)1 Version (com.hotels.styx.Version)1 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)1 BackendService (com.hotels.styx.api.extension.service.BackendService)1 BackendService.newBackendServiceBuilder (com.hotels.styx.api.extension.service.BackendService.newBackendServiceBuilder)1 Connection (com.hotels.styx.client.Connection)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.hasItems (org.hamcrest.Matchers.hasItems)1 Matchers.hasSize (org.hamcrest.Matchers.hasSize)1