Search in sources :

Example 11 with MicrometerRegistry

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

the class StyxServerComponentsTest method loadsServices.

@Test
public void loadsServices() {
    StyxServerComponents components = new StyxServerComponents.Builder().registry(new MicrometerRegistry(new CompositeMeterRegistry())).styxConfig(new StyxConfig()).services((env, routeDb) -> 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) StyxService(com.hotels.styx.api.extension.service.spi.StyxService) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) StyxConfig(com.hotels.styx.StyxConfig) NamedPlugin(com.hotels.styx.proxy.plugin.NamedPlugin) LoggingSetUp(com.hotels.styx.startup.StyxServerComponents.LoggingSetUp) Map(java.util.Map) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) Configuration(com.hotels.styx.api.configuration.Configuration) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Eventual(com.hotels.styx.api.Eventual) Plugin(com.hotels.styx.api.plugins.spi.Plugin) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) UTF_8(java.nio.charset.StandardCharsets.UTF_8) HttpResponse.response(com.hotels.styx.api.HttpResponse.response) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) Matchers.any(org.mockito.Matchers.any) List(java.util.List) IsOptional.isValue(com.hotels.styx.support.matchers.IsOptional.isValue) Collectors.toList(java.util.stream.Collectors.toList) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Environment(com.hotels.styx.Environment) ConfiguredPluginFactory(com.hotels.styx.startup.extensions.ConfiguredPluginFactory) Matchers.is(org.hamcrest.Matchers.is) Mockito.mock(org.mockito.Mockito.mock) 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 12 with MicrometerRegistry

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

the class InstrumentedPluginTest method setUp.

@BeforeEach
public void setUp() {
    registry = new MicrometerRegistry(new SimpleMeterRegistry());
    environment = new Environment.Builder().registry(registry).build();
    someRequest = get("/").build();
    chain = mock(Chain.class);
}
Also used : Chain(com.hotels.styx.api.HttpInterceptor.Chain) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Environment(com.hotels.styx.Environment) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with MicrometerRegistry

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

the class UrlRequestHealthCheckTest method setUp.

@BeforeEach
public void setUp() {
    metrics = new CentralisedMetrics(new MicrometerRegistry(new SimpleMeterRegistry()));
    originState = null;
    requestedUrl = null;
}
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 14 with MicrometerRegistry

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

the class FileBackedBackendServicesRegistryFactoryTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    tempDir = createTempDirectory("");
    monitoredFile = Paths.get(tempDir.toString(), "origins.yml");
    write(monitoredFile, "content-v1");
    environment = new com.hotels.styx.Environment.Builder().registry(new MicrometerRegistry(new SimpleMeterRegistry())).build();
}
Also used : MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Environment(com.hotels.styx.api.Environment) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 15 with MicrometerRegistry

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

the class BackendServicesRouterTest method deregistersAndReregistersMetricsAppropriately.

// This test exists due to a real bug we had when reloading in prod
@Test
public void deregistersAndReregistersMetricsAppropriately() {
    MeterRegistry metrics = new MicrometerRegistry(new SimpleMeterRegistry());
    Environment environment = new Environment.Builder().registry(metrics).build();
    MeterRegistry meterRegistry = environment.meterRegistry();
    BackendServicesRouter router = new BackendServicesRouter(new StyxBackendServiceClientFactory(environment), environment, executor);
    router.onChange(added(backendService(APP_B, "/appB/", 9094, "appB-01", 9095, "appB-02")));
    Tags tags01 = Tags.of(APPID_TAG, APP_B, ORIGINID_TAG, "appB-01");
    Tags tags02 = Tags.of(APPID_TAG, APP_B, ORIGINID_TAG, "appB-02");
    assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags01).gauge().value(), is(1.0));
    assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags02).gauge().value(), is(1.0));
    BackendService appMinusOneOrigin = backendService(APP_B, "/appB/", 9094, "appB-01");
    router.onChange(updated(appMinusOneOrigin));
    assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags01).gauge().value(), is(1.0));
    assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags02).gauge(), is(nullValue()));
}
Also used : BackendService(com.hotels.styx.api.extension.service.BackendService) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Origin.newOriginBuilder(com.hotels.styx.api.extension.Origin.newOriginBuilder) BackendService.newBackendServiceBuilder(com.hotels.styx.api.extension.service.BackendService.newBackendServiceBuilder) Environment(com.hotels.styx.Environment) Tags(io.micrometer.core.instrument.Tags) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(com.hotels.styx.api.MeterRegistry) 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