diff --git a/core/src/main/java/io/confluent/rest/metrics/MetricsResourceMethodApplicationListener.java b/core/src/main/java/io/confluent/rest/metrics/MetricsResourceMethodApplicationListener.java index 8dc6b1987a..5c997423fe 100644 --- a/core/src/main/java/io/confluent/rest/metrics/MetricsResourceMethodApplicationListener.java +++ b/core/src/main/java/io/confluent/rest/metrics/MetricsResourceMethodApplicationListener.java @@ -325,12 +325,13 @@ public MetricsRequestEventListener(final Map metri @Override public void onEvent(RequestEvent event) { - if (event.getType() == RequestEvent.Type.MATCHING_START) { + if (started == 0L) { started = time.milliseconds(); final ContainerRequest request = event.getContainerRequest(); wrappedRequestStream = new CountingInputStream(request.getEntityStream()); request.setEntityStream(wrappedRequestStream); - } else if (event.getType() == RequestEvent.Type.RESP_FILTERS_START) { + } + if (event.getType() == RequestEvent.Type.RESP_FILTERS_START) { final ContainerResponse response = event.getContainerResponse(); wrappedResponseStream = new CountingOutputStream(response.getEntityStream()); response.setEntityStream(wrappedResponseStream);