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);
}
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);
}
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;
}
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));
}
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));
}
Aggregations