diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HandlerService.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HandlerService.java index 0c6437f8b7..b68ea2f648 100644 --- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HandlerService.java +++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/processor/HandlerService.java @@ -278,7 +278,6 @@ public void run() { } ProcessorWrapper processorWrapper = HandlerService.this.httpProcessorMap.get(processorKey); try { - this.preHandler(); if (processorWrapper.httpProcessor instanceof AsyncHttpProcessor) { // set actual async request HttpEventWrapper httpEventWrapper = parseHttpRequest(request); @@ -289,10 +288,10 @@ public void run() { response = processorWrapper.httpProcessor.handler(request); if (processorWrapper.httpProcessor instanceof ShortHttpProcessor) { - this.postHandler(ConnectionType.SHORT_LIVED); + this.postHandlerWithTimeCostRecord(ConnectionType.SHORT_LIVED); return; } - this.postHandler(ConnectionType.PERSISTENT); + this.postHandlerWithTimeCostRecord(ConnectionType.PERSISTENT); } catch (Throwable e) { exception = e; // todo: according exception to generate response @@ -301,6 +300,12 @@ public void run() { } } + private void postHandlerWithTimeCostRecord(ConnectionType type) { + metrics.getSummaryMetrics().recordHTTPReqResTimeCost(System.currentTimeMillis() - requestTime); + HTTP_LOGGER.debug("{}", response); + postHandler(type); + } + private void postHandler(ConnectionType type) { metrics.getSummaryMetrics().recordHTTPRequest(); HTTP_LOGGER.debug("{}", request); @@ -315,10 +320,6 @@ private void postHandler(ConnectionType type) { } } - private void preHandler() { - metrics.getSummaryMetrics().recordHTTPReqResTimeCost(System.currentTimeMillis() - requestTime); - HTTP_LOGGER.debug("{}", response); - } private void error() { log.error(this.exception.getMessage(), this.exception);