This is an automated email from the ASF dual-hosted git repository. wujimin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git
commit b8cb6f8dac9ffe5f2b50e31763e9878384ab86ca Author: wujimin <wuji...@huawei.com> AuthorDate: Mon Apr 2 11:37:47 2018 +0800 SCB-422 log publisher output threadPool informations --- .../metrics/core/publish/DefaultLogPublisher.java | 25 ++++++++++++++++++++++ .../core/publish/TestDefaultLogPublisher.java | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java index 26a3815..a4efedd 100644 --- a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java +++ b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/publish/DefaultLogPublisher.java @@ -26,6 +26,7 @@ import org.apache.servicecomb.foundation.metrics.PolledEvent; import org.apache.servicecomb.foundation.vertx.VertxUtils; import org.apache.servicecomb.metrics.core.meter.invocation.MeterInvocationConst; import org.apache.servicecomb.metrics.core.publish.model.DefaultPublishModel; +import org.apache.servicecomb.metrics.core.publish.model.ThreadPoolPublishModel; import org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerf; import org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup; import org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups; @@ -75,12 +76,36 @@ public class DefaultLogPublisher implements MetricsInitializer { PublishModelFactory factory = new PublishModelFactory(meters); DefaultPublishModel model = factory.createDefaultPublishModel(); + + printThreadPoolMetrics(model, sb); + printConsumerLog(model, sb); printProducerLog(model, sb); LOGGER.info(sb.toString()); } + protected void printThreadPoolMetrics(DefaultPublishModel model, StringBuilder sb) { + if (model.getThreadPools().isEmpty()) { + return; + } + + sb.append("threadPool:\n"); + sb.append(" corePoolSize maxThreads poolSize currentThreadsBusy queueSize taskCount completedTaskCount name\n"); + for (Entry<String, ThreadPoolPublishModel> entry : model.getThreadPools().entrySet()) { + ThreadPoolPublishModel threadPoolPublishModel = entry.getValue(); + sb.append(String.format(" %-12d %-10d %-8d %-18d %-9d %-9.1f %-18.1f %s\n", + threadPoolPublishModel.getCorePoolSize(), + threadPoolPublishModel.getMaxThreads(), + threadPoolPublishModel.getPoolSize(), + threadPoolPublishModel.getCurrentThreadsBusy(), + threadPoolPublishModel.getQueueSize(), + threadPoolPublishModel.getAvgTaskCount(), + threadPoolPublishModel.getAvgCompletedTaskCount(), + entry.getKey())); + } + } + protected void printConsumerLog(DefaultPublishModel model, StringBuilder sb) { OperationPerfGroups consumerPerf = model.getConsumer().getOperationPerfGroups(); if (consumerPerf == null) { diff --git a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestDefaultLogPublisher.java b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestDefaultLogPublisher.java index 056dd25..c8ffc55 100644 --- a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestDefaultLogPublisher.java +++ b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/publish/TestDefaultLogPublisher.java @@ -32,6 +32,7 @@ import org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector; import org.apache.servicecomb.foundation.vertx.VertxUtils; import org.apache.servicecomb.metrics.core.meter.invocation.MeterInvocationConst; import org.apache.servicecomb.metrics.core.publish.model.DefaultPublishModel; +import org.apache.servicecomb.metrics.core.publish.model.ThreadPoolPublishModel; import org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerf; import org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroup; import org.apache.servicecomb.metrics.core.publish.model.invocation.OperationPerfGroups; @@ -157,6 +158,8 @@ public class TestDefaultLogPublisher { model.getConsumer().setOperationPerfGroups(operationPerfGroups); model.getProducer().setOperationPerfGroups(operationPerfGroups); + model.getThreadPools().put("test", new ThreadPoolPublishModel()); + new MockUp<PublishModelFactory>() { @Mock DefaultPublishModel createDefaultPublishModel() { @@ -175,6 +178,9 @@ public class TestDefaultLogPublisher { "vertx:\n" + " name eventLoopContext-created\n" + " v 1\n" + + "threadPool:\n" + + " corePoolSize maxThreads poolSize currentThreadsBusy queueSize taskCount completedTaskCount name\n" + + " 0 0 0 0 0 0.0 0.0 test\n" + "consumer:\n" + " tps latency(ms) max-latency(ms) operation\n" + " rest.OK:\n" + -- To stop receiving notification emails like this one, please contact wuji...@apache.org.