From 4b880a6dbdad57a0911b536b2bced68a82c450d3 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Fri, 15 Jul 2022 11:15:41 +0800 Subject: [PATCH] add limit rate filter debug log. (#436) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 许路路 <499319126@qq.com> --- CHANGELOG.md | 3 ++- .../polaris/ratelimit/filter/QuotaCheckReactiveFilter.java | 1 + .../polaris/ratelimit/filter/QuotaCheckServletFilter.java | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5055cb3c3..032b0ac10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Change Log --- -- [Bugfix: optimize ratelimit actuator](https://github.com/Tencent/spring-cloud-tencent/pull/419) \ No newline at end of file +- [Bugfix: optimize ratelimit actuator](https://github.com/Tencent/spring-cloud-tencent/pull/419) +- [Feature: add rate limit filter debug log](https://github.com/Tencent/spring-cloud-tencent/pull/436) diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java index fb547bb55..cdca48224 100644 --- a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java +++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java @@ -114,6 +114,7 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered { } // Unirate if (quotaResponse.getCode() == QuotaResultCode.QuotaResultOk && quotaResponse.getWaitMs() > 0) { + LOG.debug("The request of [{}] will waiting for {}ms.", path, quotaResponse.getWaitMs()); return Mono.delay(Duration.ofMillis(quotaResponse.getWaitMs())).flatMap(e -> chain.filter(exchange)); } } diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java index efe9e1c67..8497bdf4e 100644 --- a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java +++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java @@ -110,7 +110,7 @@ public class QuotaCheckServletFilter extends OncePerRequestFilter { } // Unirate if (quotaResponse.getCode() == QuotaResultCode.QuotaResultOk && quotaResponse.getWaitMs() > 0) { - LOG.debug("Unirate sleep for {}ms.", quotaResponse.getWaitMs()); + LOG.debug("The request of [{}] will waiting for {}ms.", request.getRequestURI(), quotaResponse.getWaitMs()); Thread.sleep(quotaResponse.getWaitMs()); } @@ -150,8 +150,7 @@ public class QuotaCheckServletFilter extends OncePerRequestFilter { return labelResolver.resolve(request); } catch (Throwable e) { - LOG.error("resolve custom label failed. resolver = {}", - labelResolver.getClass().getName(), e); + LOG.error("resolve custom label failed. resolver = {}", labelResolver.getClass().getName(), e); } } return Collections.emptyMap();