use of com.hotels.styx.api.HttpInterceptor.Chain in project styx by ExpediaGroup.
the class InstrumentedPluginTest method metricIsNotRecordedWhenErrorStatusIsReturnedByChain.
@Test
public void metricIsNotRecordedWhenErrorStatusIsReturnedByChain() {
Chain chain = request -> aResponse(INTERNAL_SERVER_ERROR);
String pluginName = "doNotRecordMe";
InstrumentedPlugin plugin = instrumentedPlugin(pluginName, PASS_THROUGH);
LiveHttpResponse response = Mono.from(plugin.intercept(someRequest, chain)).block();
assertThat(response.status(), is(INTERNAL_SERVER_ERROR));
assertThat(getStatusCount(pluginName, "500"), is(0.0));
assertThat(getErrorCount(pluginName), is(0.0));
}
use of com.hotels.styx.api.HttpInterceptor.Chain in project styx by ExpediaGroup.
the class InstrumentedPluginTest method metricIsRecordedWhenResponseIsMappedToErrorStatus.
@Test
public void metricIsRecordedWhenResponseIsMappedToErrorStatus() {
Chain chain = request -> aResponse(OK);
String pluginName = "replaceStatus1";
InstrumentedPlugin plugin = instrumentedPlugin(pluginName, (request, aChain) -> aChain.proceed(request).map(response -> responseWithNewStatusCode(response, INTERNAL_SERVER_ERROR)));
LiveHttpResponse response = Mono.from(plugin.intercept(someRequest, chain)).block();
assertThat(response.status(), is(INTERNAL_SERVER_ERROR));
assertThat(getStatusCount(pluginName, "500"), is(1.0));
assertThat(getErrorCount(pluginName), is(1.0));
}
use of com.hotels.styx.api.HttpInterceptor.Chain in project styx by ExpediaGroup.
the class InstrumentedPluginTest method setUp.
@BeforeEach
public void setUp() {
registry = new MicrometerRegistry(new SimpleMeterRegistry());
environment = new Environment.Builder().registry(registry).build();
someRequest = get("/").build();
chain = mock(Chain.class);
}
use of com.hotels.styx.api.HttpInterceptor.Chain in project styx by ExpediaGroup.
the class InstrumentedPluginTest method metricsAreNotRecordedWhenExceptionIsReturnedByChain.
@Test
public void metricsAreNotRecordedWhenExceptionIsReturnedByChain() {
String pluginName = "passThrough";
Chain chain = request -> error(new SomeException());
InstrumentedPlugin plugin = instrumentedPlugin(pluginName, PASS_THROUGH);
assertThatEventualHasErrorOnly(SomeException.class, plugin.intercept(someRequest, chain));
assertThat(getExceptionCount(pluginName, SOME_EXCEPTION), is(0.0));
assertThat(getErrorCount(pluginName), is(0.0));
}
use of com.hotels.styx.api.HttpInterceptor.Chain in project styx by ExpediaGroup.
the class InstrumentedPluginTest method errorsMetricIsNotRecordedWhenResponseIsMappedToNon5005xxStatus.
@Test
public void errorsMetricIsNotRecordedWhenResponseIsMappedToNon5005xxStatus() {
Chain chain = request -> aResponse(OK);
String pluginName = "replaceStatusCodeY";
InstrumentedPlugin plugin = instrumentedPlugin("replaceStatusCodeY", (request, aChain) -> aChain.proceed(request).map(response -> responseWithNewStatusCode(response, BAD_GATEWAY)));
LiveHttpResponse response = Mono.from(plugin.intercept(someRequest, chain)).block();
assertThat(response.status(), is(BAD_GATEWAY));
assertThat(getStatusCount(pluginName, "502"), is(1.0));
assertThat(getErrorCount(pluginName), is(0.0));
}
Aggregations