This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new bbe18e4 SCB-320 remove custom metrics service and we will provider
new mechanism later
bbe18e4 is described below
commit bbe18e493aa3fb3d1531f7e6bee806e22d9994b4
Author: zhengyangyong <[email protected]>
AuthorDate: Sat Feb 3 09:13:54 2018 +0800
SCB-320 remove custom metrics service and we will provider new mechanism
later
Signed-off-by: zhengyangyong <[email protected]>
---
.../servicecomb/metrics/common/RegistryMetric.java | 14 +---
.../metrics/core/custom/CounterService.java | 31 -------
.../metrics/core/custom/DefaultCounterService.java | 71 ----------------
.../metrics/core/custom/DefaultGaugeService.java | 43 ----------
.../core/custom/DefaultWindowCounterService.java | 49 -----------
.../metrics/core/custom/GaugeService.java | 25 ------
.../metrics/core/custom/WindowCounter.java | 76 -----------------
.../metrics/core/custom/WindowCounterService.java | 41 ----------
.../metrics/core/monitor/RegistryMonitor.java | 23 +-----
.../metrics/core/TestCustomMetrics.java | 81 -------------------
.../metrics/core/TestEventAndRunner.java | 6 +-
.../servicecomb/metrics/core/TestPublisher.java | 6 +-
.../metrics/core/TestStatusDimension.java | 6 +-
.../metrics/prometheus/MetricsCollector.java | 13 ---
samples/custom-business-metrics/pom.xml | 56 -------------
.../metrics/custom/CustomMetricsApplication.java | 30 -------
.../samples/metrics/custom/ShopDemoService.java | 94 ----------------------
.../src/main/resources/microservice.yaml | 30 -------
.../servicecomb/samples/mwf/TestWriteFile.java | 3 +-
samples/pom.xml | 1 -
20 files changed, 8 insertions(+), 691 deletions(-)
diff --git
a/metrics/metrics-common/src/main/java/org/apache/servicecomb/metrics/common/RegistryMetric.java
b/metrics/metrics-common/src/main/java/org/apache/servicecomb/metrics/common/RegistryMetric.java
index c03ad8f..b9a919e 100644
---
a/metrics/metrics-common/src/main/java/org/apache/servicecomb/metrics/common/RegistryMetric.java
+++
b/metrics/metrics-common/src/main/java/org/apache/servicecomb/metrics/common/RegistryMetric.java
@@ -29,8 +29,6 @@ public class RegistryMetric {
private final Map<String, ProducerInvocationMetric> producerMetrics;
- private final Map<String, Double> customMetrics;
-
public InstanceMetric getInstanceMetric() {
return instanceMetric;
}
@@ -43,27 +41,19 @@ public class RegistryMetric {
return producerMetrics;
}
- public Map<String, Double> getCustomMetrics() {
- return customMetrics;
- }
-
public RegistryMetric(@JsonProperty("instanceMetric") InstanceMetric
instanceMetric,
@JsonProperty("consumerMetrics") Map<String, ConsumerInvocationMetric>
consumerMetrics,
- @JsonProperty("producerMetrics") Map<String, ProducerInvocationMetric>
producerMetrics,
- @JsonProperty("customMetrics") Map<String, Double> customMetrics) {
+ @JsonProperty("producerMetrics") Map<String, ProducerInvocationMetric>
producerMetrics) {
this.consumerMetrics = consumerMetrics;
this.producerMetrics = producerMetrics;
this.instanceMetric = instanceMetric;
- this.customMetrics = customMetrics;
}
public RegistryMetric(SystemMetric systemMetric,
Map<String, ConsumerInvocationMetric> consumerMetrics,
- Map<String, ProducerInvocationMetric> producerMetrics,
- Map<String, Double> customMetrics) {
+ Map<String, ProducerInvocationMetric> producerMetrics) {
this.consumerMetrics = consumerMetrics;
this.producerMetrics = producerMetrics;
- this.customMetrics = customMetrics;
ConsumerInvocationMetric instanceConsumerInvocationMetric = new
ConsumerInvocationMetric("instance",
MetricsConst.INSTANCE_CONSUMER_PREFIX,
diff --git
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/CounterService.java
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/CounterService.java
deleted file mode 100644
index a67993f..0000000
---
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/CounterService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.custom;
-
-/**
- CounterService is simple service for manage basic counter,Window
Time-unrelated,always get latest value
- */
-public interface CounterService {
- void increment(String name);
-
- void increment(String name, long value);
-
- void decrement(String name);
-
- void reset(String name);
-}
diff --git
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/DefaultCounterService.java
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/DefaultCounterService.java
deleted file mode 100644
index a41319c..0000000
---
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/DefaultCounterService.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.custom;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
-import org.springframework.stereotype.Component;
-
-import com.netflix.servo.monitor.BasicCounter;
-import com.netflix.servo.monitor.MonitorConfig;
-
-@Component
-public class DefaultCounterService implements CounterService {
-
- private final Map<String, BasicCounter> counters;
-
- public DefaultCounterService() {
- this.counters = new ConcurrentHashMapEx<>();
- }
-
- @Override
- public void increment(String name) {
- getCounter(name).increment();
- }
-
- @Override
- public void increment(String name, long value) {
- getCounter(name).increment(value);
- }
-
- @Override
- public void decrement(String name) {
- getCounter(name).increment(-1);
- }
-
- @Override
- public void reset(String name) {
- counters.remove(name);
- this.increment(name, 0);
- }
-
- private BasicCounter getCounter(String name) {
- return counters.computeIfAbsent(name, n -> new
BasicCounter(MonitorConfig.builder(n).build()));
- }
-
- public Map<String, Double> toMetrics() {
- Map<String, Double> metrics = new HashMap<>();
- for (Entry<String, BasicCounter> counter : counters.entrySet()) {
- metrics.put(counter.getKey(),
counter.getValue().getValue().doubleValue());
- }
- return metrics;
- }
-}
diff --git
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/DefaultGaugeService.java
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/DefaultGaugeService.java
deleted file mode 100644
index 4789ae5..0000000
---
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/DefaultGaugeService.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.custom;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
-import org.springframework.stereotype.Component;
-
-@Component
-public class DefaultGaugeService implements GaugeService {
-
- private final Map<String, Double> gauges;
-
- public DefaultGaugeService() {
- this.gauges = new ConcurrentHashMapEx<>();
- }
-
- @Override
- public void update(String name, double value) {
- this.gauges.put(name, value);
- }
-
- public Map<String, Double> toMetrics() {
- return new HashMap<>(gauges);
- }
-}
diff --git
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/DefaultWindowCounterService.java
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/DefaultWindowCounterService.java
deleted file mode 100644
index 6f53ae6..0000000
---
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/DefaultWindowCounterService.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.custom;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
-import org.springframework.stereotype.Component;
-
-@Component
-public class DefaultWindowCounterService implements WindowCounterService {
-
- private final Map<String, WindowCounter> counters;
-
- public DefaultWindowCounterService() {
- this.counters = new ConcurrentHashMapEx<>();
- }
-
- @Override
- public void record(String name, long value) {
- WindowCounter counter = counters.computeIfAbsent(name, WindowCounter::new);
- counter.update(value);
- }
-
- public Map<String, Double> toMetrics(int windowTimeIndex) {
- Map<String, Double> metrics = new HashMap<>();
- for (Entry<String, WindowCounter> counter : counters.entrySet()) {
- metrics.putAll(counter.getValue().toMetric(windowTimeIndex));
- }
- return metrics;
- }
-}
diff --git
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/GaugeService.java
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/GaugeService.java
deleted file mode 100644
index a69ca43..0000000
---
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/GaugeService.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.custom;
-
-/**
- GaugeService is simple service for manage basic gauge,Window
Time-unrelated,always get latest value
- */
-public interface GaugeService {
- void update(String name, double value);
-}
diff --git
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/WindowCounter.java
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/WindowCounter.java
deleted file mode 100644
index 9684f20..0000000
---
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/WindowCounter.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.custom;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.netflix.servo.monitor.MaxGauge;
-import com.netflix.servo.monitor.MinGauge;
-import com.netflix.servo.monitor.MonitorConfig;
-import com.netflix.servo.monitor.StepCounter;
-
-public class WindowCounter {
- private final String name;
-
- private final StepCounter total;
-
- private final StepCounter count;
-
- private final MinGauge min;
-
- private final MaxGauge max;
-
- public WindowCounter(String name) {
- this.name = name;
- total = new StepCounter(MonitorConfig.builder(name).build());
- count = new StepCounter(MonitorConfig.builder(name).build());
- min = new MinGauge(MonitorConfig.builder(name).build());
- max = new MaxGauge(MonitorConfig.builder(name).build());
- }
-
- public void update(long value) {
- if (value > 0) {
- total.increment(value);
- count.increment();
- max.update(value);
- min.update(value);
- }
- }
-
- public Map<String, Double> toMetric(int windowTimeIndex) {
- Map<String, Double> metrics = new HashMap<>();
- metrics.put(name + ".total",
this.adjustValue(total.getCount(windowTimeIndex)));
- metrics.put(name + ".count",
this.adjustValue(count.getCount(windowTimeIndex)));
- metrics.put(name + ".max",
this.adjustValue(max.getValue(windowTimeIndex)));
- metrics.put(name + ".min",
this.adjustValue(min.getValue(windowTimeIndex)));
- double value = count.getCount(windowTimeIndex) == 0 ? 0 :
- (double) this.total.getCount(windowTimeIndex) / (double)
this.count.getCount(windowTimeIndex);
- metrics.put(name + ".average", value);
- metrics.put(name + ".rate",
this.adjustValue(total.getValue(windowTimeIndex).doubleValue()));
- metrics.put(name + ".tps",
this.adjustValue(count.getValue(windowTimeIndex).doubleValue()));
- return metrics;
- }
-
- //for time-related monitor type, if stop poll value over one window time,
- //the value may return -1 because servo can't known precise value of
previous step
- //so must change to return 0
- private double adjustValue(double value) {
- return value < 0 ? 0 : value;
- }
-}
diff --git
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/WindowCounterService.java
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/WindowCounterService.java
deleted file mode 100644
index 26ba380..0000000
---
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/custom/WindowCounterService.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.custom;
-
-/**
- WindowCounterService is complex service for manage 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 :
- record("Order Amount",100)
- record("Order Amount",200)
- record("Order Amount",300)
- record("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 interface WindowCounterService {
- void record(String name, long value);
-}
diff --git
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/monitor/RegistryMonitor.java
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/monitor/RegistryMonitor.java
index 982e11b..78be282 100644
---
a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/monitor/RegistryMonitor.java
+++
b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/monitor/RegistryMonitor.java
@@ -24,9 +24,6 @@ import
org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
import org.apache.servicecomb.metrics.common.ConsumerInvocationMetric;
import org.apache.servicecomb.metrics.common.ProducerInvocationMetric;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -39,20 +36,9 @@ public class RegistryMonitor {
private final Map<String, ProducerInvocationMonitor>
producerInvocationMonitors;
- private final DefaultCounterService counterService;
-
- private final DefaultGaugeService gaugeService;
-
- private final DefaultWindowCounterService windowCounterService;
-
@Autowired
- public RegistryMonitor(SystemMonitor systemMonitor,
- DefaultCounterService counterService, DefaultGaugeService gaugeService,
- DefaultWindowCounterService windowCounterService) {
+ public RegistryMonitor(SystemMonitor systemMonitor) {
this.systemMonitor = systemMonitor;
- this.counterService = counterService;
- this.gaugeService = gaugeService;
- this.windowCounterService = windowCounterService;
this.consumerInvocationMonitors = new ConcurrentHashMapEx<>();
this.producerInvocationMonitors = new ConcurrentHashMapEx<>();
}
@@ -75,11 +61,6 @@ public class RegistryMonitor {
producerInvocationMetrics.put(monitor.getOperationName(),
monitor.toMetric(windowTimeIndex));
}
- Map<String, Double> customMetrics = new
HashMap<>(counterService.toMetrics());
- customMetrics.putAll(gaugeService.toMetrics());
- customMetrics.putAll(windowCounterService.toMetrics(windowTimeIndex));
-
- return new RegistryMetric(systemMonitor.toMetric(),
consumerInvocationMetrics, producerInvocationMetrics,
- customMetrics);
+ return new RegistryMetric(systemMonitor.toMetric(),
consumerInvocationMetrics, producerInvocationMetrics);
}
}
diff --git
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestCustomMetrics.java
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestCustomMetrics.java
deleted file mode 100644
index b0ac7e1..0000000
---
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestCustomMetrics.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.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.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 TestCustomMetrics {
-
- @Test
- public void testCustom() throws InterruptedException {
- SystemMonitor systemMonitor = new DefaultSystemMonitor();
- DefaultCounterService counterService = new DefaultCounterService();
- DefaultGaugeService gaugeService = new DefaultGaugeService();
- DefaultWindowCounterService windowCounterService = new
DefaultWindowCounterService();
-
- RegistryMonitor registryMonitor = new RegistryMonitor(systemMonitor,
counterService, gaugeService,
- windowCounterService);
- DefaultDataSource dataSource = new DefaultDataSource(registryMonitor,
"1000,2000,3000");
-
- counterService.increment("C1");
- counterService.increment("C1");
- counterService.decrement("C1");
-
- counterService.increment("C2", 99);
- counterService.reset("C2");
-
- counterService.increment("C3", 20);
-
- gaugeService.update("G1", 100);
- gaugeService.update("G1", 200);
- gaugeService.update("G2", 150);
-
- windowCounterService.record("W1", 100);
- windowCounterService.record("W1", 200);
- windowCounterService.record("W1", 300);
- windowCounterService.record("W1", 400);
-
- //sim lease one window time
- Thread.sleep(1000);
-
- RegistryMetric metric = dataSource.getRegistryMetric(1000);
-
- Assert.assertEquals(1, metric.getCustomMetrics().get("C1").intValue());
- Assert.assertEquals(0, metric.getCustomMetrics().get("C2").intValue());
- Assert.assertEquals(20, metric.getCustomMetrics().get("C3").intValue());
- Assert.assertEquals(200, metric.getCustomMetrics().get("G1").intValue());
- Assert.assertEquals(150, metric.getCustomMetrics().get("G2").intValue());
-
- Assert.assertEquals(1000, metric.getCustomMetrics().get("W1.total"), 0);
- Assert.assertEquals(4, metric.getCustomMetrics().get("W1.count"), 0);
- Assert.assertEquals(4, metric.getCustomMetrics().get("W1.tps"), 0);
- Assert.assertEquals(1000, metric.getCustomMetrics().get("W1.rate"), 0);
- Assert.assertEquals(250, metric.getCustomMetrics().get("W1.average"), 0);
- Assert.assertEquals(100, metric.getCustomMetrics().get("W1.min"), 0);
- Assert.assertEquals(400, metric.getCustomMetrics().get("W1.max"), 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 db400d1..85cf463 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
@@ -35,9 +35,6 @@ import
org.apache.servicecomb.core.metrics.InvocationStartedEvent;
import org.apache.servicecomb.foundation.common.utils.EventUtils;
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;
@@ -71,8 +68,7 @@ public class TestEventAndRunner {
when(nonHeap.getUsed()).thenReturn(800L);
DefaultSystemMonitor systemMonitor = new
DefaultSystemMonitor(systemMXBean, threadMXBean, memoryMXBean);
- RegistryMonitor monitor = new RegistryMonitor(systemMonitor, new
DefaultCounterService(), new DefaultGaugeService(),
- new DefaultWindowCounterService());
+ RegistryMonitor monitor = new RegistryMonitor(systemMonitor);
DefaultDataSource dataSource = new DefaultDataSource(monitor,
"1000,2000,3000");
List<Long> intervals = dataSource.getAppliedWindowTime();
diff --git
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestPublisher.java
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestPublisher.java
index 8650fc5..bf38058 100644
---
a/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestPublisher.java
+++
b/metrics/metrics-core/src/test/java/org/apache/servicecomb/metrics/core/TestPublisher.java
@@ -24,9 +24,6 @@ import java.util.List;
import java.util.Map;
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.monitor.DefaultSystemMonitor;
import org.apache.servicecomb.metrics.core.monitor.RegistryMonitor;
import org.apache.servicecomb.metrics.core.monitor.SystemMonitor;
@@ -40,8 +37,7 @@ public class TestPublisher {
@Test
public void test() {
SystemMonitor systemMonitor = new DefaultSystemMonitor();
- RegistryMonitor registryMonitor = new RegistryMonitor(systemMonitor, new
DefaultCounterService(),
- new DefaultGaugeService(), new DefaultWindowCounterService());
+ RegistryMonitor registryMonitor = new RegistryMonitor(systemMonitor);
DefaultDataSource dataSource = new DefaultDataSource(registryMonitor,
"1000,2000,3000,3000,2000,1000");
DefaultMetricsPublisher publisher = new
DefaultMetricsPublisher(dataSource);
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 844aa04..897648b 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
@@ -25,9 +25,6 @@ import
org.apache.servicecomb.core.metrics.InvocationStartedEvent;
import org.apache.servicecomb.foundation.common.utils.EventUtils;
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;
@@ -100,8 +97,7 @@ public class TestStatusDimension {
private RegistryMetric prepare(String outputLevel) throws
InterruptedException {
DefaultSystemMonitor systemMonitor = new DefaultSystemMonitor();
- RegistryMonitor monitor = new RegistryMonitor(systemMonitor, new
DefaultCounterService(), new DefaultGaugeService(),
- new DefaultWindowCounterService());
+ RegistryMonitor monitor = new RegistryMonitor(systemMonitor);
DefaultDataSource dataSource = new DefaultDataSource(monitor,
"1000,2000,3000");
new DefaultEventListenerManager(monitor, new StatusConvertorFactory(),
outputLevel);
diff --git
a/metrics/metrics-integration/metrics-prometheus/src/main/java/org/apache/servicecomb/metrics/prometheus/MetricsCollector.java
b/metrics/metrics-integration/metrics-prometheus/src/main/java/org/apache/servicecomb/metrics/prometheus/MetricsCollector.java
index 52bab8e..932863e 100644
---
a/metrics/metrics-integration/metrics-prometheus/src/main/java/org/apache/servicecomb/metrics/prometheus/MetricsCollector.java
+++
b/metrics/metrics-integration/metrics-prometheus/src/main/java/org/apache/servicecomb/metrics/prometheus/MetricsCollector.java
@@ -88,22 +88,9 @@ public class MetricsCollector extends Collector implements
Collector.Describable
.add(new MetricFamilySamples("Producer Side", Type.UNTYPED,
"Producer Side Metrics", producerSamples));
}
- if (registryMetric.getCustomMetrics().size() != 0) {
- familySamples.add(getFamilySamples("User Custom",
registryMetric.getCustomMetrics()));
- }
-
return familySamples;
}
- private <T extends Number> MetricFamilySamples getFamilySamples(String name,
Map<String, T> metrics) {
- List<Sample> samples = metrics.entrySet()
- .stream()
- .map((entry) -> new Sample(entry.getKey().replace(".", "_"),
- new ArrayList<>(), new ArrayList<>(),
entry.getValue().doubleValue()))
- .collect(Collectors.toList());
- return new MetricFamilySamples(name, Type.UNTYPED, name + " Metrics",
samples);
- }
-
private List<Sample> convertConsumerMetric(ConsumerInvocationMetric metric) {
return convertMetricValues(metric.getConsumerLatency().toMap());
}
diff --git a/samples/custom-business-metrics/pom.xml
b/samples/custom-business-metrics/pom.xml
deleted file mode 100644
index 90b60da..0000000
--- a/samples/custom-business-metrics/pom.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>samples</artifactId>
- <groupId>org.apache.servicecomb.samples</groupId>
- <version>0.6.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>custom-business-metrics</artifactId>
- <name>Java Chassis::Samples::Custom Business Metrics</name>
-
-
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>spring-boot-starter-provider</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.servicecomb</groupId>
- <artifactId>metrics-core</artifactId>
- </dependency>
- </dependencies>
-
-
-</project>
\ No newline at end of file
diff --git
a/samples/custom-business-metrics/src/main/java/org/apache/servicecomb/samples/metrics/custom/CustomMetricsApplication.java
b/samples/custom-business-metrics/src/main/java/org/apache/servicecomb/samples/metrics/custom/CustomMetricsApplication.java
deleted file mode 100644
index 3826c99..0000000
---
a/samples/custom-business-metrics/src/main/java/org/apache/servicecomb/samples/metrics/custom/CustomMetricsApplication.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.samples.metrics.custom;
-
-import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-@EnableServiceComb
-public class CustomMetricsApplication {
- public static void main(String[] args) {
- SpringApplication.run(CustomMetricsApplication.class, args);
- }
-}
diff --git
a/samples/custom-business-metrics/src/main/java/org/apache/servicecomb/samples/metrics/custom/ShopDemoService.java
b/samples/custom-business-metrics/src/main/java/org/apache/servicecomb/samples/metrics/custom/ShopDemoService.java
deleted file mode 100644
index 6e5faec..0000000
---
a/samples/custom-business-metrics/src/main/java/org/apache/servicecomb/samples/metrics/custom/ShopDemoService.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.samples.metrics.custom;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-
-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.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ShopDemoService {
-
- private final CounterService counterService;
-
- private final GaugeService gaugeService;
-
- private final WindowCounterService windowCounterService;
-
- //autowire metrics service
- @Autowired
- public ShopDemoService(CounterService counterService, GaugeService
gaugeService,
- WindowCounterService windowCounterService) {
- this.counterService = counterService;
- this.gaugeService = gaugeService;
- this.windowCounterService = windowCounterService;
-
- login(null,null);
- }
-
- public void login(String name, String password) {
- counterService.increment("Active User");
- }
-
- public void logout(String session) {
- counterService.decrement("Active User");
- }
-
- public void order(double amount) throws InterruptedException {
- long start = System.currentTimeMillis();
- //sim do order process
- Thread.sleep(100);
-
- //sim record order process time
- windowCounterService.record("Order Latency", System.currentTimeMillis() -
start);
-
- //plus one
- windowCounterService.record("Order Count", 1);
-
- //only support long,please do unit convert ,$99.00 dollar -> $9900 cent,
$59.99 dollar -> $5999 cent
- windowCounterService.record("Order Amount", (long) round(amount * 100, 0));
- }
-
- public void discount(double value) {
- //make a discount to Levis Jeans
-
- //record current Levis Jeans Discount
- gaugeService.update("Levis Jeans Discount", value);
- }
-
- private double round(double value, int places) {
- if (!Double.isNaN(value)) {
- BigDecimal decimal = new BigDecimal(value);
- return decimal.setScale(places, RoundingMode.HALF_UP).doubleValue();
- }
- return 0;
- }
-
- /* Output of RegistryMetric.customMetrics :
- * Active User
- * Order Latency (total,count,tps,rate,average,max,min)
- * Order Count (total,count,tps,rate,average,max,min)
- * Order Amount (total,count,tps,rate,average,max,min)
- * Levis Jeans Discount
- */
-}
diff --git
a/samples/custom-business-metrics/src/main/resources/microservice.yaml
b/samples/custom-business-metrics/src/main/resources/microservice.yaml
deleted file mode 100644
index c1c9226..0000000
--- a/samples/custom-business-metrics/src/main/resources/microservice.yaml
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-
-# all interconnected microservices must belong to an application wth the same
ID
-APPLICATION_ID: metrics
-service_description:
-# name of the declaring microservice
- name: metricsCustom
- version: 0.0.1
-cse:
- service:
- registry:
- address: http://127.0.0.1:30100
- rest:
- address: 0.0.0.0:7777
\ No newline at end of file
diff --git
a/samples/metrics-write-file-sample/metrics-write-file/src/test/java/org/apache/servicecomb/samples/mwf/TestWriteFile.java
b/samples/metrics-write-file-sample/metrics-write-file/src/test/java/org/apache/servicecomb/samples/mwf/TestWriteFile.java
index 8571ae7..67f4b44 100644
---
a/samples/metrics-write-file-sample/metrics-write-file/src/test/java/org/apache/servicecomb/samples/mwf/TestWriteFile.java
+++
b/samples/metrics-write-file-sample/metrics-write-file/src/test/java/org/apache/servicecomb/samples/mwf/TestWriteFile.java
@@ -156,8 +156,7 @@ public class TestWriteFile {
new CallMetric("B2", Collections.singletonList(new
LongMetricValue("B2", 100L, new HashMap<>())),
Collections.singletonList(new DoubleMetricValue("B2",
888.66666, new HashMap<>())))));
- RegistryMetric metric = new RegistryMetric(systemMetric,
consumerInvocationMetricMap, new HashMap<>(),
- new HashMap<>());
+ RegistryMetric metric = new RegistryMetric(systemMetric,
consumerInvocationMetricMap, new HashMap<>());
DataSource dataSource = Mockito.mock(DataSource.class);
Mockito.when(dataSource.getRegistryMetric()).thenReturn(metric);
diff --git a/samples/pom.xml b/samples/pom.xml
index 2c60a7c..0590c43 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -37,7 +37,6 @@
<module>metrics-write-file-sample</module>
<module>metrics-extend-healthcheck</module>
<module>config-apollo-sample</module>
- <module>custom-business-metrics</module>
</modules>
<dependencyManagement>
--
To stop receiving notification emails like this one, please contact
[email protected].