Skip to content

Commit

Permalink
[ISSUE #4551] modify the logic of time-consumption statistics (#4822)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnzakii authored Apr 11, 2024
1 parent a930f6d commit a003c03
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit a003c03

Please sign in to comment.