Skip to content

Commit

Permalink
[ISSUE#5697]Add new indicator for core module, especially Jraft and D…
Browse files Browse the repository at this point in the history
…istro protocal. (#7003)

* clean git log. (#5)

* delete MetricsMonitor.java in core module.

* delete MetricsMonitor.java in config module.

* remove some unnecessary code in MetricsMonitor.java from naming module.

* add a NacosMetersReporter which is aimed to transfer JRaft metrics into micrometer metrics.

* fix code style.

* delete unnecessary code and add a groupName String for NacosMetersReporter.java.

* delete unnecessary notes.

* add some JRaft metrics into MetricsManger.

* fix code style error.

* delete append-logs and replicate-entries timer, nacos only collect theirs times.

* add prefix for JRaft metrics.

* add distro metrics in core module.

* fix code style.

* rename gaugesMap into gauges, countersMap into counters and timersMap into timers.

* delete exporter in MetricsManager.
  • Loading branch information
Holdonbei authored Sep 30, 2021
1 parent ce8bcd3 commit 919cfd2
Show file tree
Hide file tree
Showing 44 changed files with 725 additions and 692 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public Object interfacePublishSingleRpc(ProceedingJoinPoint pjp, ConfigPublishRe
throws Throwable {
final String md5 =
request.getContent() == null ? null : MD5Utils.md5Hex(request.getContent(), Constants.ENCODE);
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_PUBLISH)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.PUBLISH)
.incrementAndGet();
return logClientRequestRpc("publish", pjp, request, meta, request.getDataId(), request.getGroup(),
request.getTenant(), md5);
Expand All @@ -125,9 +125,9 @@ public Object interfacePublishSingleRpc(ProceedingJoinPoint pjp, ConfigPublishRe
public Object interfacePublishSingle(ProceedingJoinPoint pjp, HttpServletRequest request,
HttpServletResponse response, String dataId, String group, String tenant, String content) throws Throwable {
final String md5 = content == null ? null : MD5Utils.md5Hex(content, Constants.ENCODE);
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_PUBLISH)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.PUBLISH)
.incrementAndGet();
return logClientRequest("publish", pjp, request, response, dataId, group, tenant, md5);
}
Expand Down Expand Up @@ -159,9 +159,9 @@ public Object interfaceGetConfig(ProceedingJoinPoint pjp, HttpServletRequest req
String dataId, String group, String tenant) throws Throwable {
final String groupKey = GroupKey2.getKey(dataId, group, tenant);
final String md5 = ConfigCacheService.getContentMd5(groupKey);
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_GET_CONFIG)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.GET_CONFIG)
.incrementAndGet();
return logClientRequest("get", pjp, request, response, dataId, group, tenant, md5);
}
Expand All @@ -174,9 +174,9 @@ public Object interfaceGetConfigRpc(ProceedingJoinPoint pjp, ConfigQueryRequest
throws Throwable {
final String groupKey = GroupKey2.getKey(request.getDataId(), request.getGroup(), request.getTenant());
final String md5 = ConfigCacheService.getContentMd5(groupKey);
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_GET_CONFIG)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.GET_CONFIG)
.incrementAndGet();
return logClientRequestRpc("get", pjp, request, meta, request.getDataId(), request.getGroup(),
request.getTenant(), md5);
Expand Down Expand Up @@ -224,9 +224,9 @@ private Object logClientRequestRpc(String requestType, ProceedingJoinPoint pjp,
@Around(CLIENT_INTERFACE_LISTEN_CONFIG_RPC)
public Object interfaceListenConfigRpc(ProceedingJoinPoint pjp, ConfigBatchListenRequest request,
RequestMeta meta) throws Throwable {
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_GET_CONFIG)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.GET_CONFIG)
.incrementAndGet();
final String requestIp = meta.getClientIp();
String appName = request.getHeader(RequestUtil.CLIENT_APPNAME_HEADER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public class GlobalExceptionHandler {
*/
@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<String> handleIllegalArgumentException(Exception ex) throws IOException {
MetricsManager.counter(ConfigMetricsConstant.N_NACOS_EXCEPTION,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_ILLEGAL_ARGUMENT)
MetricsManager.counter(ConfigMetricsConstant.NACOS_EXCEPTION,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.ILLEGAL_ARGUMENT)
.increment();
return ResponseEntity.status(400).body(ExceptionUtil.getAllExceptionMsg(ex));
}
Expand All @@ -57,9 +57,9 @@ public ResponseEntity<String> handleIllegalArgumentException(Exception ex) throw
*/
@ExceptionHandler(NacosException.class)
public ResponseEntity<String> handleNacosException(NacosException ex) throws IOException {
MetricsManager.counter(ConfigMetricsConstant.N_NACOS_EXCEPTION,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_NACOS)
MetricsManager.counter(ConfigMetricsConstant.NACOS_EXCEPTION,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.NACOS)
.increment();
return ResponseEntity.status(ex.getErrCode()).body(ExceptionUtil.getAllExceptionMsg(ex));
}
Expand All @@ -71,9 +71,9 @@ public ResponseEntity<String> handleNacosException(NacosException ex) throws IOE
*/
@ExceptionHandler(DataAccessException.class)
public ResponseEntity<String> handleDataAccessException(DataAccessException ex) throws DataAccessException {
MetricsManager.counter(ConfigMetricsConstant.N_NACOS_EXCEPTION,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_DB)
MetricsManager.counter(ConfigMetricsConstant.NACOS_EXCEPTION,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.DB)
.increment();
return ResponseEntity.status(500).body(ExceptionUtil.getAllExceptionMsg(ex));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,28 @@ public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
@Override
public void addTask(Object key, AbstractDelayTask newTask) {
super.addTask(key, newTask);
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_DUMP_TASK)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.DUMP_TASK)
.set(tasks.size());
}

@Override
public AbstractDelayTask removeTask(Object key) {
AbstractDelayTask result = super.removeTask(key);
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_DUMP_TASK)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.DUMP_TASK)
.set(tasks.size());
return result;
}

@Override
protected void processTasks() {
super.processTasks();
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_DUMP_TASK)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.DUMP_TASK)
.set(tasks.size());
if (tasks.isEmpty()) {
this.lock.lock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public MemoryMonitor(AsyncNotifyService notifySingleService) {
*/
@Scheduled(cron = "0 0 0 * * ?")
public void clear() {
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_GET_CONFIG)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.GET_CONFIG)
.set(0);

MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_PUBLISH)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.PUBLISH)
.set(0);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public void run() {
long subCount = ClientTrackService.subscriberCount();
MEMORY_LOG.info("groupCount = {}, subscriberClientCount = {}, subscriberCount = {}", groupCount, subClientCount,
subCount);
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_CONFIG_COUNT).set(groupCount);
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.CONFIG_COUNT).set(groupCount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public void run() {
int notifierClientSize = ConfigExecutor.asyncCofigChangeClientNotifyQueueSize();
MEMORY_LOG.info("toNotifyTaskSize = {}", size);
MEMORY_LOG.info("toClientNotifyTaskSize = {}", notifierClientSize);
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_NOTIFY_TASK)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.NOTIFY_TASK)
.set(size);
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_NOTIFY_CLIENT_TASK)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.NOTIFY_CLIENT_TASK)
.set(notifierClientSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ class StatTask implements Runnable {
@Override
public void run() {
MEMORY_LOG.info("[long-pulling] client count " + allSubs.size());
MetricsManager.gauge(ConfigMetricsConstant.N_NACOS_MONITOR,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_LONG_POLLING)
MetricsManager.gauge(ConfigMetricsConstant.NACOS_MONITOR,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.LONG_POLLING)
.set(allSubs.size());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ public void run() {

if (!isFound) {
FATAL_LOG.error("[master-db] master db not found.");
MetricsManager.counter(ConfigMetricsConstant.N_NACOS_EXCEPTION,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_DB)
MetricsManager.counter(ConfigMetricsConstant.NACOS_EXCEPTION,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.DB)
.increment();
}
}
Expand Down Expand Up @@ -259,9 +259,9 @@ public void run() {
}
isHealthList.set(i, Boolean.FALSE);

MetricsManager.counter(ConfigMetricsConstant.N_NACOS_EXCEPTION,
ConfigMetricsConstant.TK_MODULE, ConfigMetricsConstant.TV_CONFIG,
ConfigMetricsConstant.TK_NAME, ConfigMetricsConstant.TV_DB)
MetricsManager.counter(ConfigMetricsConstant.NACOS_EXCEPTION,
ConfigMetricsConstant.MODULE, ConfigMetricsConstant.CONFIG,
ConfigMetricsConstant.NAME, ConfigMetricsConstant.DB)
.increment();
}
}
Expand Down
Loading

0 comments on commit 919cfd2

Please sign in to comment.