@Test public void onEvent_should_do_nothing_if_passed_RESPONSE_SENT_with_value_object_that_is_not_a_HttpProcessingState() { // when listener.onEvent(ServerMetricsEvent.RESPONSE_SENT, new Object()); // then verifyZeroInteractions(listener.inflightRequests, listener.processedRequests); verify(endpointMetricsHandlerMock, never()).handleRequest( any(RequestInfo.class), any(ResponseInfo.class), any(HttpProcessingState.class), anyInt(), anyInt(), anyLong() ); }
/** * Initialize the endpoint and server config metrics. Note that the server config values will not be added if * {@link #includeServerConfigMetrics} is false, however {@link * EndpointMetricsHandler#setupEndpointsMetrics(ServerConfig, MetricRegistry)} will always be called. * * @param config The {@link ServerConfig} that contains the endpoints and server config values. */ public void initEndpointAndServerConfigMetrics(ServerConfig config) { if (includeServerConfigMetrics) addServerConfigMetrics(config); endpointMetricsHandler.setupEndpointsMetrics(config, metricsCollector.getMetricRegistry()); }
final int responseHttpStatusCodeXXValue = responseHttpStatusCode / 100; endpointMetricsHandler.handleRequest( requestInfo, responseInfo, httpState, responseHttpStatusCode, responseHttpStatusCodeXXValue, requestElapsedTimeMillis
verify(endpointMetricsHandlerMock).setupEndpointsMetrics(serverConfig, metricRegistryMock);
@Test public void onEvent_should_short_circuit_for_RESPONSE_SENT_if_request_info_is_null() { // given state.setRequestInfo(null); // when listener.onEvent(ServerMetricsEvent.RESPONSE_SENT, state); // then // Inflight requests and processed requests counters should still be adjusted properly verify(listener.inflightRequests).dec(); verify(listener.processedRequests).inc(); // But we should short circuit immediately afterward verifyZeroInteractions(listener.requestSizes, listener.responseSizes); verify(endpointMetricsHandlerMock, never()).handleRequest( any(RequestInfo.class), any(ResponseInfo.class), any(HttpProcessingState.class), anyInt(), anyInt(), anyLong() ); }
@Test public void onEvent_should_short_circuit_for_RESPONSE_SENT_if_response_info_is_null() { // given state.setResponseInfo(null, null); // when listener.onEvent(ServerMetricsEvent.RESPONSE_SENT, state); // then // Inflight requests and processed requests counters should still be adjusted properly verify(listener.inflightRequests).dec(); verify(listener.processedRequests).inc(); // But we should short circuit immediately afterward verifyZeroInteractions(listener.requestSizes, listener.responseSizes); verify(endpointMetricsHandlerMock, never()).handleRequest( any(RequestInfo.class), any(ResponseInfo.class), any(HttpProcessingState.class), anyInt(), anyInt(), anyLong() ); }
@Test public void onEvent_should_short_circuit_for_RESPONSE_SENT_if_request_start_time_nanos_is_null() { // given state.setRequestStartTimeNanos(null); // when listener.onEvent(ServerMetricsEvent.RESPONSE_SENT, state); // then // Inflight requests and processed requests counters should still be adjusted properly verify(listener.inflightRequests).dec(); verify(listener.processedRequests).inc(); // But we should short circuit immediately afterward verifyZeroInteractions(listener.requestSizes, listener.responseSizes); verify(endpointMetricsHandlerMock, never()).handleRequest( any(RequestInfo.class), any(ResponseInfo.class), any(HttpProcessingState.class), anyInt(), anyInt(), anyLong() ); }
verify(endpointMetricsHandlerMock).handleRequest( eq(requestInfoMock), eq(responseInfoMock), eq(state), eq(responseStatusCode), eq(responseHttpStatusCodeXXValue), elapsedTimeMillisArgCaptor.capture()
verify(endpointMetricsHandlerMock).handleRequest( eq(requestInfoMock), eq(responseInfoMock), eq(state), eq(responseStatusCode), eq(responseHttpStatusCodeXXValue), elapsedTimeMillisArgCaptor.capture()