in apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/main/java/org/apache/skywalking/apm/plugin/dubbo/AbstractServerConstructorInterceptor.java [37:83]
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Throwable {
Field executorField = AbstractServer.class.getDeclaredField("executor");
executorField.setAccessible(true);
ExecutorService executor = (ExecutorService) executorField.get(objInst);
URL url = (URL) allArguments[0];
int port = url.getPort();
if (!(executor instanceof ThreadPoolExecutor)) {
return;
}
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executor;
String threadPoolName = String.format("DubboServerHandler-%s", port);
MeterFactory.gauge(METER_NAME, () -> (double) (threadPoolExecutor.getCorePoolSize()))
.tag(METRIC_POOL_NAME_TAG_NAME, threadPoolName)
.tag(METRIC_TYPE_TAG_NAME, "core_pool_size")
.build();
MeterFactory.gauge(METER_NAME, () -> (double) (threadPoolExecutor.getMaximumPoolSize()))
.tag(METRIC_POOL_NAME_TAG_NAME, threadPoolName)
.tag(METRIC_TYPE_TAG_NAME, "max_pool_size")
.build();
MeterFactory.gauge(METER_NAME, () -> (double) (threadPoolExecutor.getLargestPoolSize()))
.tag(METRIC_POOL_NAME_TAG_NAME, threadPoolName)
.tag(METRIC_TYPE_TAG_NAME, "largest_pool_size")
.build();
MeterFactory.gauge(METER_NAME, () -> (double) (threadPoolExecutor.getPoolSize()))
.tag(METRIC_POOL_NAME_TAG_NAME, threadPoolName)
.tag(METRIC_TYPE_TAG_NAME, "pool_size")
.build();
MeterFactory.gauge(METER_NAME, () -> (double) (threadPoolExecutor.getQueue().size()))
.tag(METRIC_POOL_NAME_TAG_NAME, threadPoolName)
.tag(METRIC_TYPE_TAG_NAME, "queue_size")
.build();
MeterFactory.gauge(METER_NAME, () -> (double) (threadPoolExecutor.getActiveCount()))
.tag(METRIC_POOL_NAME_TAG_NAME, threadPoolName)
.tag(METRIC_TYPE_TAG_NAME, "active_size")
.build();
MeterFactory.gauge(METER_NAME, () -> (double) (threadPoolExecutor.getTaskCount()))
.tag(METRIC_POOL_NAME_TAG_NAME, threadPoolName)
.tag(METRIC_TYPE_TAG_NAME, "task_count")
.build();
MeterFactory.gauge(METER_NAME, () -> (double) (threadPoolExecutor.getCompletedTaskCount()))
.tag(METRIC_POOL_NAME_TAG_NAME, threadPoolName)
.tag(METRIC_TYPE_TAG_NAME, "completed_task_count")
.build();
}