Search in sources :

Example 16 with MicrometerRegistry

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

the class HttpErrorStatusMetricsTest method setUp.

@BeforeEach
public void setUp() {
    registry = new SimpleMeterRegistry();
    metrics = new CentralisedMetrics(new MicrometerRegistry(registry));
    errorListener = new HttpErrorStatusMetrics(metrics);
}
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 17 with MicrometerRegistry

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

the class StyxServer method createStyxServer.

private static StyxServer createStyxServer(String[] args) {
    Stopwatch stopwatch = new Stopwatch();
    StartupConfig startupConfig = parseStartupConfig(args);
    LOG.info("Styx home={}", startupConfig.styxHome());
    LOG.info("Styx configFileLocation={}", startupConfig.configFileLocation());
    LOG.info("Styx logConfigLocation={}", startupConfig.logConfigLocation());
    PrometheusMeterRegistry prometheusRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
    CompositeMeterRegistry compositeMeterRegistry = new CompositeMeterRegistry();
    compositeMeterRegistry.add(prometheusRegistry);
    StyxServerComponents components = new StyxServerComponents.Builder().registry(new MicrometerRegistry(compositeMeterRegistry)).styxConfig(parseConfiguration(startupConfig)).startupConfig(startupConfig).loggingSetUp(environment -> activateLogbackConfigurer(startupConfig)).showBanner(true).build();
    return new StyxServer(components, stopwatch);
}
Also used : PrometheusMeterRegistry(io.micrometer.prometheus.PrometheusMeterRegistry) CompositeMeterRegistry(io.micrometer.core.instrument.composite.CompositeMeterRegistry) StyxServerComponents(com.hotels.styx.startup.StyxServerComponents) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) NettyServerBuilder(com.hotels.styx.server.netty.NettyServerBuilder) AdminServerBuilder(com.hotels.styx.admin.AdminServerBuilder) Stopwatch(com.hotels.styx.javaconvenience.Stopwatch)

Example 18 with MicrometerRegistry

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

the class HttpPipelineHandlerTest method createHandler.

private HttpPipelineHandler createHandler(HttpHandler pipeline) throws Exception {
    metrics = new MicrometerRegistry(new SimpleMeterRegistry());
    HttpPipelineHandler handler = handlerWithMocks(pipeline).responseWriterFactory(responseWriterFactory).build();
    handler.channelActive(ctx);
    return handler;
}
Also used : MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry)

Example 19 with MicrometerRegistry

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

the class HttpPipelineHandlerTest method decrementsRequestsOngoingOnExceptionCaught.

@Test
public void decrementsRequestsOngoingOnExceptionCaught() throws Exception {
    MeterRegistry registry = new MicrometerRegistry(new SimpleMeterRegistry());
    HttpPipelineHandler adapter = handlerWithMocks(doNotRespondHandler).progressListener(new RequestStatsCollector(new CentralisedMetrics(registry))).build();
    ChannelHandlerContext ctx = mockCtx();
    adapter.channelActive(ctx);
    LiveHttpRequest request = get("/foo").build();
    adapter.channelRead0(ctx, request);
    assertThat(requestOutstandingValue(registry), is(1.0));
    adapter.exceptionCaught(ctx, new Throwable("Exception"));
    assertThat(requestOutstandingValue(registry), is(0.0));
    adapter.channelInactive(ctx);
    assertThat(requestOutstandingValue(registry), is(0.0));
    verify(responseEnhancer).enhance(any(LiveHttpResponse.Transformer.class), eq(request));
}
Also used : RequestStatsCollector(com.hotels.styx.server.RequestStatsCollector) MicrometerRegistry(com.hotels.styx.api.MicrometerRegistry) LiveHttpRequest(com.hotels.styx.api.LiveHttpRequest) 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 20 with MicrometerRegistry

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

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