You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/01/10 12:54:42 UTC
[skywalking] branch percentile updated: Update query protocol and
add percentile test case
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch percentile
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/percentile by this push:
new 05d791a Update query protocol and add percentile test case
05d791a is described below
commit 05d791a92f28fc48dbf8d6bde5f7e974867c8b93
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Fri Jan 10 20:54:14 2020 +0800
Update query protocol and add percentile test case
---
.../core/analysis/metrics/PercentileMetrics.java | 8 ++
.../analysis/metrics/PercentileMetricsTest.java | 86 ++++++++++++++++++++++
.../src/main/resources/query-protocol | 2 +-
3 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentileMetrics.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentileMetrics.java
index ec09208..078b851 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentileMetrics.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentileMetrics.java
@@ -109,4 +109,12 @@ public abstract class PercentileMetrics extends GroupMetrics implements MultiInt
}
}
}
+
+ public int[] getValues() {
+ int[] values = new int[percentileValues.size()];
+ for (int i = 0; i < values.length; i++) {
+ values[i] = (int)percentileValues.get(i).getValue();
+ }
+ return values;
+ }
}
diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentileMetricsTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentileMetricsTest.java
new file mode 100644
index 0000000..9a7fad2
--- /dev/null
+++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentileMetricsTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.metrics;
+
+import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author wusheng
+ */
+public class PercentileMetricsTest {
+ private int precision = 10;//ms
+
+ @Test
+ public void percentileTest() {
+ PercentileMetricsTest.PercentileMetricsMocker metricsMocker = new PercentileMetricsTest.PercentileMetricsMocker();
+
+ metricsMocker.combine(110, precision);
+ metricsMocker.combine(90, precision);
+ metricsMocker.combine(95, precision);
+ metricsMocker.combine(99, precision);
+ metricsMocker.combine(50, precision);
+ metricsMocker.combine(50, precision);
+ metricsMocker.combine(50, precision);
+ metricsMocker.combine(50, precision);
+ metricsMocker.combine(50, precision);
+ metricsMocker.combine(75, precision);
+ metricsMocker.combine(75, precision);
+
+ metricsMocker.calculate();
+
+ Assert.assertArrayEquals(new int[] {70, 90, 90, 90, 110}, metricsMocker.getValues());
+
+ for (int value : metricsMocker.getValues()) {
+ System.out.println(value);
+ }
+ }
+
+ public class PercentileMetricsMocker extends PercentileMetrics {
+
+ @Override public String id() {
+ return null;
+ }
+
+ @Override public Metrics toHour() {
+ return null;
+ }
+
+ @Override public Metrics toDay() {
+ return null;
+ }
+
+ @Override public Metrics toMonth() {
+ return null;
+ }
+
+ @Override public int remoteHashCode() {
+ return 0;
+ }
+
+ @Override public void deserialize(RemoteData remoteData) {
+
+ }
+
+ @Override public RemoteData.Builder serialize() {
+ return null;
+ }
+ }
+}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
index 0c2dfa1..90dfc1c 160000
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
@@ -1 +1 @@
-Subproject commit 0c2dfa18862596ed6790e2db0245b8f5af64e156
+Subproject commit 90dfc1c7ddc34e0c6f0291ffe3d96cd205d88c05