You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/08/19 15:03:28 UTC
[incubator-skywalking-oal-tool] branch master updated: Support
double avg.
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking-oal-tool.git
The following commit(s) were added to refs/heads/master by this push:
new 6f6aaf2 Support double avg.
6f6aaf2 is described below
commit 6f6aaf262a15beeca078780b966228f909965ea0
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Sun Aug 19 23:03:22 2018 +0800
Support double avg.
---
.../skywalking/oap/server/core/Indicators.java | 2 +
.../analysis/indicator/DoubleAvgIndicator.java | 53 ++++++++++++++++++++++
oal-parser/src/test/resources/oal_test.oal | 2 +-
3 files changed, 56 insertions(+), 1 deletion(-)
diff --git a/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/Indicators.java b/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/Indicators.java
index 2787979..b02f540 100644
--- a/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/Indicators.java
+++ b/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/Indicators.java
@@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.core;
import java.util.HashMap;
import java.util.Map;
+import org.apache.skywalking.oap.server.core.analysis.indicator.DoubleAvgIndicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.LongAvgIndicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.PercentIndicator;
@@ -29,6 +30,7 @@ public class Indicators {
static {
REGISTER.put("longAvg", LongAvgIndicator.class);
+ REGISTER.put("doubleAvg", DoubleAvgIndicator.class);
REGISTER.put("percent", PercentIndicator.class);
}
diff --git a/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/DoubleAvgIndicator.java b/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/DoubleAvgIndicator.java
new file mode 100644
index 0000000..036f1f5
--- /dev/null
+++ b/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/DoubleAvgIndicator.java
@@ -0,0 +1,53 @@
+/*
+ * 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.skywalking.oap.server.core.analysis.indicator;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.ConstOne;
+import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.Entrance;
+import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorOperator;
+import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.SourceFrom;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+
+/**
+ * @author peng-yongsheng
+ */
+@IndicatorOperator
+public abstract class DoubleAvgIndicator extends Indicator {
+
+ protected static final String SUMMATION = "summation";
+ protected static final String COUNT = "count";
+ protected static final String VALUE = "value";
+
+ @Getter @Setter @Column(columnName = SUMMATION) private double summation;
+ @Getter @Setter @Column(columnName = COUNT) private int count;
+ @Getter @Setter @Column(columnName = VALUE) private double value;
+
+ @Entrance
+ public final void combine(@SourceFrom double summation, @ConstOne int count) {
+ this.summation += summation;
+ this.count += count;
+ }
+
+ @Override public final void combine(Indicator indicator) {
+ DoubleAvgIndicator longAvgIndicator = (DoubleAvgIndicator)indicator;
+ combine(longAvgIndicator.summation, longAvgIndicator.count);
+ }
+}
diff --git a/oal-parser/src/test/resources/oal_test.oal b/oal-parser/src/test/resources/oal_test.oal
index a722650..d2674b4 100644
--- a/oal-parser/src/test/resources/oal_test.oal
+++ b/oal-parser/src/test/resources/oal_test.oal
@@ -21,7 +21,7 @@ Service_Avg = from(Service.latency).longAvg();
endpoint_Avg = from(Endpoint.latency).longAvg();
endpoint_percent = from(Endpoint.*).percent(status == true);
-instance_jvm_cpu = from(ServiceInstanceJVMCPU.usePercent).longAvg();
+instance_jvm_cpu = from(ServiceInstanceJVMCPU.usePercent).doubleAvg();
instance_jvm_memory_max = from(ServiceInstanceJVMMemory.max).longAvg();