From b560bae3f887e967a6639674fc5507071a96d0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=9F=20Wu=20Sheng?= Date: Sun, 27 Sep 2020 07:31:33 +0800 Subject: [PATCH] Polish comments of the meter at the agent side. (#5565) * Polish comments of the meter at the agent side. * Fix code style. --- .../skywalking/apm/toolkit/meter/Counter.java | 4 +- .../skywalking/apm/toolkit/meter/Gauge.java | 2 + .../apm/toolkit/meter/Histogram.java | 17 +++---- .../apm/toolkit/meter/MeterCenter.java | 6 +-- .../skywalking/apm/toolkit/meter/MeterId.java | 2 +- .../apm/agent/core/meter/BaseMeter.java | 21 +++----- .../apm/agent/core/meter/Counter.java | 2 +- .../apm/agent/core/meter/CounterMode.java | 4 +- .../apm/agent/core/meter/Gauge.java | 1 - .../apm/agent/core/meter/Histogram.java | 48 ++++++++++--------- .../apm/agent/core/meter/MeterFactory.java | 13 +++-- .../apm/agent/core/meter/MeterId.java | 2 +- .../apm/agent/core/meter/MeterSender.java | 2 +- .../apm/agent/core/meter/MeterService.java | 3 +- .../apm/agent/core/meter/MeterType.java | 12 +++++ 15 files changed, 79 insertions(+), 60 deletions(-) diff --git a/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Counter.java b/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Counter.java index d3f947c96a..e794b6bf85 100644 --- a/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Counter.java +++ b/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Counter.java @@ -19,7 +19,9 @@ package org.apache.skywalking.apm.toolkit.meter; /** - * A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart. + * A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase. + * + * The source code of this class doesn't include the implementation, all logic are injected from its activation. */ public class Counter extends BaseMeter { diff --git a/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Gauge.java b/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Gauge.java index 60cdaeff4d..25199df9b5 100644 --- a/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Gauge.java +++ b/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Gauge.java @@ -22,6 +22,8 @@ import java.util.function.Supplier; /** * A gauge is a metric that represents a single numerical value that can arbitrarily go up and down. + * + * The source code of this class doesn't include the implementation, all logic are injected from its activation. */ public class Gauge extends BaseMeter { diff --git a/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Histogram.java b/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Histogram.java index caf12da856..3915f2ba88 100644 --- a/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Histogram.java +++ b/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/Histogram.java @@ -23,9 +23,11 @@ import java.util.List; import java.util.stream.Collectors; /** - * A summary sample observations (usual things like request durations and response sizes). - * While it also provides a total count of observations and a sum of all observed values, it calculates configurable quartiles over a sliding time window. - * The histogram provides detailed data in each data group. + * Histogram represents the distribution of data. It includes the buckets representing continuous ranges of values, with + * the num of collected values in every specific range. The ranges could start from any value(default 0) to positive + * infinitive. They can be set through the constructor and immutable after that. + * + * The source code of this class doesn't include the implementation, all logic are injected from its activation. */ public class Histogram extends BaseMeter { @@ -34,8 +36,7 @@ public class Histogram extends BaseMeter { } /** - * Add value into the histogram, automatic analyze what bucket count need to be increment - * [step1, step2) + * Add value into the histogram, automatic analyze what bucket count need to be increment [step1, step2) */ public void addValue(double value) { } @@ -53,7 +54,7 @@ public class Histogram extends BaseMeter { } /** - * Setting bucket steps + * Set bucket steps, the minimal values of every buckets besides the {@link #minValue}. */ public Builder steps(List steps) { this.steps = new ArrayList<>(steps); @@ -61,7 +62,7 @@ public class Histogram extends BaseMeter { } /** - * Setting min value, default is zero + * Set min value, default is zero */ public Builder minValue(double minValue) { this.minValue = minValue; @@ -84,7 +85,7 @@ public class Histogram extends BaseMeter { // verify steps with except min value if (steps.get(0) < minValue) { - throw new IllegalArgumentException("First step must bigger than min value"); + throw new IllegalArgumentException("Step[0] must be bigger than min value"); } else if (steps.get(0) != minValue) { // add the min value to the steps steps.add(0, minValue); diff --git a/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/MeterCenter.java b/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/MeterCenter.java index e4492726d4..de79118551 100644 --- a/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/MeterCenter.java +++ b/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/MeterCenter.java @@ -19,13 +19,13 @@ package org.apache.skywalking.apm.toolkit.meter; /** - * Management the meter. + * Management the meter. No implementation yet. As meter typically is not deleted/removed by the user codes manually, we + * don't support this. */ public class MeterCenter { /** - * Remove meter - * @return Meter reference if exists + * @return NULL always, no real operation. */ public static BaseMeter removeMeter(MeterId id) { return null; diff --git a/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/MeterId.java b/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/MeterId.java index 34949ce326..3473c526da 100644 --- a/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/MeterId.java +++ b/apm-application-toolkit/apm-toolkit-meter/src/main/java/org/apache/skywalking/apm/toolkit/meter/MeterId.java @@ -79,7 +79,7 @@ public class MeterId { /** * The meter type */ - public static enum MeterType { + public enum MeterType { COUNTER, GAUGE, HISTOGRAM diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/meter/BaseMeter.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/meter/BaseMeter.java index 6b9cd24d11..122d71c84d 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/meter/BaseMeter.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/meter/BaseMeter.java @@ -18,19 +18,18 @@ package org.apache.skywalking.apm.agent.core.meter; -import org.apache.skywalking.apm.network.language.agent.v3.Label; -import org.apache.skywalking.apm.network.language.agent.v3.MeterData; - import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; +import org.apache.skywalking.apm.network.language.agent.v3.Label; +import org.apache.skywalking.apm.network.language.agent.v3.MeterData; +/** + * BaseMeter is the basic class of all available meter implementations. + * It includes all labels and unique id representing this meter. + */ public abstract class BaseMeter { protected final MeterId meterId; - // cache the gRPC label message - private List