Search in sources :

Example 21 with MicrometerRegistry

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

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

use of com.hotels.styx.api.MicrometerRegistry in project styx by ExpediaGroup.

the class StyxServerComponentsTest method exposesAdditionalServices.

@Test
public void exposesAdditionalServices() {
    StyxServerComponents components = new StyxServerComponents.Builder().registry(new MicrometerRegistry((new CompositeMeterRegistry()))).styxConfig(new StyxConfig()).additionalServices(Map.of("service1", mock(StyxService.class), "service2", mock(StyxService.class))).build();
    Map<String, StyxService> services = components.services();
    assertThat(services.keySet(), containsInAnyOrder("service1", "service2"));
}
Also used : CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) StyxConfig(com.hotels.styx.StyxConfig) StyxService(com.hotels.styx.api.extension.service.spi.StyxService) Test(org.junit.jupiter.api.Test)

Example 24 with MicrometerRegistry

use of com.hotels.styx.api.MicrometerRegistry in project styx by ExpediaGroup.

the class StyxServerComponentsTest method createsEnvironment.

@Test
public void createsEnvironment() {
    Configuration config = new Configuration.MapBackedConfiguration().set("foo", "abc").set("bar", "def");
    StyxServerComponents components = new StyxServerComponents.Builder().registry(new MicrometerRegistry(new CompositeMeterRegistry())).styxConfig(new StyxConfig(config)).build();
    Environment environment = components.environment();
    assertThat(environment.configuration().get("foo", String.class), isValue("abc"));
    assertThat(environment.configuration().get("bar", String.class), isValue("def"));
    assertThat(environment.eventBus(), is(notNullValue()));
    assertThat(environment.metricRegistry(), is(notNullValue()));
}
Also used : CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) StyxConfig(com.hotels.styx.StyxConfig) Configuration(com.hotels.styx.api.configuration.Configuration) Environment(com.hotels.styx.Environment) Test(org.junit.jupiter.api.Test)

Example 25 with MicrometerRegistry

use of com.hotels.styx.api.MicrometerRegistry in project styx by ExpediaGroup.

the class StyxServerComponentsTest method setsUpLoggingOnBuild.

@Test
public void setsUpLoggingOnBuild() {
    LoggingSetUp loggingSetUp = mock(LoggingSetUp.class);
    new StyxServerComponents.Builder().registry(new MicrometerRegistry(new CompositeMeterRegistry())).styxConfig(new StyxConfig()).loggingSetUp(loggingSetUp).build();
    verify(loggingSetUp).setUp(any(Environment.class));
}
Also used : CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) StyxConfig(com.hotels.styx.StyxConfig) LoggingSetUp(com.hotels.styx.startup.StyxServerComponents.LoggingSetUp) Environment(com.hotels.styx.Environment) Test(org.junit.jupiter.api.Test)

Aggregations

MicrometerRegistry (com.hotels.styx.api.MicrometerRegistry)28 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)21 Test (org.junit.jupiter.api.Test)16 CentralisedMetrics (com.hotels.styx.metrics.CentralisedMetrics)12 BeforeEach (org.junit.jupiter.api.BeforeEach)11 Environment (com.hotels.styx.Environment)8 StyxConfig (com.hotels.styx.StyxConfig)7 MeterRegistry (com.hotels.styx.api.MeterRegistry)7 CompositeMeterRegistry (io.micrometer.core.instrument.composite.CompositeMeterRegistry)7 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)3 Origin.newOriginBuilder (com.hotels.styx.api.extension.Origin.newOriginBuilder)3 NamedPlugin (com.hotels.styx.proxy.plugin.NamedPlugin)3 List (java.util.List)3 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)3 Eventual (com.hotels.styx.api.Eventual)2 LiveHttpResponse (com.hotels.styx.api.LiveHttpResponse)2 Configuration (com.hotels.styx.api.configuration.Configuration)2 BackendService (com.hotels.styx.api.extension.service.BackendService)2 BackendService.newBackendServiceBuilder (com.hotels.styx.api.extension.service.BackendService.newBackendServiceBuilder)2 StyxService (com.hotels.styx.api.extension.service.spi.StyxService)2