You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2017/12/23 08:17:06 UTC
[GitHub] seanyinx commented on a change in pull request #451: [JAV-539] & [SCB-9] Implement CallCount and TPS Metrics
seanyinx commented on a change in pull request #451: [JAV-539] & [SCB-9] Implement CallCount and TPS Metrics
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/451#discussion_r158578810
##########
File path: metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/metric/RegistryMetric.java
##########
@@ -17,40 +17,93 @@
package io.servicecomb.metrics.core.metric;
+import java.util.HashMap;
import java.util.Map;
-import io.servicecomb.metrics.core.monitor.RegistryMonitor;
+import io.servicecomb.metrics.core.MetricsConst;
public class RegistryMetric {
private final InstanceMetric instanceMetric;
- private final Map<String, InvocationMetric> invocationMetrics;
+ private final Map<String, ConsumerInvocationMetric> consumerMetrics;
+
+ private final Map<String, ProducerInvocationMetric> producerMetrics;
public InstanceMetric getInstanceMetric() {
return instanceMetric;
}
- public Map<String, InvocationMetric> getInvocationMetrics() {
- return invocationMetrics;
+ public Map<String, ConsumerInvocationMetric> getConsumerMetrics() {
+ return consumerMetrics;
+ }
+
+ public Map<String, ProducerInvocationMetric> getProducerMetrics() {
+ return producerMetrics;
}
- public RegistryMetric(RegistryMonitor registryMonitor, int pollerIndex) {
- invocationMetrics = registryMonitor.toInvocationMetrics(pollerIndex);
+ public RegistryMetric() {
+ consumerMetrics = new HashMap<>();
+ producerMetrics = new HashMap<>();
+ instanceMetric = new InstanceMetric();
+ }
+ public RegistryMetric(Map<String, InvocationMetric> invocationMetrics) {
//sum instance level metric
- long waitInQueue = 0;
- TimerMetric lifeTimeInQueue = new TimerMetric();
- TimerMetric executionTime = new TimerMetric();
- TimerMetric consumerLatency = new TimerMetric();
- TimerMetric producerLatency = new TimerMetric();
+ consumerMetrics = new HashMap<>();
+ producerMetrics = new HashMap<>();
+
+ //TODO:current java chassis unable know invocation type before starting process,totalWaitInQueue = ProducerInvocation + UnknownTypeInvocation
+ long totalWaitInQueue = 0;
+ long producerWaitInQueue = 0;
+ TimerMetric lifeTimeInQueue = new TimerMetric(MetricsConst.INSTANCE_PRODUCER_PREFIX + ".lifeTimeInQueue");
+ TimerMetric executionTime = new TimerMetric(MetricsConst.INSTANCE_PRODUCER_PREFIX + ".executionTime");
+ TimerMetric consumerLatency = new TimerMetric(MetricsConst.INSTANCE_CONSUMER_PREFIX + ".consumerLatency");
+ TimerMetric producerLatency = new TimerMetric(MetricsConst.INSTANCE_PRODUCER_PREFIX + ".producerLatency");
+ CallMetric consumerCall = new CallMetric(MetricsConst.INSTANCE_CONSUMER_PREFIX + ".consumerCall");
+ CallMetric producerCall = new CallMetric(MetricsConst.INSTANCE_PRODUCER_PREFIX + ".producerCall");
+
for (InvocationMetric metric : invocationMetrics.values()) {
- waitInQueue += metric.getWaitInQueue();
- lifeTimeInQueue = lifeTimeInQueue.merge(metric.getLifeTimeInQueue());
- executionTime = executionTime.merge(metric.getExecutionTime());
- consumerLatency = consumerLatency.merge(metric.getConsumerLatency());
- producerLatency = producerLatency.merge(metric.getProducerLatency());
+ if (metric != null) {
+ if (metric instanceof ConsumerInvocationMetric) {
Review comment:
think of open closed principle
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services