Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
EachannChan committed Nov 20, 2024
1 parent 15929e1 commit 8457c52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public static ExecutorStats toMetrics(ExecutorWrapper wrapper) {
ExecutorStats executorStats = convertCommon(executor);
executorStats.setExecutorName(wrapper.getThreadPoolName());
executorStats.setExecutorAliasName(wrapper.getThreadPoolAliasName());
executorStats.setPoolName(wrapper.getThreadPoolName());
executorStats.setPoolAliasName(wrapper.getThreadPoolAliasName());
executorStats.setRunTimeoutCount(provider.getRunTimeoutCount());
executorStats.setQueueTimeoutCount(provider.getQueueTimeoutCount());
executorStats.setRejectCount(provider.getRejectedTaskCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ public class MicroMeterCollector extends AbstractCollector {

public static final String APP_NAME_TAG = "app.name";

private static final Map<String, org.dromara.dynamictp.common.entity.Metrics> GAUGE_CACHE = new ConcurrentHashMap<>();
private static final Map<String, ExecutorStats> GAUGE_CACHE = new ConcurrentHashMap<>();

@Override
public void collect(ExecutorStats executorStats) {
// metrics must be held with a strong reference, even though it is never referenced within this class
ExecutorStats oldStats = (ExecutorStats) GAUGE_CACHE.get(executorStats.getPoolName());
ExecutorStats oldStats = (ExecutorStats) GAUGE_CACHE.get(executorStats.getExecutorName());
if (Objects.isNull(oldStats)) {
GAUGE_CACHE.put(executorStats.getPoolName(), executorStats);
GAUGE_CACHE.put(executorStats.getExecutorName(), executorStats);
} else {
BeanCopierUtil.copyProperties(executorStats, oldStats);
}
gauge((ExecutorStats) GAUGE_CACHE.get(executorStats.getPoolName()));
gauge((ExecutorStats) GAUGE_CACHE.get(executorStats.getExecutorName()));
}

@Override
Expand Down Expand Up @@ -120,9 +120,9 @@ private static String metricName(String name) {

private Iterable<Tag> getTags(ExecutorStats executorStats) {
List<Tag> tags = new ArrayList<>(3);
tags.add(Tag.of(executorStats.isVirtualExecutor() ? VTE_NAME_TAG : POOL_NAME_TAG, executorStats.getPoolName()));
tags.add(Tag.of(executorStats.isVirtualExecutor() ? VTE_NAME_TAG : POOL_NAME_TAG, executorStats.getExecutorName()));
tags.add(Tag.of(APP_NAME_TAG, CommonUtil.getInstance().getServiceName()));
tags.add(Tag.of(executorStats.isVirtualExecutor() ? VTE_ALIAS_TAG : POOL_ALIAS_TAG, Optional.ofNullable(executorStats.getExecutorAliasName()).orElse(executorStats.getPoolName())));
tags.add(Tag.of(executorStats.isVirtualExecutor() ? VTE_ALIAS_TAG : POOL_ALIAS_TAG, Optional.ofNullable(executorStats.getExecutorAliasName()).orElse(executorStats.getExecutorName())));
return tags;
}
}
Expand Down

0 comments on commit 8457c52

Please sign in to comment.