[ 
https://issues.apache.org/jira/browse/SCB-311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16343064#comment-16343064
 ] 

ASF GitHub Bot commented on SCB-311:
------------------------------------

zhengyangyong closed pull request #535: [SCB-311] Support Record Custom Metrics 
in Java Chassis Itself
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/535
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/CustomMetricsUtils.java
 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/CustomMetricsUtils.java
new file mode 100644
index 000000000..1ae700f78
--- /dev/null
+++ 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/CustomMetricsUtils.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.foundation.common.utils;
+
+import org.apache.servicecomb.foundation.metrics.CounterEvent;
+import org.apache.servicecomb.foundation.metrics.GaugeEvent;
+import org.apache.servicecomb.foundation.metrics.WindowCounterEvent;
+
+public final class CustomMetricsUtils {
+  public static void incrementCounter(String name) {
+    EventUtils.triggerEvent(new CounterEvent(name));
+  }
+
+  public static void incrementCounter(String name, long value) {
+    EventUtils.triggerEvent(new CounterEvent(name, value));
+  }
+
+  public static void decrementCounter(String name) {
+    EventUtils.triggerEvent(new CounterEvent(name, -1));
+  }
+
+  public static void updateGauge(String name, double value) {
+    EventUtils.triggerEvent(new GaugeEvent(name, value));
+  }
+
+  /**
+   WindowCounter is complex Window Time-related Step Counter,
+   It will output total,count,tps,rate,average,max and min
+   examples:
+   if record four time in one window,and window time = 2000 (2 seconds), like :
+   recordWindowCounter("Order Amount",100)
+   recordWindowCounter("Order Amount",200)
+   recordWindowCounter("Order Amount",300)
+   recordWindowCounter("Order Amount",400)
+
+   Output metrics include:
+   Order Amount.total = 1000
+   Order Amount.count = 4
+   Order Amount.tps = 2           count / time(second)
+   Order Amount.rate = 500        total / time(second
+   Order Amount.average = 250     total / count
+   Order Amount.max = 400
+   Order Amount.min = 100
+   */
+  public static void recordWindowCounter(String name, long value) {
+    EventUtils.triggerEvent(new WindowCounterEvent(name, value));
+  }
+}
diff --git 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/metrics/CounterEvent.java
 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/metrics/CounterEvent.java
new file mode 100644
index 000000000..3691f8d97
--- /dev/null
+++ 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/metrics/CounterEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.foundation.metrics;
+
+import org.apache.servicecomb.foundation.common.event.Event;
+
+public class CounterEvent implements Event {
+  private final String name;
+
+  private final long value;
+
+  public String getName() {
+    return name;
+  }
+
+  public long getValue() {
+    return value;
+  }
+
+  public CounterEvent(String name) {
+    this(name, 1);
+  }
+
+  public CounterEvent(String name, long value) {
+    this.name = name;
+    this.value = value;
+  }
+}
diff --git 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/metrics/GaugeEvent.java
 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/metrics/GaugeEvent.java
new file mode 100644
index 000000000..bed66d173
--- /dev/null
+++ 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/metrics/GaugeEvent.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.foundation.metrics;
+
+import org.apache.servicecomb.foundation.common.event.Event;
+
+public class GaugeEvent implements Event {
+  private final String name;
+
+  private final double value;
+
+  public String getName() {
+    return name;
+  }
+
+  public double getValue() {
+    return value;
+  }
+
+  public GaugeEvent(String name, double value) {
+    this.name = name;
+    this.value = value;
+  }
+}
diff --git 
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/metrics/WindowCounterEvent.java
 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/metrics/WindowCounterEvent.java
new file mode 100644
index 000000000..f00451341
--- /dev/null
+++ 
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/metrics/WindowCounterEvent.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.foundation.metrics;
+
+import org.apache.servicecomb.foundation.common.event.Event;
+
+public class WindowCounterEvent implements Event {
+  private final String name;
+
+  private final long value;
+
+  public String getName() {
+    return name;
+  }
+
+  public long getValue() {
+    return value;
+  }
+
+  public WindowCounterEvent(String name, long value) {
+    this.name = name;
+    this.value = value;
+  }
+}
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/CounterEventListener.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/CounterEventListener.java
new file mode 100644
index 000000000..f8308fead
--- /dev/null
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/CounterEventListener.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.metrics.core.event;
+
+import org.apache.servicecomb.foundation.common.event.Event;
+import org.apache.servicecomb.foundation.common.event.EventListener;
+import org.apache.servicecomb.foundation.metrics.CounterEvent;
+import org.apache.servicecomb.metrics.core.custom.CounterService;
+
+public class CounterEventListener implements EventListener {
+
+  private final CounterService counterService;
+
+  public CounterEventListener(CounterService counterService) {
+    this.counterService = counterService;
+  }
+
+  @Override
+  public Class<? extends Event> getConcernedEvent() {
+    return CounterEvent.class;
+  }
+
+  @Override
+  public void process(Event data) {
+    CounterEvent event = (CounterEvent) data;
+    counterService.increment(event.getName(), event.getValue());
+  }
+}
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/DefaultEventListenerManager.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/DefaultEventListenerManager.java
index 6dc6df4f4..43c088b20 100644
--- 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/DefaultEventListenerManager.java
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/DefaultEventListenerManager.java
@@ -21,6 +21,9 @@
 import org.apache.servicecomb.foundation.common.utils.EventUtils;
 import org.apache.servicecomb.metrics.common.MetricsDimension;
 import org.apache.servicecomb.metrics.core.MetricsConfig;
+import org.apache.servicecomb.metrics.core.custom.CounterService;
+import org.apache.servicecomb.metrics.core.custom.GaugeService;
+import org.apache.servicecomb.metrics.core.custom.WindowCounterService;
 import 
org.apache.servicecomb.metrics.core.event.dimension.StatusConvertorFactory;
 import org.apache.servicecomb.metrics.core.monitor.RegistryMonitor;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,18 +35,24 @@
 public class DefaultEventListenerManager implements EventListenerManager {
 
   @Autowired
-  public DefaultEventListenerManager(RegistryMonitor registryMonitor, 
StatusConvertorFactory convertorFactory) {
-    this(registryMonitor, convertorFactory, DynamicPropertyFactory
-        
.getInstance().getStringProperty(MetricsConfig.METRICS_DIMENSION_STATUS_OUTPUT_LEVEL,
+  public DefaultEventListenerManager(RegistryMonitor registryMonitor, 
StatusConvertorFactory convertorFactory,
+      CounterService counterService, GaugeService gaugeService, 
WindowCounterService windowCounterService) {
+    this(registryMonitor, convertorFactory, counterService, gaugeService, 
windowCounterService,
+        
DynamicPropertyFactory.getInstance().getStringProperty(MetricsConfig.METRICS_DIMENSION_STATUS_OUTPUT_LEVEL,
             
MetricsDimension.DIMENSION_STATUS_OUTPUT_LEVEL_SUCCESS_FAILED).get());
   }
 
   public DefaultEventListenerManager(RegistryMonitor registryMonitor, 
StatusConvertorFactory convertorFactory,
+      CounterService counterService, GaugeService gaugeService, 
WindowCounterService windowCounterService,
       String outputLevel) {
     this.registerEventListener(new 
InvocationStartedEventListener(registryMonitor));
     this.registerEventListener(new 
InvocationStartProcessingEventListener(registryMonitor));
     this.registerEventListener(
         new InvocationFinishedEventListener(registryMonitor, 
convertorFactory.getConvertor(outputLevel)));
+
+    this.registerEventListener(new CounterEventListener(counterService));
+    this.registerEventListener(new GaugeEventListener(gaugeService));
+    this.registerEventListener(new 
WindowCounterEventListener(windowCounterService));
   }
 
   @Override
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/GaugeEventListener.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/GaugeEventListener.java
new file mode 100644
index 000000000..45fb8768e
--- /dev/null
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/GaugeEventListener.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.metrics.core.event;
+
+import org.apache.servicecomb.foundation.common.event.Event;
+import org.apache.servicecomb.foundation.common.event.EventListener;
+import org.apache.servicecomb.foundation.metrics.GaugeEvent;
+import org.apache.servicecomb.metrics.core.custom.GaugeService;
+
+public class GaugeEventListener implements EventListener {
+
+  private final GaugeService gaugeService;
+
+  public GaugeEventListener(GaugeService gaugeService) {
+    this.gaugeService = gaugeService;
+  }
+
+  @Override
+  public Class<? extends Event> getConcernedEvent() {
+    return GaugeEvent.class;
+  }
+
+  @Override
+  public void process(Event data) {
+    GaugeEvent event = (GaugeEvent) data;
+    gaugeService.update(event.getName(), event.getValue());
+  }
+}
diff --git 
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/WindowCounterEventListener.java
 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/WindowCounterEventListener.java
new file mode 100644
index 000000000..ce5d2ff88
--- /dev/null
+++ 
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/event/WindowCounterEventListener.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.metrics.core.event;
+
+import org.apache.servicecomb.foundation.common.event.Event;
+import org.apache.servicecomb.foundation.common.event.EventListener;
+import org.apache.servicecomb.foundation.metrics.WindowCounterEvent;
+import org.apache.servicecomb.metrics.core.custom.WindowCounterService;
+
+public class WindowCounterEventListener implements EventListener {
+
+  private final WindowCounterService windowCounterService;
+
+  public WindowCounterEventListener(WindowCounterService windowCounterService) 
{
+    this.windowCounterService = windowCounterService;
+  }
+
+  @Override
+  public Class<? extends Event> getConcernedEvent() {
+    return WindowCounterEvent.class;
+  }
+
+  @Override
+  public void process(Event data) {
+    WindowCounterEvent event = (WindowCounterEvent) data;
+    windowCounterService.record(event.getName(), event.getValue());
+  }
+}
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestCustomMetricsFromEvent.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestCustomMetricsFromEvent.java
new file mode 100644
index 000000000..841cb5dd8
--- /dev/null
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestCustomMetricsFromEvent.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.metrics.core;
+
+import org.apache.servicecomb.foundation.common.utils.CustomMetricsUtils;
+import org.apache.servicecomb.metrics.common.MetricsDimension;
+import org.apache.servicecomb.metrics.common.RegistryMetric;
+import org.apache.servicecomb.metrics.core.custom.DefaultCounterService;
+import org.apache.servicecomb.metrics.core.custom.DefaultGaugeService;
+import org.apache.servicecomb.metrics.core.custom.DefaultWindowCounterService;
+import org.apache.servicecomb.metrics.core.event.DefaultEventListenerManager;
+import 
org.apache.servicecomb.metrics.core.event.dimension.StatusConvertorFactory;
+import org.apache.servicecomb.metrics.core.monitor.DefaultSystemMonitor;
+import org.apache.servicecomb.metrics.core.monitor.RegistryMonitor;
+import org.apache.servicecomb.metrics.core.monitor.SystemMonitor;
+import org.apache.servicecomb.metrics.core.publish.DefaultDataSource;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestCustomMetricsFromEvent {
+
+  @Test
+  public void testCustom() throws InterruptedException {
+    SystemMonitor systemMonitor = new DefaultSystemMonitor();
+    DefaultCounterService counterService = new DefaultCounterService();
+    DefaultGaugeService gaugeService = new DefaultGaugeService();
+    DefaultWindowCounterService windowCounterService = new 
DefaultWindowCounterService();
+
+    RegistryMonitor monitor = new RegistryMonitor(systemMonitor, 
counterService, gaugeService, windowCounterService);
+    new DefaultEventListenerManager(monitor, new StatusConvertorFactory(),
+        counterService, gaugeService, windowCounterService,
+        MetricsDimension.DIMENSION_STATUS_OUTPUT_LEVEL_SUCCESS_FAILED);
+
+    DefaultDataSource dataSource = new DefaultDataSource(monitor, 
"1000,2000,3000");
+
+    CustomMetricsUtils.incrementCounter("C1");
+    CustomMetricsUtils.incrementCounter("C1", 2);
+    CustomMetricsUtils.incrementCounter("C2", 2);
+    CustomMetricsUtils.decrementCounter("C2");
+
+    CustomMetricsUtils.updateGauge("G1", 100.0);
+    CustomMetricsUtils.updateGauge("G1", 200.0);
+    CustomMetricsUtils.updateGauge("G1", 150.0);
+    CustomMetricsUtils.updateGauge("G2", 250.0);
+
+    CustomMetricsUtils.recordWindowCounter("W1", 1);
+    CustomMetricsUtils.recordWindowCounter("W1", 2);
+    CustomMetricsUtils.recordWindowCounter("W1", 3);
+    CustomMetricsUtils.recordWindowCounter("W2", 1);
+
+    //sim lease one window time
+    Thread.sleep(1000);
+
+    RegistryMetric model = dataSource.getRegistryMetric(1000);
+
+    Assert.assertEquals(3, model.getCustomMetrics().get("C1").longValue());
+    Assert.assertEquals(1, model.getCustomMetrics().get("C2").longValue());
+
+    Assert.assertEquals(150.0, model.getCustomMetrics().get("G1"), 0);
+    Assert.assertEquals(250.0, model.getCustomMetrics().get("G2"), 0);
+
+    Assert.assertEquals(6.0, model.getCustomMetrics().get("W1.total"), 0);
+    Assert.assertEquals(3.0, model.getCustomMetrics().get("W1.count"), 0);
+    Assert.assertEquals(6.0, model.getCustomMetrics().get("W1.rate"), 0);
+    Assert.assertEquals(1.0, model.getCustomMetrics().get("W1.min"), 0);
+    Assert.assertEquals(3.0, model.getCustomMetrics().get("W1.max"), 0);
+    Assert.assertEquals(2.0, model.getCustomMetrics().get("W1.average"), 0);
+    Assert.assertEquals(3.0, model.getCustomMetrics().get("W1.tps"), 0);
+  }
+}
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestEventAndRunner.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestEventAndRunner.java
index db400d191..d60baf1f8 100644
--- 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestEventAndRunner.java
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestEventAndRunner.java
@@ -70,9 +70,12 @@ public void test() throws InterruptedException {
     when(nonHeap.getMax()).thenReturn(700L);
     when(nonHeap.getUsed()).thenReturn(800L);
 
+    DefaultCounterService counterService = new DefaultCounterService();
+    DefaultGaugeService gaugeService = new DefaultGaugeService();
+    DefaultWindowCounterService windowCounterService = new 
DefaultWindowCounterService();
+
     DefaultSystemMonitor systemMonitor = new 
DefaultSystemMonitor(systemMXBean, threadMXBean, memoryMXBean);
-    RegistryMonitor monitor = new RegistryMonitor(systemMonitor, new 
DefaultCounterService(), new DefaultGaugeService(),
-        new DefaultWindowCounterService());
+    RegistryMonitor monitor = new RegistryMonitor(systemMonitor, 
counterService, gaugeService, windowCounterService);
     DefaultDataSource dataSource = new DefaultDataSource(monitor, 
"1000,2000,3000");
 
     List<Long> intervals = dataSource.getAppliedWindowTime();
@@ -80,6 +83,7 @@ public void test() throws InterruptedException {
     Assert.assertThat(intervals, containsInAnyOrder(Arrays.asList(1000L, 
2000L, 3000L).toArray()));
 
     new DefaultEventListenerManager(monitor, new StatusConvertorFactory(),
+        counterService, gaugeService, windowCounterService,
         MetricsDimension.DIMENSION_STATUS_OUTPUT_LEVEL_SUCCESS_FAILED);
 
     //fun1 is a PRODUCER invocation call 2 time and all is completed
diff --git 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestStatusDimension.java
 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestStatusDimension.java
index 844aa0476..bd492dcc2 100644
--- 
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestStatusDimension.java
+++ 
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestStatusDimension.java
@@ -100,11 +100,15 @@ public void testCodeDimension() throws 
InterruptedException {
   private RegistryMetric prepare(String outputLevel) throws 
InterruptedException {
     DefaultSystemMonitor systemMonitor = new DefaultSystemMonitor();
 
-    RegistryMonitor monitor = new RegistryMonitor(systemMonitor, new 
DefaultCounterService(), new DefaultGaugeService(),
-        new DefaultWindowCounterService());
+    DefaultCounterService counterService = new DefaultCounterService();
+    DefaultGaugeService gaugeService = new DefaultGaugeService();
+    DefaultWindowCounterService windowCounterService = new 
DefaultWindowCounterService();
+
+    RegistryMonitor monitor = new RegistryMonitor(systemMonitor, 
counterService, gaugeService, windowCounterService);
     DefaultDataSource dataSource = new DefaultDataSource(monitor, 
"1000,2000,3000");
 
-    new DefaultEventListenerManager(monitor, new StatusConvertorFactory(), 
outputLevel);
+    new DefaultEventListenerManager(monitor, new StatusConvertorFactory(),
+        counterService, gaugeService, windowCounterService, outputLevel);
 
     EventUtils.triggerEvent(new InvocationStartedEvent("fun1", 
InvocationType.PRODUCER, System.nanoTime()));
     EventUtils.triggerEvent(


 

----------------------------------------------------------------
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:
us...@infra.apache.org


> Support Record Custom Metrics in Java Chassis Itself
> ----------------------------------------------------
>
>                 Key: SCB-311
>                 URL: https://issues.apache.org/jira/browse/SCB-311
>             Project: Apache ServiceComb
>          Issue Type: Sub-task
>          Components: Java-Chassis
>            Reporter: yangyongzheng
>            Assignee: yangyongzheng
>            Priority: Major
>             Fix For: java-chassis-1.0.0-m1
>
>
> Current custom metrics only can use out of Java Chassis because metrics core 
> is dependent on Java Chassis core,we need support inject custom metrics in 
> Java Chassis let other developer use this mechanism,like foundcation-vertx 
> count context creation etc...



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to