From e1e5777d7371b264020ddf4ae930270c3567b142 Mon Sep 17 00:00:00 2001 From: 1289220708 <1289220708@qq.com> Date: Tue, 17 Oct 2023 02:29:34 +0800 Subject: [PATCH] feat(api): support recording slow query log --- .../org/apache/hugegraph/api/filter/AccessLogFilter.java | 2 +- .../java/org/apache/hugegraph/metrics/SlowQueryLog.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java b/hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java index c4ef047146..b1a4d08d10 100644 --- a/hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java +++ b/hugegraph-api/src/main/java/org/apache/hugegraph/api/filter/AccessLogFilter.java @@ -94,7 +94,7 @@ public void filter(ContainerRequestContext requestContext, ContainerResponseCont // record slow query log if (enableSlowQueryLog && isSlowQueryLogWhiteAPI(requestContext) && timeThreshold < responseTime) { - SlowQueryLog log = new SlowQueryLog(responseTime, + SlowQueryLog log = new SlowQueryLog(responseTime, (Long) requestTime, (String) requestContext.getProperty(REQUEST_PARAMS_JSON), method, timeThreshold, path); LOG.info("slow query log: {}", JsonUtil.toJson(log)); } diff --git a/hugegraph-api/src/main/java/org/apache/hugegraph/metrics/SlowQueryLog.java b/hugegraph-api/src/main/java/org/apache/hugegraph/metrics/SlowQueryLog.java index 70d708864b..947b5ecc8e 100644 --- a/hugegraph-api/src/main/java/org/apache/hugegraph/metrics/SlowQueryLog.java +++ b/hugegraph-api/src/main/java/org/apache/hugegraph/metrics/SlowQueryLog.java @@ -21,6 +21,8 @@ public class SlowQueryLog { public Long executeTime; + public Long startTime; + public String rawQuery; public String method; @@ -29,7 +31,9 @@ public class SlowQueryLog { public String path; - public SlowQueryLog(Long executeTime, String rawQuery, String method, Long threshold, + + + public SlowQueryLog(Long executeTime, Long startTime, String rawQuery, String method, Long threshold, String path) { this.executeTime = executeTime; this.rawQuery = rawQuery;