From 47d913de0533ca666ab65fc8fb02c6b2c411bc0a Mon Sep 17 00:00:00 2001 From: "blake.qiu" <46370663+Bo-Qiu@users.noreply.github.com> Date: Thu, 18 Jul 2024 09:40:12 +0800 Subject: [PATCH] feat(#12355): Record the cost of ConfigDump in Prometheus. (#12356) --- .../nacos/config/server/monitor/MetricsMonitor.java | 4 ++++ .../config/server/service/trace/ConfigTraceService.java | 7 +------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/config/src/main/java/com/alibaba/nacos/config/server/monitor/MetricsMonitor.java b/config/src/main/java/com/alibaba/nacos/config/server/monitor/MetricsMonitor.java index aca6c68e9..33842db26 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/monitor/MetricsMonitor.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/monitor/MetricsMonitor.java @@ -194,6 +194,10 @@ public class MetricsMonitor { return NacosMeterRegistryCenter.timer(METER_REGISTRY, "nacos_timer", "module", "config", "name", "notifyRt"); } + public static Timer getDumpRtTimer() { + return NacosMeterRegistryCenter.timer(METER_REGISTRY, "nacos_timer", "module", "config", "name", "dumpRt"); + } + public static Counter getIllegalArgumentException() { return NacosMeterRegistryCenter .counter(METER_REGISTRY, "nacos_exception", "module", "config", "name", "illegalArgument"); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/trace/ConfigTraceService.java b/config/src/main/java/com/alibaba/nacos/config/server/service/trace/ConfigTraceService.java index 8b720c2b4..ec9b4a58f 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/trace/ConfigTraceService.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/trace/ConfigTraceService.java @@ -142,7 +142,6 @@ public class ConfigTraceService { //localIp | dataid | group | tenant | requestIpAppName | ts | client ip | event | type | [delayed = -1] | ext // (md5) String md5 = content == null ? null : MD5Utils.md5Hex(content, Constants.PERSIST_ENCODE); - LogUtil.TRACE_LOG.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", InetUtils.getSelfIP(), dataId, group, tenant, requestIpAppName, ts, handleIp, event, type, -1, md5); } @@ -165,17 +164,14 @@ public class ConfigTraceService { if (!LogUtil.TRACE_LOG.isInfoEnabled()) { return; } - if (delayed < 0) { delayed = 0; } - MetricsMonitor.getNotifyRtTimer().record(delayed, TimeUnit.MILLISECONDS); // Convenient tlog segmentation if (StringUtils.isBlank(tenant)) { tenant = null; } - //localIp | dataid | group | tenant | requestIpAppName | ts | handleIp | event | type | [delayed] | ext // (targetIp) LogUtil.TRACE_LOG.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", InetUtils.getSelfIP(), dataId, group, tenant, @@ -227,6 +223,7 @@ public class ConfigTraceService { if (delayed < 0) { delayed = 0; } + MetricsMonitor.getDumpRtTimer().record(delayed, TimeUnit.MILLISECONDS); // Convenient tlog segmentation if (StringUtils.isBlank(tenant)) { tenant = null; @@ -284,11 +281,9 @@ public class ConfigTraceService { if (StringUtils.isBlank(tenant)) { tenant = null; } - if (isNotify && delayed < 0) { delayed = 0; } - // localIp | dataid | group | tenant| requestIpAppName| ts | event | type | [delayed] |clientIp| isNotify | mode(http/grpc) LogUtil.TRACE_LOG.info("{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}|{}", InetUtils.getSelfIP(), dataId, group, tenant, requestIpAppName, ts, event, type, delayed, clientIp, isNotify, model);