You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2017/12/27 01:26:21 UTC
[incubator-servicecomb-java-chassis] 07/12: JAV-539 & SCB-9 add
code comment for windowtime
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
commit 7a490c47e05db24a345b0c105ed08e72601834a1
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Sat Dec 23 10:27:59 2017 +0800
JAV-539 & SCB-9 add code comment for windowtime
Signed-off-by: zhengyangyong <ya...@huawei.com>
---
.../metrics/core/publish/DataSource.java | 36 ++++++++++++++++++++--
.../metrics/core/publish/DefaultDataSource.java | 2 +-
.../src/main/resources/microservice.yaml | 9 +++---
3 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DataSource.java b/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DataSource.java
index fbd47d4..47f7c83 100644
--- a/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DataSource.java
+++ b/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DataSource.java
@@ -22,9 +22,41 @@ import java.util.List;
import io.servicecomb.metrics.core.metric.RegistryMetric;
public interface DataSource {
- RegistryMetric getRegistryMetric();
- RegistryMetric getRegistryMetric(int windowTimeIndex);
+ /** What's the WindowTime ?
+ We all know there are two major type of metric :
+ 1.Time-unrelated,you can get the latest value any time immediately:
+ Counter -> increase or decrease
+ Guage -> set a certain one value
+ 2.Time-related,only after a centain time pass you can compute the right value,"a centain time" called WindowTime
+ Max & Min -> the max value or min value in a centain time
+ Average -> average value, the simplest algorithm is f = sum / count
+ Rate -> like TPS,algorithm is f = sum / second
+ Will be return "servicecomb.metrics.window_time" setting in microservice.yaml
+ */
List<Long> getAppliedWindowTime();
+
+ //return getRegistryMetric(0)
+ RegistryMetric getRegistryMetric();
+
+ /**
+ * windowTimeIndex usage example:
+ * if there is two window time set in "servicecomb.metrics.window_time" like 1000,2000
+ * then windowTimeIndex = 0 will return result of the setting 1000(1 second)
+ * windowTimeIndex = 1 will return result of the setting 2000(2 second)
+ *
+ * there are three monitor of max,min,total
+ * 0----------1----------2---------- <-time line (second)
+ * 100,200 300,400 <-value record
+ *
+ * ↑ getRegistryMetric(0) will return max=200 min=100 total=300
+ * getRegistryMetric(1) will return max=0 min=0 total=0
+ * ↑ getRegistryMetric(0) will return max=300 min=400 total=700
+ * getRegistryMetric(1) will return max=400 min=100 total=1000
+ *
+ * @param windowTimeIndex index of getAppliedWindowTime() item
+ * @return RegistryMetric
+ */
+ RegistryMetric getRegistryMetric(int windowTimeIndex);
}
diff --git a/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultDataSource.java b/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultDataSource.java
index 59a9d91..9549884 100644
--- a/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultDataSource.java
+++ b/metrics/metrics-core/src/main/java/io/servicecomb/metrics/core/publish/DefaultDataSource.java
@@ -30,7 +30,7 @@ import io.servicecomb.metrics.core.monitor.RegistryMonitor;
@Component
public class DefaultDataSource implements DataSource {
- private static final String METRICS_POLLING_TIME = "servicecomb.metrics.polling.time";
+ private static final String METRICS_POLLING_TIME = "servicecomb.metrics.window_time";
private final RegistryMonitor registryMonitor;
diff --git a/metrics/metrics-sample/metrics-performance-test/src/main/resources/microservice.yaml b/metrics/metrics-sample/metrics-performance-test/src/main/resources/microservice.yaml
index 52596aa..b5edcd1 100644
--- a/metrics/metrics-sample/metrics-performance-test/src/main/resources/microservice.yaml
+++ b/metrics/metrics-sample/metrics-performance-test/src/main/resources/microservice.yaml
@@ -30,7 +30,8 @@ cse:
servicecomb:
metrics:
- #polling setting
- polling:
- #Support Muti-Polling Time (MILLISECONDS) like 10000,60000 (10s and 60s), Use pollerIndex make selection,start from 0
- time: 10000
\ No newline at end of file
+ #Support Muti-WindowTime (MILLISECONDS) like 10000,60000 (10s and 60s), Use WindowTimeIndex make selection,start from 0
+ #Default value is single WindowTime : 5000 (5 second)
+ #Will direct set value of "servo.pollers"
+ #More info can be found here : https://github.com/Netflix/servo/wiki/Getting-Started -> Polling Intervals Chapter
+ window_time: 5000
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.