Search in sources :

Example 1 with MicrometerRegistry

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

the class StyxServerTest method disablesResourceLeakDetectionByDefault.

@Test
public void disablesResourceLeakDetectionByDefault() {
    StyxServerComponents config = new StyxServerComponents.Builder().registry(new MicrometerRegistry(new CompositeMeterRegistry())).configuration(EMPTY_CONFIGURATION).additionalServices(Map.of("backendServiceRegistry", new RegistryServiceAdapter(new MemoryBackedRegistry<>()))).build();
    new StyxServer(config);
    assertThat(ResourceLeakDetector.getLevel(), is(DISABLED));
}
Also used : StyxServerComponents(com.hotels.styx.startup.StyxServerComponents) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) MemoryBackedRegistry(com.hotels.styx.infrastructure.MemoryBackedRegistry) RegistryServiceAdapter(com.hotels.styx.infrastructure.RegistryServiceAdapter) Test(org.junit.jupiter.api.Test)

Example 2 with MicrometerRegistry

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

the class OriginsInventoryTest method setUp.

@BeforeEach
public void setUp() {
    meterRegistry = new MicrometerRegistry(new SimpleMeterRegistry());
    logger = new LoggingTestSupport(OriginsInventory.class);
    monitor = mock(OriginHealthStatusMonitor.class);
    eventBus = mock(EventBus.class);
    inventory = new OriginsInventory(eventBus, GENERIC_APP, monitor, connectionFactory, hostClientFactory, new CentralisedMetrics(meterRegistry));
}
Also used : MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) OriginHealthStatusMonitor(com.hotels.styx.client.healthcheck.OriginHealthStatusMonitor) EventBus(com.google.common.eventbus.EventBus) LoggingTestSupport(com.hotels.styx.support.matchers.LoggingTestSupport) CentralisedMetrics(com.hotels.styx.metrics.CentralisedMetrics) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with MicrometerRegistry

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

the class StyxBackendServiceClientTest method setUp.

@BeforeEach
public void setUp() {
    meterRegistry = new MicrometerRegistry(new SimpleMeterRegistry());
    metrics = new CentralisedMetrics(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 4 with MicrometerRegistry

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

the class SimpleConnectionPoolFactoryTest method registersMetricsUnderOriginsScope.

@Test
public void registersMetricsUnderOriginsScope() {
    MeterRegistry meterRegistry = new MicrometerRegistry(new SimpleMeterRegistry());
    SimpleConnectionPoolFactory factory = new SimpleConnectionPoolFactory.Builder().connectionFactory(mock(Connection.Factory.class)).connectionPoolSettings(defaultConnectionPoolSettings()).metrics(new CentralisedMetrics(meterRegistry)).build();
    factory.create(origin);
    Tags tags = Tags.of("appId", "test-app", "originId", "origin-X");
    assertThat(meterRegistry.find("proxy.client.connectionpool.pendingConnections").tags(tags).gauge(), notNullValue());
    assertThat(meterRegistry.find("proxy.client.connectionpool.availableConnections").tags(tags).gauge(), notNullValue());
    assertThat(meterRegistry.find("proxy.client.connectionpool.busyConnections").tags(tags).gauge(), notNullValue());
    assertThat(meterRegistry.find("proxy.client.connectionpool.connectionsInEstablishment").tags(tags).gauge(), notNullValue());
}
Also used : MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Origin.newOriginBuilder(com.hotels.styx.api.extension.Origin.newOriginBuilder) Connection(com.hotels.styx.client.Connection) CentralisedMetrics(com.hotels.styx.metrics.CentralisedMetrics) 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)

Example 5 with MicrometerRegistry

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

the class HttpPipelineHandlerTest method updatesRequestsOngoingCountOnChannelReadEvent.

@Test
public void updatesRequestsOngoingCountOnChannelReadEvent() throws Exception {
    MeterRegistry registry = new MicrometerRegistry(new SimpleMeterRegistry());
    HttpPipelineHandler pipelineHandler = handlerWithMocks(doNotRespondHandler).responseEnhancer(DO_NOT_MODIFY_RESPONSE).progressListener(new RequestStatsCollector(new CentralisedMetrics(registry))).build();
    ChannelHandlerContext ctx = mockCtx();
    pipelineHandler.channelActive(ctx);
    pipelineHandler.channelRead0(ctx, get("/foo").build());
    assertThat(requestOutstandingValue(registry), is(1.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)

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