use of com.hotels.styx.metrics.CentralisedMetrics 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.metrics.CentralisedMetrics in project styx by ExpediaGroup.
the class OriginsInventoryTest method shutsConnectionPoolForRemovedOrigin.
@Test
public void shutsConnectionPoolForRemovedOrigin() {
Origin originV1 = newOriginBuilder("acme01.com", 80).applicationId(GENERIC_APP).id("acme-01").build();
Origin originV2 = newOriginBuilder("acme02.com", 80).applicationId(GENERIC_APP).id("acme-02").build();
ConnectionPool.Factory connectionFactory = mock(ConnectionPool.Factory.class);
ConnectionPool pool1 = mock(ConnectionPool.class);
when(pool1.getOrigin()).thenReturn(originV1);
ConnectionPool pool2 = mock(ConnectionPool.class);
when(pool2.getOrigin()).thenReturn(originV2);
when(connectionFactory.create(eq(originV1))).thenReturn(pool1);
when(connectionFactory.create(eq(originV2))).thenReturn(pool2);
inventory = new OriginsInventory(eventBus, GENERIC_APP, monitor, connectionFactory, hostClientFactory, new CentralisedMetrics(meterRegistry));
inventory.setOrigins(originV1, originV2);
inventory.setOrigins(originV2);
verify(pool1).close();
}
use of com.hotels.styx.metrics.CentralisedMetrics 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;
}
use of com.hotels.styx.metrics.CentralisedMetrics 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.metrics.CentralisedMetrics 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));
}
Aggregations