use of com.hotels.styx.api.MeterRegistry 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());
}
use of com.hotels.styx.api.MeterRegistry 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.api.MeterRegistry in project styx by ExpediaGroup.
the class BackendServicesRouterTest method deregistersAndReregistersMetricsAppropriately.
// This test exists due to a real bug we had when reloading in prod
@Test
public void deregistersAndReregistersMetricsAppropriately() {
MeterRegistry metrics = new MicrometerRegistry(new SimpleMeterRegistry());
Environment environment = new Environment.Builder().registry(metrics).build();
MeterRegistry meterRegistry = environment.meterRegistry();
BackendServicesRouter router = new BackendServicesRouter(new StyxBackendServiceClientFactory(environment), environment, executor);
router.onChange(added(backendService(APP_B, "/appB/", 9094, "appB-01", 9095, "appB-02")));
Tags tags01 = Tags.of(APPID_TAG, APP_B, ORIGINID_TAG, "appB-01");
Tags tags02 = Tags.of(APPID_TAG, APP_B, ORIGINID_TAG, "appB-02");
assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags01).gauge().value(), is(1.0));
assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags02).gauge().value(), is(1.0));
BackendService appMinusOneOrigin = backendService(APP_B, "/appB/", 9094, "appB-01");
router.onChange(updated(appMinusOneOrigin));
assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags01).gauge().value(), is(1.0));
assertThat(meterRegistry.find("proxy.client.originHealthStatus").tags(tags02).gauge(), is(nullValue()));
}
use of com.hotels.styx.api.MeterRegistry 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.MeterRegistry 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