use of com.hotels.styx.server.RequestStatsCollector 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));
}
use of com.hotels.styx.server.RequestStatsCollector 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.server.RequestStatsCollector 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