From da773973be0edf13c1ec198c605689d083e45978 Mon Sep 17 00:00:00 2001 From: Alan Lau Date: Mon, 6 May 2019 14:26:15 +0800 Subject: [PATCH 01/24] init need not return anything. also this function not used by other places. (#2597) --- .../apm/agent/core/plugin/loader/AgentClassLoader.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/loader/AgentClassLoader.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/loader/AgentClassLoader.java index 42c209fe5dfb..98690569fd6d 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/loader/AgentClassLoader.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/loader/AgentClassLoader.java @@ -89,10 +89,9 @@ public static AgentClassLoader getDefault() { /** * Init the default * - * @return * @throws AgentPackageNotFoundException */ - public static AgentClassLoader initDefaultLoader() throws AgentPackageNotFoundException { + public static void initDefaultLoader() throws AgentPackageNotFoundException { if (DEFAULT_LOADER == null) { synchronized (AgentClassLoader.class) { if (DEFAULT_LOADER == null) { @@ -100,7 +99,6 @@ public static AgentClassLoader initDefaultLoader() throws AgentPackageNotFoundEx } } } - return getDefault(); } public AgentClassLoader(ClassLoader parent) throws AgentPackageNotFoundException { From e6ebf62a1fa8a508fe88e17a1339be53cb47f94d Mon Sep 17 00:00:00 2001 From: Alan Lau Date: Mon, 6 May 2019 15:17:20 +0800 Subject: [PATCH 02/24] Add catch clause more details. (#2601) * Add catch clause more details. * Update SkyWalkingAgent.java --- .../org/apache/skywalking/apm/agent/SkyWalkingAgent.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java b/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java index 033b831bac92..6ef21ec9d174 100644 --- a/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java +++ b/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java @@ -27,8 +27,10 @@ import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatchers; import net.bytebuddy.utility.JavaModule; +import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException; import org.apache.skywalking.apm.agent.core.boot.ServiceManager; import org.apache.skywalking.apm.agent.core.conf.Config; +import org.apache.skywalking.apm.agent.core.conf.ConfigNotFoundException; import org.apache.skywalking.apm.agent.core.conf.SnifferConfigInitializer; import org.apache.skywalking.apm.agent.core.logging.api.ILog; import org.apache.skywalking.apm.agent.core.logging.api.LogManager; @@ -61,6 +63,12 @@ public static void premain(String agentArgs, Instrumentation instrumentation) th pluginFinder = new PluginFinder(new PluginBootstrap().loadPlugins()); + } catch (ConfigNotFoundException ce) { + logger.error(ce, "Skywalking agent could not find config. Shutting down."); + return; + } catch (AgentPackageNotFoundException ape) { + logger.error(ape, "Locate agent.jar failure. Shutting down."); + return; } catch (Exception e) { logger.error(e, "Skywalking agent initialized failure. Shutting down."); return; From b97399670924025b2553077564088bf481e4699c Mon Sep 17 00:00:00 2001 From: zxbu <32785355+zxbu@users.noreply.github.com> Date: Mon, 6 May 2019 17:46:58 +0800 Subject: [PATCH 03/24] Customizing the management endpoint paths (#2598) --- apm-webapp/src/main/resources/application.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apm-webapp/src/main/resources/application.yml b/apm-webapp/src/main/resources/application.yml index 1169abd0aa5f..946f819d7d4e 100644 --- a/apm-webapp/src/main/resources/application.yml +++ b/apm-webapp/src/main/resources/application.yml @@ -44,3 +44,6 @@ spring: mvc: throw-exception-if-no-handler-found: true +management: + # Customizing the management endpoint paths + context-path: /manage From b1b11e7295fb1091d37724e3e380cacc8aa2cb3d Mon Sep 17 00:00:00 2001 From: Lemon Date: Mon, 6 May 2019 22:57:00 +0800 Subject: [PATCH 04/24] Add appveyor config (#2609) --- appveyor.yml | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000000..dfe72da43b9d --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,60 @@ +# 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. + +version: '{build}' + +os: Visual Studio 2017 + +environment: + BUILDING_ON_PLATFORM: win + BuildEnvironment: appveyor + JAVA_HOME: C:\Program Files\Java\jdk1.8.0 + +skip_commits: + files: + - LICENSE + - NOTICE + - HEADER + - docs/* + - CHANGES.md + - CODE_OF_CONDUCT.md + - CONTRIBUTING.md + - README.md + - .travis.yml + - Jenkinsfile + # - appveyor.yml + +branches: + only: + - master + +install: +- ps: $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") +- java -version +- git submodule init +- git submodule update + +build_script: +- mvnw.cmd package -Dmaven.test.skip=true --quiet + +# after_build: +# - mvnw.cmd javadoc:javadoc -Dmaven.test.skip=true + +# test_script: +# - mvnw.cmd test + +cache: + - C:\Users\appveyor\.m2 \ No newline at end of file From 12f9991eef948aafea73a83abfad3c43db73f4bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=9F=20Wu=20Sheng?= Date: Tue, 7 May 2019 07:27:41 +0800 Subject: [PATCH 05/24] Add documents for timezone and ttl (#2607) --- docs/en/setup/README.md | 2 +- docs/en/setup/backend/backend-setup.md | 15 +++++++++++++++ docs/en/setup/backend/ttl.md | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 docs/en/setup/backend/ttl.md diff --git a/docs/en/setup/README.md b/docs/en/setup/README.md index 3d21c0cd0ecc..d07b753e4d7b 100644 --- a/docs/en/setup/README.md +++ b/docs/en/setup/README.md @@ -2,7 +2,7 @@ Setup based on which kind of probes are you going to use. If you don't understand, please read [Concepts and Designs](../concepts-and-designs/README.md) first. -**Important: Please comfirm the system time on the monitored servers are same as the time on the OAP servers.** +**Important: Please choose the timezone on UI, make it matches the timezone of your OAP backend servers.** ## Download official releases diff --git a/docs/en/setup/backend/backend-setup.md b/docs/en/setup/backend/backend-setup.md index fe42829be752..341950e0aefd 100644 --- a/docs/en/setup/backend/backend-setup.md +++ b/docs/en/setup/backend/backend-setup.md @@ -79,7 +79,22 @@ rules targeting the analysis oal metric objects. scale and support high payload, you may need this. 1. [Metric exporter](metric-exporter.md). Use metric data exporter to forward metric data to 3rd party system. +1. [Time To Live (TTL)](ttl.md). Metric and trace are time series data, they would be saved forever, you could +set the expired time for each dimension. ## Telemetry for backend OAP backend cluster itself underlying is a distributed streaming process system. For helping the Ops team, we provide the telemetry for OAP backend itself. Follow [document](backend-telemetry.md) to use it. + + +## FAQs +#### When and why do we need to set Timezone? +SkyWalking provides downsampling time series metric features. +Query and storage at each time dimension(minute, hour, day, month metric indexes) +related to timezone when doing time format. + +For example, metric time will be formatted like YYYYMMDDHHmm in minute dimension metric, +which format process is timezone related. + +In default, SkyWalking OAP backend choose the OS default timezone. +If you want to override it, please follow Java and OS documents to do so. \ No newline at end of file diff --git a/docs/en/setup/backend/ttl.md b/docs/en/setup/backend/ttl.md new file mode 100644 index 000000000000..f82b64119cbf --- /dev/null +++ b/docs/en/setup/backend/ttl.md @@ -0,0 +1,19 @@ +# TTL +In SkyWalking, there are two types of observability data, besides metadata. +1. Record, including trace and alarm. Maybe log in the future. +1. Metric, including such as p99/p95/p90/p75/p50, heatmap, success rate, cpm(rpm) etc. +Metric is separated in minute/hour/day/month dimensions in storage, different indexes or tables. + +You have following settings for different types. +```yaml + # Set a timeout on metric data. After the timeout has expired, the metric data will automatically be deleted. + recordDataTTL: ${SW_CORE_RECORD_DATA_TTL:90} # Unit is minute + minuteMetricsDataTTL: ${SW_CORE_MINUTE_METRIC_DATA_TTL:90} # Unit is minute + hourMetricsDataTTL: ${SW_CORE_HOUR_METRIC_DATA_TTL:36} # Unit is hour + dayMetricsDataTTL: ${SW_CORE_DAY_METRIC_DATA_TTL:45} # Unit is day + monthMetricsDataTTL: ${SW_CORE_MONTH_METRIC_DATA_TTL:18} # Unit is month +``` + +- `recordDataTTL` affects **Record** data. +- `minuteMetricsDataTTL`, `hourMetricsDataTTL`, `dayMetricsDataTTL` and `monthMetricsDataTTL` affects +metric data in minute/hour/day/month dimensions. \ No newline at end of file From ea347b85355741ba54975be4bb65e2db93c7f2f7 Mon Sep 17 00:00:00 2001 From: Jared Tan Date: Tue, 7 May 2019 07:56:46 +0800 Subject: [PATCH 06/24] fix webflux cast exception. (#2608) * fix * revert status interceptor. --- .../v5/define/HttpServerOperations20xInstrumentation.java | 3 +-- .../v5/define/HttpServerOperations21xInstrumentation.java | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations20xInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations20xInstrumentation.java index bd26e37e5fdd..fa70cd386520 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations20xInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations20xInstrumentation.java @@ -25,7 +25,6 @@ import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; -import static net.bytebuddy.matcher.ElementMatchers.takesArguments; import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; @@ -48,7 +47,7 @@ public class HttpServerOperations20xInstrumentation extends ClassInstanceMethods return new InstanceMethodsInterceptPoint[] { new InstanceMethodsInterceptPoint() { @Override public ElementMatcher getMethodsMatcher() { - return named("status").and(takesArguments(1)); + return named("status").and(takesArgumentWithType(0, "io.netty.handler.codec.http.HttpResponseStatus")); } @Override public String getMethodsInterceptor() { diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations21xInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations21xInstrumentation.java index 3d19bbe93c4a..83efc53b400e 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations21xInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations21xInstrumentation.java @@ -25,7 +25,6 @@ import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; -import static net.bytebuddy.matcher.ElementMatchers.takesArguments; import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; @@ -48,7 +47,7 @@ public class HttpServerOperations21xInstrumentation extends ClassInstanceMethods return new InstanceMethodsInterceptPoint[] { new InstanceMethodsInterceptPoint() { @Override public ElementMatcher getMethodsMatcher() { - return named("status").and(takesArguments(1)); + return named("status").and(takesArgumentWithType(0, "io.netty.handler.codec.http.HttpResponseStatus")); } @Override public String getMethodsInterceptor() { @@ -104,4 +103,4 @@ public class HttpServerOperations21xInstrumentation extends ClassInstanceMethods @Override protected ClassMatch enhanceClass() { return byName("reactor.netty.http.server.HttpServerOperations"); } -} \ No newline at end of file +} From 4e710857a08f90792b75ec5fc5d4d1696f2bbcc1 Mon Sep 17 00:00:00 2001 From: neatlife Date: Tue, 7 May 2019 08:43:15 +0800 Subject: [PATCH 07/24] fix docker elasticsearch and oap host (#2574) --- docker/config/application.yml | 2 +- docker/docker-compose.yml | 2 +- docker/ui/docker-entrypoint.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/config/application.yml b/docker/config/application.yml index d1c909092371..7865829d1c48 100644 --- a/docker/config/application.yml +++ b/docker/config/application.yml @@ -57,7 +57,7 @@ core: storage: elasticsearch: nameSpace: ${SW_NAMESPACE:""} - clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200} + clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:elasticsearch:9200} user: ${SW_ES_USER:""} password: ${SW_ES_PASSWORD:""} indexShardsNumber: ${SW_STORAGE_ES_INDEX_SHARDS_NUMBER:2} diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 4c6da78377be..88b40f7374e9 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -49,4 +49,4 @@ services: ports: - 8080:8080 environment: - collector.ribbon.listOfServers: oap:12800 \ No newline at end of file + collectorListOfServers: oap:12800 diff --git a/docker/ui/docker-entrypoint.sh b/docker/ui/docker-entrypoint.sh index 37fc457e2001..881368f4ada7 100755 --- a/docker/ui/docker-entrypoint.sh +++ b/docker/ui/docker-entrypoint.sh @@ -18,4 +18,4 @@ set -ex -exec java -XX:+PrintFlagsFinal -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -jar webapp/skywalking-webapp.jar --logging.config=webapp/logback.xml "$@" +exec java -XX:+PrintFlagsFinal -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -jar webapp/skywalking-webapp.jar --logging.config=webapp/logback.xml --collector.ribbon.listOfServers=${collectorListOfServers} "$@" From 16103c673822689a7c5afb7c85d7f0ef7acde3bb Mon Sep 17 00:00:00 2001 From: Ming Deng Date: Tue, 7 May 2019 10:32:43 +0800 Subject: [PATCH 08/24] Using PowerMockito to mock System.getent; (#2593) * Using PowerMockito rathen then using reflection to mock System.getent; * Run Test * Trigger CI only on the master --- .../apm/commons/datacarrier/EnvUtilTest.java | 44 +++++++------------ appveyor.yml | 4 +- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/EnvUtilTest.java b/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/EnvUtilTest.java index b95e86215d36..640b23dd177b 100644 --- a/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/EnvUtilTest.java +++ b/apm-commons/apm-datacarrier/src/test/java/org/apache/skywalking/apm/commons/datacarrier/EnvUtilTest.java @@ -18,37 +18,33 @@ package org.apache.skywalking.apm.commons.datacarrier; -import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; -import java.lang.reflect.Field; -import java.util.Map; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; /** * @author dengming * 2019-04-20 */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(EnvUtil.class) public class EnvUtilTest { - private Map writableEnv; @Before public void before() { - try { - Map env = System.getenv(); - Class cl = env.getClass(); - Field field = cl.getDeclaredField("m"); - field.setAccessible(true); - writableEnv = (Map) field.get(env); - writableEnv.put("myInt", "123"); - writableEnv.put("wrongInt", "wrong123"); - writableEnv.put("myLong", "12345678901234567"); - writableEnv.put("wrongLong", "wrong123"); - } catch (Exception e) { - throw new IllegalStateException("Failed to set environment variable", e); - } + + PowerMockito.mockStatic(System.class); + + when(System.getenv("myInt")).thenReturn("123"); + when(System.getenv("wrongInt")).thenReturn("wrong123"); + when(System.getenv("myLong")).thenReturn("12345678901234567"); + when(System.getenv("wrongLong")).thenReturn("wrong123"); } @Test @@ -63,14 +59,4 @@ public void getLong() { assertEquals(987654321987654321L, EnvUtil.getLong("wrongLong", 987654321987654321L)); } - @After - public void after() { - writableEnv.remove("myInt"); - writableEnv.remove("wrongInt"); - writableEnv.remove("myLong"); - writableEnv.remove("wrongLong"); - assertNull(System.getenv("myInt")); - } - - } \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index dfe72da43b9d..f9c2967bf330 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -53,8 +53,8 @@ build_script: # after_build: # - mvnw.cmd javadoc:javadoc -Dmaven.test.skip=true -# test_script: -# - mvnw.cmd test +test_script: +- mvnw.cmd test cache: - C:\Users\appveyor\.m2 \ No newline at end of file From 4de1fe58167d49b1b24f6bcf8deb1e6278135c5d Mon Sep 17 00:00:00 2001 From: Alan Lau Date: Tue, 7 May 2019 11:03:42 +0800 Subject: [PATCH 09/24] Remove the unused class loader. (#2612) --- .../apache/skywalking/apm/agent/core/plugin/PluginFinder.java | 3 +-- .../java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java index 99e49a50ce23..5beed29a4977 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/plugin/PluginFinder.java @@ -67,8 +67,7 @@ public PluginFinder(List plugins) { } } - public List find(TypeDescription typeDescription, - ClassLoader classLoader) { + public List find(TypeDescription typeDescription) { List matchedPlugins = new LinkedList(); String typeName = typeDescription.getTypeName(); if (nameMatchDefine.containsKey(typeName)) { diff --git a/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java b/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java index 6ef21ec9d174..516c1cdf2daa 100644 --- a/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java +++ b/apm-sniffer/apm-agent/src/main/java/org/apache/skywalking/apm/agent/SkyWalkingAgent.java @@ -116,7 +116,7 @@ private static class Transformer implements AgentBuilder.Transformer { @Override public DynamicType.Builder transform(DynamicType.Builder builder, TypeDescription typeDescription, ClassLoader classLoader, JavaModule module) { - List pluginDefines = pluginFinder.find(typeDescription, classLoader); + List pluginDefines = pluginFinder.find(typeDescription); if (pluginDefines.size() > 0) { DynamicType.Builder newBuilder = builder; EnhanceContext context = new EnhanceContext(); From 1f39b199377a325a2368bdf3bd29de8e38c17d2a Mon Sep 17 00:00:00 2001 From: SataQiu Date: Tue, 7 May 2019 11:40:35 +0800 Subject: [PATCH 10/24] fix some spelling mistakes (#2615) --- .../skywalking/apm/commons/datacarrier/buffer/Channels.java | 2 +- .../jdbc/mysql/v5/define/Mysql50ConnectionInstrumentation.java | 2 +- docs/powered-by.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java index e0f3026fbe40..af8cefcd30f1 100644 --- a/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java +++ b/apm-commons/apm-datacarrier/src/main/java/org/apache/skywalking/apm/commons/datacarrier/buffer/Channels.java @@ -22,7 +22,7 @@ import org.apache.skywalking.apm.commons.datacarrier.partition.IDataPartitioner; /** - * Channels of Buffer It contais all buffer data which belongs to this channel. It supports several strategy when buffer + * Channels of Buffer It contains all buffer data which belongs to this channel. It supports several strategy when buffer * is full. The Default is BLOCKING

Created by wusheng on 2016/10/25. */ public class Channels { diff --git a/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v5/define/Mysql50ConnectionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v5/define/Mysql50ConnectionInstrumentation.java index 147ae735c008..e78cfe9b846f 100644 --- a/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v5/define/Mysql50ConnectionInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v5/define/Mysql50ConnectionInstrumentation.java @@ -24,7 +24,7 @@ import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** - * {@link Mysql50ConnectionInstrumentation} interceptor the com.mysql.jdbc.Connection class in the 5.0.x verison + * {@link Mysql50ConnectionInstrumentation} interceptor the com.mysql.jdbc.Connection class in the 5.0.x version * of mysql driver jar. * * @author zhangxin diff --git a/docs/powered-by.md b/docs/powered-by.md index b9115b962d07..d831aec55cf9 100644 --- a/docs/powered-by.md +++ b/docs/powered-by.md @@ -94,7 +94,7 @@ Integrated in the microservices architecture support platform. Use SkyWalking and [SkyAPM .net agent](https://github.com/SkyAPM/SkyAPM-dotnet) in the CMBChina Mall project. ## ke.com -Deploy SkyWalking in production enviroments. +Deploy SkyWalking in production environments. - Three CentOs Machines(32 CPUs, 64G RAM, 1.3T Disk) for Collector Server - Three ElasticSearch(Version 6.4.2, 40 CPUs, 96G RAM, 7T Disk) Nodes for Storage From 8f731594151ef076d0f2aa8fa2fdd3455aa2f3a3 Mon Sep 17 00:00:00 2001 From: Changyu Date: Tue, 7 May 2019 12:38:58 +0800 Subject: [PATCH 11/24] sync-ui (#2618) --- skywalking-ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skywalking-ui b/skywalking-ui index b12a5499f038..ef3570fb126c 160000 --- a/skywalking-ui +++ b/skywalking-ui @@ -1 +1 @@ -Subproject commit b12a5499f0383a1285b485070e11289052692ac9 +Subproject commit ef3570fb126c534d0f15c3a241944fa46ee594b7 From ba73d3420b5e3cd78769957729a2c31e31777a4c Mon Sep 17 00:00:00 2001 From: coki230 Date: Tue, 7 May 2019 19:25:57 +0800 Subject: [PATCH 12/24] fix doc_Trace Data Protocol v2_error #2620 (#2625) fix doc_Trace Data Protocol v2_error #2620 --- docs/en/protocols/Trace-Data-Protocol-v2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/protocols/Trace-Data-Protocol-v2.md b/docs/en/protocols/Trace-Data-Protocol-v2.md index b574c54d26e3..c25f8a12d823 100644 --- a/docs/en/protocols/Trace-Data-Protocol-v2.md +++ b/docs/en/protocols/Trace-Data-Protocol-v2.md @@ -24,7 +24,7 @@ Because batch is supported, even for most language agent/SDK, no scenario to do and `UUID` in response, and match with your expected value. ### Step 2. Send trace and metric -After you have trace id and trace instance id, you could send traces and metric. Now we +After you have service id and service instance id, you could send traces and metric. Now we have 1. `TraceSegmentReportService#collect` for skywalking native trace format 1. `JVMMetricReportService#collect` for skywalking native jvm format From 19d9c56f279f6485f94c77f7cd7590bc414bc205 Mon Sep 17 00:00:00 2001 From: SataQiu Date: Tue, 7 May 2019 21:56:23 +0800 Subject: [PATCH 13/24] Clean up unnecessary times(1) for test verify (#2619) * clean up unnecessary times(1) for test verify * format code * fix checkstyle --- .../logging/core/SystemOutWriterTest.java | 3 +- .../v4/HttpClientExecuteInterceptorTest.java | 9 +- .../v4/HttpAsyncClientInterceptorTest.java | 2 +- .../plugin/jdbc/SWCallableStatementTest.java | 308 +++++++++--------- .../apm/plugin/jdbc/SWConnectionTest.java | 55 ++-- .../apm/plugin/jdbc/SWStatementTest.java | 59 ++-- .../plugin/jdbc/SwPreparedStatementTest.java | 212 ++++++------ ...ctorWithHostAndPortArgInterceptorTest.java | 3 +- ...WithListHostAndPortArgInterceptorTest.java | 3 +- ...ructorWithShardInfoArgInterceptorTest.java | 3 +- ...nstructorWithStringArgInterceptorTest.java | 5 +- ...sConstructorWithUriArgInterceptorTest.java | 3 +- .../motan/MotanConsumerInterceptorTest.java | 5 +- .../ConnectionImplCreateInterceptorTest.java | 3 +- .../ConnectionImplCreateInterceptorTest.java | 3 +- ...reateCallableStatementInterceptorTest.java | 2 +- ...reatePreparedStatementInterceptorTest.java | 2 +- .../mysql/CreateStatementInterceptorTest.java | 2 +- .../nutz/http/sync/SenderInterceptorTest.java | 5 +- .../v3/MessageSendInterceptorTest.java | 7 +- .../v4/MessageSendInterceptorTest.java | 7 +- ...oducerOperationHandlerInterceptorTest.java | 3 +- ...TransportClientHandlerInterceptorTest.java | 3 +- ...oducerOperationHandlerInterceptorTest.java | 3 +- ...TransportClientHandlerInterceptorTest.java | 3 +- ...etSocketAddressListArgInterceptorTest.java | 3 +- ...structorWithComplexArgInterceptorTest.java | 3 +- ...tructorWithHostPortArgInterceptorTest.java | 3 +- ...thInetSocketAddressArgInterceptorTest.java | 3 +- ...etSocketAddressListArgInterceptorTest.java | 3 +- 30 files changed, 352 insertions(+), 376 deletions(-) diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/logging/core/SystemOutWriterTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/logging/core/SystemOutWriterTest.java index ab45c43f79ac..3c154f7515a6 100644 --- a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/logging/core/SystemOutWriterTest.java +++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/logging/core/SystemOutWriterTest.java @@ -27,7 +27,6 @@ import java.io.PrintStream; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.times; /** * Created by wusheng on 2017/2/28. @@ -47,7 +46,7 @@ public void testWrite() { SystemOutWriter.INSTANCE.write("hello"); - Mockito.verify(mockStream, times(1)).println(anyString()); + Mockito.verify(mockStream).println(anyString()); } @AfterClass diff --git a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java index 89fbf30bd34f..ecfe4aadf325 100644 --- a/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java @@ -54,7 +54,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -128,7 +127,7 @@ public void testHttpClient() throws Throwable { List spans = SegmentHelper.getSpans(traceSegment); assertHttpSpan(spans.get(0)); - verify(request, times(1)).setHeader(anyString(), anyString()); + verify(request).setHeader(anyString(), anyString()); } @Test @@ -149,7 +148,7 @@ public void testStatusCodeNotEquals200() throws Throwable { assertHttpSpan(spans.get(0)); assertThat(SpanHelper.getErrorOccurred(spans.get(0)), is(true)); - verify(request, times(1)).setHeader(anyString(), anyString()); + verify(request).setHeader(anyString(), anyString()); } @Test @@ -167,7 +166,7 @@ public void testHttpClientWithException() throws Throwable { assertHttpSpan(span); assertThat(SpanHelper.getErrorOccurred(span), is(true)); assertHttpSpanErrorLog(SpanHelper.getLogs(span)); - verify(request, times(1)).setHeader(anyString(), anyString()); + verify(request).setHeader(anyString(), anyString()); } @@ -197,7 +196,7 @@ public String getUri() { List spans = SegmentHelper.getSpans(traceSegment); assertHttpSpan(spans.get(0)); - verify(request, times(1)).setHeader(anyString(), anyString()); + verify(request).setHeader(anyString(), anyString()); } private void assertHttpSpanErrorLog(List logs) { diff --git a/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/HttpAsyncClientInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/HttpAsyncClientInterceptorTest.java index a046b1600ac1..e5ff8bc305e9 100644 --- a/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/HttpAsyncClientInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/httpasyncclient-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/httpasyncclient/v4/HttpAsyncClientInterceptorTest.java @@ -194,7 +194,7 @@ public void testSuccess() throws Throwable { List spans = SegmentHelper.getSpans(findNeedSegemnt()); assertHttpSpan(spans.get(0)); - verify(requestWrapper, times(1)).setHeader(anyString(), anyString()); + verify(requestWrapper).setHeader(anyString(), anyString()); } diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java index 12fe63168a73..7bcae2ab8f06 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java @@ -301,107 +301,107 @@ public void testSetParam() throws SQLException, MalformedURLException { ResultSet resultSet = callableStatement.executeQuery(); callableStatement.close(); - verify(mysqlCallableStatement, times(1)).clearParameters(); - verify(mysqlCallableStatement, times(1)).executeQuery(); - verify(mysqlCallableStatement, times(1)).close(); - verify(mysqlCallableStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class)); - verify(mysqlCallableStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class), anyInt()); - verify(mysqlCallableStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class), anyLong()); - verify(mysqlCallableStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class)); - verify(mysqlCallableStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class), anyInt()); - verify(mysqlCallableStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class), anyLong()); - verify(mysqlCallableStatement, times(1)).setShort(anyInt(), anyShort()); - verify(mysqlCallableStatement, times(1)).setInt(anyInt(), anyInt()); - verify(mysqlCallableStatement, times(1)).setString(anyInt(), anyString()); - verify(mysqlCallableStatement, times(1)).setBoolean(anyInt(), anyBoolean()); - verify(mysqlCallableStatement, times(1)).setLong(anyInt(), anyLong()); - verify(mysqlCallableStatement, times(1)).setDouble(anyInt(), anyDouble()); - verify(mysqlCallableStatement, times(1)).setFloat(anyInt(), anyFloat()); - verify(mysqlCallableStatement, times(1)).setByte(anyInt(), anyByte()); - verify(mysqlCallableStatement, times(1)).setBytes(14, bytesParam); - verify(mysqlCallableStatement, times(1)).setDate(anyInt(), any(Date.class)); - verify(mysqlCallableStatement, times(1)).setNull(anyInt(), anyInt()); - verify(mysqlCallableStatement, times(1)).setNull(anyInt(), anyInt(), anyString()); - verify(mysqlCallableStatement, times(1)).setBigDecimal(anyInt(), any(BigDecimal.class)); - verify(mysqlCallableStatement, times(1)).setBlob(anyInt(), any(InputStream.class)); - verify(mysqlCallableStatement, times(1)).setBlob(anyInt(), any(InputStream.class), anyLong()); - verify(mysqlCallableStatement, times(1)).setClob(anyInt(), any(Clob.class)); - verify(mysqlCallableStatement, times(1)).setClob(anyInt(), any(Reader.class)); - verify(mysqlCallableStatement, times(1)).setClob(anyInt(), any(Reader.class), anyInt()); - verify(mysqlCallableStatement, times(1)).setNString(anyInt(), anyString()); - verify(mysqlCallableStatement, times(1)).setNCharacterStream(anyInt(), any(Reader.class)); - verify(mysqlCallableStatement, times(1)).setNCharacterStream(anyInt(), any(Reader.class), anyInt()); - verify(mysqlCallableStatement, times(1)).setNClob(27, nClob); - verify(mysqlCallableStatement, times(1)).setNClob(28, reader, 1); - verify(mysqlCallableStatement, times(1)).setObject(anyInt(), Matchers.anyObject()); - verify(mysqlCallableStatement, times(1)).setObject(anyInt(), Matchers.anyObject(), anyInt()); - verify(mysqlCallableStatement, times(1)).setObject(anyInt(), Matchers.anyObject(), anyInt(), anyInt()); - verify(mysqlCallableStatement, times(1)).setRef(anyInt(), any(Ref.class)); - verify(mysqlCallableStatement, times(1)).setRowId(anyInt(), any(RowId.class)); - verify(mysqlCallableStatement, times(1)).setSQLXML(anyInt(), any(SQLXML.class)); - verify(mysqlCallableStatement, times(1)).setTime(anyInt(), any(Time.class)); - verify(mysqlCallableStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class)); - verify(mysqlCallableStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class)); - verify(mysqlCallableStatement, times(1)).setURL(anyInt(), any(URL.class)); - verify(mysqlCallableStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class)); - verify(mysqlCallableStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class), anyInt()); - verify(mysqlCallableStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class), anyLong()); - verify(mysqlCallableStatement, times(1)).setNClob(42, reader); - verify(mysqlCallableStatement, times(1)).setTime(anyInt(), any(Time.class), any(Calendar.class)); - verify(mysqlCallableStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class)); - verify(mysqlCallableStatement, times(1)).setArray(anyInt(), any(Array.class)); - verify(mysqlCallableStatement, times(1)).setBlob(anyInt(), any(Blob.class)); - verify(mysqlCallableStatement, times(1)).setDate(anyInt(), any(Date.class), any(Calendar.class)); - - verify(mysqlCallableStatement, times(1)).clearParameters(); - verify(mysqlCallableStatement, times(1)).executeQuery(); - verify(mysqlCallableStatement, times(1)).close(); - verify(mysqlCallableStatement, times(1)).setAsciiStream(anyString(), any(InputStream.class)); - verify(mysqlCallableStatement, times(1)).setAsciiStream(anyString(), any(InputStream.class), anyInt()); - verify(mysqlCallableStatement, times(1)).setAsciiStream(anyString(), any(InputStream.class), anyLong()); - verify(mysqlCallableStatement, times(1)).setCharacterStream(anyString(), any(Reader.class)); - verify(mysqlCallableStatement, times(1)).setCharacterStream(anyString(), any(Reader.class), anyInt()); - verify(mysqlCallableStatement, times(1)).setCharacterStream(anyString(), any(Reader.class), anyLong()); - verify(mysqlCallableStatement, times(1)).setShort(anyString(), anyShort()); - verify(mysqlCallableStatement, times(1)).setInt(anyString(), anyInt()); - verify(mysqlCallableStatement, times(1)).setString(anyString(), anyString()); - verify(mysqlCallableStatement, times(1)).setBoolean(anyString(), anyBoolean()); - verify(mysqlCallableStatement, times(1)).setLong(anyString(), anyLong()); - verify(mysqlCallableStatement, times(1)).setDouble(anyString(), anyDouble()); - verify(mysqlCallableStatement, times(1)).setFloat(anyString(), anyFloat()); - verify(mysqlCallableStatement, times(1)).setByte(anyString(), anyByte()); - verify(mysqlCallableStatement, times(1)).setBytes(14, bytesParam); - verify(mysqlCallableStatement, times(1)).setDate(anyString(), any(Date.class)); - verify(mysqlCallableStatement, times(1)).setNull(anyString(), anyInt()); - verify(mysqlCallableStatement, times(1)).setNull(anyString(), anyInt(), anyString()); - verify(mysqlCallableStatement, times(1)).setBigDecimal(anyString(), any(BigDecimal.class)); - verify(mysqlCallableStatement, times(1)).setBlob(anyString(), any(InputStream.class)); - verify(mysqlCallableStatement, times(1)).setBlob(anyString(), any(InputStream.class), anyLong()); - verify(mysqlCallableStatement, times(1)).setClob(anyString(), any(Clob.class)); - verify(mysqlCallableStatement, times(1)).setClob(anyString(), any(Reader.class)); - verify(mysqlCallableStatement, times(1)).setClob(anyString(), any(Reader.class), anyInt()); - verify(mysqlCallableStatement, times(1)).setNString(anyString(), anyString()); - verify(mysqlCallableStatement, times(1)).setNCharacterStream(anyString(), any(Reader.class)); - verify(mysqlCallableStatement, times(1)).setNCharacterStream(anyString(), any(Reader.class), anyInt()); - verify(mysqlCallableStatement, times(1)).setNClob(27, nClob); - verify(mysqlCallableStatement, times(1)).setNClob(28, reader, 1); - verify(mysqlCallableStatement, times(1)).setObject(anyString(), Matchers.anyObject()); - verify(mysqlCallableStatement, times(1)).setObject(anyString(), Matchers.anyObject(), anyInt()); - verify(mysqlCallableStatement, times(1)).setObject(anyString(), Matchers.anyObject(), anyInt(), anyInt()); - verify(mysqlCallableStatement, times(1)).setRowId(anyString(), any(RowId.class)); - verify(mysqlCallableStatement, times(1)).setSQLXML(anyString(), any(SQLXML.class)); - verify(mysqlCallableStatement, times(1)).setTime(anyString(), any(Time.class)); - verify(mysqlCallableStatement, times(1)).setTimestamp(anyString(), any(Timestamp.class)); - verify(mysqlCallableStatement, times(1)).setTimestamp(anyString(), any(Timestamp.class), any(Calendar.class)); - verify(mysqlCallableStatement, times(1)).setURL(anyString(), any(URL.class)); - verify(mysqlCallableStatement, times(1)).setBinaryStream(anyString(), any(InputStream.class)); - verify(mysqlCallableStatement, times(1)).setBinaryStream(anyString(), any(InputStream.class), anyInt()); - verify(mysqlCallableStatement, times(1)).setBinaryStream(anyString(), any(InputStream.class), anyLong()); - verify(mysqlCallableStatement, times(1)).setNClob(42, reader); - verify(mysqlCallableStatement, times(1)).setTime(anyString(), any(Time.class), any(Calendar.class)); - verify(mysqlCallableStatement, times(1)).setTimestamp(anyString(), any(Timestamp.class), any(Calendar.class)); - verify(mysqlCallableStatement, times(1)).setBlob(anyString(), any(Blob.class)); - verify(mysqlCallableStatement, times(1)).setDate(anyString(), any(Date.class), any(Calendar.class)); + verify(mysqlCallableStatement).clearParameters(); + verify(mysqlCallableStatement).executeQuery(); + verify(mysqlCallableStatement).close(); + verify(mysqlCallableStatement).setAsciiStream(anyInt(), any(InputStream.class)); + verify(mysqlCallableStatement).setAsciiStream(anyInt(), any(InputStream.class), anyInt()); + verify(mysqlCallableStatement).setAsciiStream(anyInt(), any(InputStream.class), anyLong()); + verify(mysqlCallableStatement).setCharacterStream(anyInt(), any(Reader.class)); + verify(mysqlCallableStatement).setCharacterStream(anyInt(), any(Reader.class), anyInt()); + verify(mysqlCallableStatement).setCharacterStream(anyInt(), any(Reader.class), anyLong()); + verify(mysqlCallableStatement).setShort(anyInt(), anyShort()); + verify(mysqlCallableStatement).setInt(anyInt(), anyInt()); + verify(mysqlCallableStatement).setString(anyInt(), anyString()); + verify(mysqlCallableStatement).setBoolean(anyInt(), anyBoolean()); + verify(mysqlCallableStatement).setLong(anyInt(), anyLong()); + verify(mysqlCallableStatement).setDouble(anyInt(), anyDouble()); + verify(mysqlCallableStatement).setFloat(anyInt(), anyFloat()); + verify(mysqlCallableStatement).setByte(anyInt(), anyByte()); + verify(mysqlCallableStatement).setBytes(14, bytesParam); + verify(mysqlCallableStatement).setDate(anyInt(), any(Date.class)); + verify(mysqlCallableStatement).setNull(anyInt(), anyInt()); + verify(mysqlCallableStatement).setNull(anyInt(), anyInt(), anyString()); + verify(mysqlCallableStatement).setBigDecimal(anyInt(), any(BigDecimal.class)); + verify(mysqlCallableStatement).setBlob(anyInt(), any(InputStream.class)); + verify(mysqlCallableStatement).setBlob(anyInt(), any(InputStream.class), anyLong()); + verify(mysqlCallableStatement).setClob(anyInt(), any(Clob.class)); + verify(mysqlCallableStatement).setClob(anyInt(), any(Reader.class)); + verify(mysqlCallableStatement).setClob(anyInt(), any(Reader.class), anyInt()); + verify(mysqlCallableStatement).setNString(anyInt(), anyString()); + verify(mysqlCallableStatement).setNCharacterStream(anyInt(), any(Reader.class)); + verify(mysqlCallableStatement).setNCharacterStream(anyInt(), any(Reader.class), anyInt()); + verify(mysqlCallableStatement).setNClob(27, nClob); + verify(mysqlCallableStatement).setNClob(28, reader, 1); + verify(mysqlCallableStatement).setObject(anyInt(), Matchers.anyObject()); + verify(mysqlCallableStatement).setObject(anyInt(), Matchers.anyObject(), anyInt()); + verify(mysqlCallableStatement).setObject(anyInt(), Matchers.anyObject(), anyInt(), anyInt()); + verify(mysqlCallableStatement).setRef(anyInt(), any(Ref.class)); + verify(mysqlCallableStatement).setRowId(anyInt(), any(RowId.class)); + verify(mysqlCallableStatement).setSQLXML(anyInt(), any(SQLXML.class)); + verify(mysqlCallableStatement).setTime(anyInt(), any(Time.class)); + verify(mysqlCallableStatement).setTimestamp(anyInt(), any(Timestamp.class)); + verify(mysqlCallableStatement).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class)); + verify(mysqlCallableStatement).setURL(anyInt(), any(URL.class)); + verify(mysqlCallableStatement).setBinaryStream(anyInt(), any(InputStream.class)); + verify(mysqlCallableStatement).setBinaryStream(anyInt(), any(InputStream.class), anyInt()); + verify(mysqlCallableStatement).setBinaryStream(anyInt(), any(InputStream.class), anyLong()); + verify(mysqlCallableStatement).setNClob(42, reader); + verify(mysqlCallableStatement).setTime(anyInt(), any(Time.class), any(Calendar.class)); + verify(mysqlCallableStatement).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class)); + verify(mysqlCallableStatement).setArray(anyInt(), any(Array.class)); + verify(mysqlCallableStatement).setBlob(anyInt(), any(Blob.class)); + verify(mysqlCallableStatement).setDate(anyInt(), any(Date.class), any(Calendar.class)); + + verify(mysqlCallableStatement).clearParameters(); + verify(mysqlCallableStatement).executeQuery(); + verify(mysqlCallableStatement).close(); + verify(mysqlCallableStatement).setAsciiStream(anyString(), any(InputStream.class)); + verify(mysqlCallableStatement).setAsciiStream(anyString(), any(InputStream.class), anyInt()); + verify(mysqlCallableStatement).setAsciiStream(anyString(), any(InputStream.class), anyLong()); + verify(mysqlCallableStatement).setCharacterStream(anyString(), any(Reader.class)); + verify(mysqlCallableStatement).setCharacterStream(anyString(), any(Reader.class), anyInt()); + verify(mysqlCallableStatement).setCharacterStream(anyString(), any(Reader.class), anyLong()); + verify(mysqlCallableStatement).setShort(anyString(), anyShort()); + verify(mysqlCallableStatement).setInt(anyString(), anyInt()); + verify(mysqlCallableStatement).setString(anyString(), anyString()); + verify(mysqlCallableStatement).setBoolean(anyString(), anyBoolean()); + verify(mysqlCallableStatement).setLong(anyString(), anyLong()); + verify(mysqlCallableStatement).setDouble(anyString(), anyDouble()); + verify(mysqlCallableStatement).setFloat(anyString(), anyFloat()); + verify(mysqlCallableStatement).setByte(anyString(), anyByte()); + verify(mysqlCallableStatement).setBytes(14, bytesParam); + verify(mysqlCallableStatement).setDate(anyString(), any(Date.class)); + verify(mysqlCallableStatement).setNull(anyString(), anyInt()); + verify(mysqlCallableStatement).setNull(anyString(), anyInt(), anyString()); + verify(mysqlCallableStatement).setBigDecimal(anyString(), any(BigDecimal.class)); + verify(mysqlCallableStatement).setBlob(anyString(), any(InputStream.class)); + verify(mysqlCallableStatement).setBlob(anyString(), any(InputStream.class), anyLong()); + verify(mysqlCallableStatement).setClob(anyString(), any(Clob.class)); + verify(mysqlCallableStatement).setClob(anyString(), any(Reader.class)); + verify(mysqlCallableStatement).setClob(anyString(), any(Reader.class), anyInt()); + verify(mysqlCallableStatement).setNString(anyString(), anyString()); + verify(mysqlCallableStatement).setNCharacterStream(anyString(), any(Reader.class)); + verify(mysqlCallableStatement).setNCharacterStream(anyString(), any(Reader.class), anyInt()); + verify(mysqlCallableStatement).setNClob(27, nClob); + verify(mysqlCallableStatement).setNClob(28, reader, 1); + verify(mysqlCallableStatement).setObject(anyString(), Matchers.anyObject()); + verify(mysqlCallableStatement).setObject(anyString(), Matchers.anyObject(), anyInt()); + verify(mysqlCallableStatement).setObject(anyString(), Matchers.anyObject(), anyInt(), anyInt()); + verify(mysqlCallableStatement).setRowId(anyString(), any(RowId.class)); + verify(mysqlCallableStatement).setSQLXML(anyString(), any(SQLXML.class)); + verify(mysqlCallableStatement).setTime(anyString(), any(Time.class)); + verify(mysqlCallableStatement).setTimestamp(anyString(), any(Timestamp.class)); + verify(mysqlCallableStatement).setTimestamp(anyString(), any(Timestamp.class), any(Calendar.class)); + verify(mysqlCallableStatement).setURL(anyString(), any(URL.class)); + verify(mysqlCallableStatement).setBinaryStream(anyString(), any(InputStream.class)); + verify(mysqlCallableStatement).setBinaryStream(anyString(), any(InputStream.class), anyInt()); + verify(mysqlCallableStatement).setBinaryStream(anyString(), any(InputStream.class), anyLong()); + verify(mysqlCallableStatement).setNClob(42, reader); + verify(mysqlCallableStatement).setTime(anyString(), any(Time.class), any(Calendar.class)); + verify(mysqlCallableStatement).setTimestamp(anyString(), any(Timestamp.class), any(Calendar.class)); + verify(mysqlCallableStatement).setBlob(anyString(), any(Blob.class)); + verify(mysqlCallableStatement).setDate(anyString(), any(Date.class), any(Calendar.class)); } @Test @@ -441,32 +441,32 @@ public void testCallableStatementConfig() throws SQLException { callableStatement.getResultSet(); callableStatement.close(); - verify(mysqlCallableStatement, times(1)).getUpdateCount(); - verify(mysqlCallableStatement, times(1)).getMoreResults(); - verify(mysqlCallableStatement, times(1)).setFetchDirection(anyInt()); - verify(mysqlCallableStatement, times(1)).getFetchDirection(); - verify(mysqlCallableStatement, times(1)).getResultSetType(); - verify(mysqlCallableStatement, times(1)).isClosed(); - verify(mysqlCallableStatement, times(1)).setPoolable(anyBoolean()); - verify(mysqlCallableStatement, times(1)).getWarnings(); - verify(mysqlCallableStatement, times(1)).clearWarnings(); - verify(mysqlCallableStatement, times(1)).setCursorName(anyString()); - verify(mysqlCallableStatement, times(1)).setMaxFieldSize(anyInt()); - verify(mysqlCallableStatement, times(1)).getMaxFieldSize(); - verify(mysqlCallableStatement, times(1)).setMaxRows(anyInt()); - verify(mysqlCallableStatement, times(1)).getMaxRows(); - verify(mysqlCallableStatement, times(1)).setEscapeProcessing(anyBoolean()); - verify(mysqlCallableStatement, times(1)).getResultSetConcurrency(); - verify(mysqlCallableStatement, times(1)).getResultSetConcurrency(); - verify(mysqlCallableStatement, times(1)).getResultSetType(); - verify(mysqlCallableStatement, times(1)).getMetaData(); - verify(mysqlCallableStatement, times(1)).getParameterMetaData(); - verify(mysqlCallableStatement, times(1)).getMoreResults(anyInt()); - verify(mysqlCallableStatement, times(1)).setFetchSize(anyInt()); - verify(mysqlCallableStatement, times(1)).getFetchSize(); - verify(mysqlCallableStatement, times(1)).getQueryTimeout(); - verify(mysqlCallableStatement, times(1)).setQueryTimeout(anyInt()); - verify(mysqlCallableStatement, times(1)).getResultSet(); + verify(mysqlCallableStatement).getUpdateCount(); + verify(mysqlCallableStatement).getMoreResults(); + verify(mysqlCallableStatement).setFetchDirection(anyInt()); + verify(mysqlCallableStatement).getFetchDirection(); + verify(mysqlCallableStatement).getResultSetType(); + verify(mysqlCallableStatement).isClosed(); + verify(mysqlCallableStatement).setPoolable(anyBoolean()); + verify(mysqlCallableStatement).getWarnings(); + verify(mysqlCallableStatement).clearWarnings(); + verify(mysqlCallableStatement).setCursorName(anyString()); + verify(mysqlCallableStatement).setMaxFieldSize(anyInt()); + verify(mysqlCallableStatement).getMaxFieldSize(); + verify(mysqlCallableStatement).setMaxRows(anyInt()); + verify(mysqlCallableStatement).getMaxRows(); + verify(mysqlCallableStatement).setEscapeProcessing(anyBoolean()); + verify(mysqlCallableStatement).getResultSetConcurrency(); + verify(mysqlCallableStatement).getResultSetConcurrency(); + verify(mysqlCallableStatement).getResultSetType(); + verify(mysqlCallableStatement).getMetaData(); + verify(mysqlCallableStatement).getParameterMetaData(); + verify(mysqlCallableStatement).getMoreResults(anyInt()); + verify(mysqlCallableStatement).setFetchSize(anyInt()); + verify(mysqlCallableStatement).getFetchSize(); + verify(mysqlCallableStatement).getQueryTimeout(); + verify(mysqlCallableStatement).setQueryTimeout(anyInt()); + verify(mysqlCallableStatement).getResultSet(); assertThat(connection, CoreMatchers.is(swConnection)); } @@ -477,8 +477,8 @@ public void testExecuteQuery() throws SQLException { callableStatement.close(); - verify(mysqlCallableStatement, times(1)).executeQuery(); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).executeQuery(); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -494,8 +494,8 @@ public void testQuerySqlWithSql() throws SQLException { preparedStatement.getGeneratedKeys(); preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).executeQuery(anyString()); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).executeQuery(anyString()); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -509,8 +509,8 @@ public void testInsertWithAutoGeneratedKey() throws SQLException { boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", 1); preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).execute(anyString(), anyInt()); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).execute(anyString(), anyInt()); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -524,7 +524,7 @@ public void testInsertWithIntColumnIndexes() throws SQLException { boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", new int[] {1, 2}); preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -538,7 +538,7 @@ public void testInsertWithStringColumnIndexes() throws SQLException { boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", new String[] {"1", "2"}); preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -554,8 +554,8 @@ public void testExecute() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).execute(anyString()); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).execute(anyString()); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -571,8 +571,8 @@ public void testExecuteUpdate() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).executeUpdate(); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).executeUpdate(); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -588,8 +588,8 @@ public void testUpdateSql() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).executeUpdate(anyString()); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).executeUpdate(anyString()); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -605,7 +605,7 @@ public void testUpdateWithAutoGeneratedKey() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -621,7 +621,7 @@ public void testUpdateWithIntColumnIndexes() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -637,7 +637,7 @@ public void testUpdateWithStringColumnIndexes() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).close(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -654,9 +654,9 @@ public void testBatch() throws SQLException, MalformedURLException { int[] resultSet = preparedStatement.executeBatch(); preparedStatement.clearBatch(); - verify(mysqlCallableStatement, times(1)).executeBatch(); - verify(mysqlCallableStatement, times(1)).addBatch(); - verify(mysqlCallableStatement, times(1)).clearBatch(); + verify(mysqlCallableStatement).executeBatch(); + verify(mysqlCallableStatement).addBatch(); + verify(mysqlCallableStatement).clearBatch(); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); @@ -676,8 +676,8 @@ public void testQueryWithMultiHost() throws SQLException { preparedStatement.close(); - verify(mysqlCallableStatement, times(1)).executeQuery(); - verify(mysqlCallableStatement, times(1)).close(); + verify(mysqlCallableStatement).executeQuery(); + verify(mysqlCallableStatement).close(); } @Test(expected = SQLException.class) @@ -696,12 +696,12 @@ public void testMultiHostWithException() throws SQLException { preparedStatement.close(); } finally { - verify(mysqlCallableStatement, times(1)).executeQuery(); + verify(mysqlCallableStatement).executeQuery(); verify(mysqlCallableStatement, times(0)).close(); - verify(mysqlCallableStatement, times(1)).setBigDecimal(anyInt(), any(BigDecimal.class)); - verify(mysqlCallableStatement, times(1)).setBlob(anyInt(), any(InputStream.class)); - verify(mysqlCallableStatement, times(1)).setBlob(anyInt(), any(InputStream.class), anyLong()); - verify(mysqlCallableStatement, times(1)).setByte(anyInt(), anyByte()); + verify(mysqlCallableStatement).setBigDecimal(anyInt(), any(BigDecimal.class)); + verify(mysqlCallableStatement).setBlob(anyInt(), any(InputStream.class)); + verify(mysqlCallableStatement).setBlob(anyInt(), any(InputStream.class), anyLong()); + verify(mysqlCallableStatement).setByte(anyInt(), anyByte()); assertThat(segmentStorage.getTraceSegments().size(), is(1)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWConnectionTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWConnectionTest.java index 7216be7e70b5..32056f929d8a 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWConnectionTest.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWConnectionTest.java @@ -50,7 +50,6 @@ import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -323,33 +322,33 @@ public void testSetConfig() throws SQLException { swConnection.setTransactionIsolation(1); swConnection.setTypeMap(new HashMap>()); - verify(jdbcConnection, times(1)).createBlob(); - verify(jdbcConnection, times(1)).createClob(); - verify(jdbcConnection, times(1)).createNClob(); - verify(jdbcConnection, times(1)).createSQLXML(); - verify(jdbcConnection, times(1)).nativeSQL(anyString()); - verify(jdbcConnection, times(1)).setAutoCommit(anyBoolean()); - verify(jdbcConnection, times(1)).getAutoCommit(); - verify(jdbcConnection, times(1)).setCatalog(anyString()); - verify(jdbcConnection, times(1)).getCatalog(); - verify(jdbcConnection, times(1)).setClientInfo(anyString(), anyString()); - verify(jdbcConnection, times(1)).setHoldability(anyInt()); - verify(jdbcConnection, times(1)).getHoldability(); - verify(jdbcConnection, times(1)).setReadOnly(anyBoolean()); - verify(jdbcConnection, times(1)).getClientInfo(); - verify(jdbcConnection, times(1)).getClientInfo(anyString()); - verify(jdbcConnection, times(1)).setSavepoint(anyString()); - verify(jdbcConnection, times(1)).setSavepoint(); - verify(jdbcConnection, times(1)).getMetaData(); - verify(jdbcConnection, times(1)).getTransactionIsolation(); - verify(jdbcConnection, times(1)).getTypeMap(); - verify(jdbcConnection, times(1)).getWarnings(); - verify(jdbcConnection, times(1)).setTransactionIsolation(anyInt()); - verify(jdbcConnection, times(1)).getTransactionIsolation(); - verify(jdbcConnection, times(1)).isClosed(); - verify(jdbcConnection, times(1)).isReadOnly(); - verify(jdbcConnection, times(1)).isValid(anyInt()); - verify(jdbcConnection, times(1)).setTypeMap(any(HashMap.class)); + verify(jdbcConnection).createBlob(); + verify(jdbcConnection).createClob(); + verify(jdbcConnection).createNClob(); + verify(jdbcConnection).createSQLXML(); + verify(jdbcConnection).nativeSQL(anyString()); + verify(jdbcConnection).setAutoCommit(anyBoolean()); + verify(jdbcConnection).getAutoCommit(); + verify(jdbcConnection).setCatalog(anyString()); + verify(jdbcConnection).getCatalog(); + verify(jdbcConnection).setClientInfo(anyString(), anyString()); + verify(jdbcConnection).setHoldability(anyInt()); + verify(jdbcConnection).getHoldability(); + verify(jdbcConnection).setReadOnly(anyBoolean()); + verify(jdbcConnection).getClientInfo(); + verify(jdbcConnection).getClientInfo(anyString()); + verify(jdbcConnection).setSavepoint(anyString()); + verify(jdbcConnection).setSavepoint(); + verify(jdbcConnection).getMetaData(); + verify(jdbcConnection).getTransactionIsolation(); + verify(jdbcConnection).getTypeMap(); + verify(jdbcConnection).getWarnings(); + verify(jdbcConnection).setTransactionIsolation(anyInt()); + verify(jdbcConnection).getTransactionIsolation(); + verify(jdbcConnection).isClosed(); + verify(jdbcConnection).isReadOnly(); + verify(jdbcConnection).isValid(anyInt()); + verify(jdbcConnection).setTypeMap(any(HashMap.class)); } } diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWStatementTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWStatementTest.java index d3bc35d8b049..ea534236093d 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWStatementTest.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SWStatementTest.java @@ -49,7 +49,6 @@ import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -113,30 +112,30 @@ public void testPreparedStatementConfig() throws SQLException { statement.getResultSet(); statement.close(); - verify(mysqlStatement, times(1)).getUpdateCount(); - verify(mysqlStatement, times(1)).getMoreResults(); - verify(mysqlStatement, times(1)).setFetchDirection(anyInt()); - verify(mysqlStatement, times(1)).getFetchDirection(); - verify(mysqlStatement, times(1)).getResultSetType(); - verify(mysqlStatement, times(1)).isClosed(); - verify(mysqlStatement, times(1)).setPoolable(anyBoolean()); - verify(mysqlStatement, times(1)).getWarnings(); - verify(mysqlStatement, times(1)).clearWarnings(); - verify(mysqlStatement, times(1)).setCursorName(anyString()); - verify(mysqlStatement, times(1)).setMaxFieldSize(anyInt()); - verify(mysqlStatement, times(1)).getMaxFieldSize(); - verify(mysqlStatement, times(1)).setMaxRows(anyInt()); - verify(mysqlStatement, times(1)).getMaxRows(); - verify(mysqlStatement, times(1)).setEscapeProcessing(anyBoolean()); - verify(mysqlStatement, times(1)).getResultSetConcurrency(); - verify(mysqlStatement, times(1)).getResultSetConcurrency(); - verify(mysqlStatement, times(1)).getResultSetType(); - verify(mysqlStatement, times(1)).getMoreResults(anyInt()); - verify(mysqlStatement, times(1)).setFetchSize(anyInt()); - verify(mysqlStatement, times(1)).getFetchSize(); - verify(mysqlStatement, times(1)).getQueryTimeout(); - verify(mysqlStatement, times(1)).setQueryTimeout(anyInt()); - verify(mysqlStatement, times(1)).getResultSet(); + verify(mysqlStatement).getUpdateCount(); + verify(mysqlStatement).getMoreResults(); + verify(mysqlStatement).setFetchDirection(anyInt()); + verify(mysqlStatement).getFetchDirection(); + verify(mysqlStatement).getResultSetType(); + verify(mysqlStatement).isClosed(); + verify(mysqlStatement).setPoolable(anyBoolean()); + verify(mysqlStatement).getWarnings(); + verify(mysqlStatement).clearWarnings(); + verify(mysqlStatement).setCursorName(anyString()); + verify(mysqlStatement).setMaxFieldSize(anyInt()); + verify(mysqlStatement).getMaxFieldSize(); + verify(mysqlStatement).setMaxRows(anyInt()); + verify(mysqlStatement).getMaxRows(); + verify(mysqlStatement).setEscapeProcessing(anyBoolean()); + verify(mysqlStatement).getResultSetConcurrency(); + verify(mysqlStatement).getResultSetConcurrency(); + verify(mysqlStatement).getResultSetType(); + verify(mysqlStatement).getMoreResults(anyInt()); + verify(mysqlStatement).setFetchSize(anyInt()); + verify(mysqlStatement).getFetchSize(); + verify(mysqlStatement).getQueryTimeout(); + verify(mysqlStatement).setQueryTimeout(anyInt()); + verify(mysqlStatement).getResultSet(); assertThat(connection, CoreMatchers.is(swConnection)); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); @@ -187,7 +186,7 @@ public void testExecuteUpdateWithAutoGeneratedKey() throws SQLException { int executeSuccess = statement.executeUpdate("UPDATE test SET a = 1", 1); statement.getGeneratedKeys(); - verify(mysqlStatement, times(1)).getGeneratedKeys(); + verify(mysqlStatement).getGeneratedKeys(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -249,9 +248,9 @@ public void testBatch() throws SQLException, MalformedURLException { int[] resultSet = statement.executeBatch(); statement.clearBatch(); - verify(mysqlStatement, times(1)).executeBatch(); - verify(mysqlStatement, times(1)).addBatch(anyString()); - verify(mysqlStatement, times(1)).clearBatch(); + verify(mysqlStatement).executeBatch(); + verify(mysqlStatement).addBatch(anyString()); + verify(mysqlStatement).clearBatch(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -267,7 +266,7 @@ public void testMultiHostWithException() throws SQLException { Statement statement = multiHostConnection.createStatement(); statement.execute("UPDATE test SET a = 1 WHERE b = 2"); } finally { - verify(mysqlStatement, times(1)).execute(anyString()); + verify(mysqlStatement).execute(anyString()); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java index b783eb013919..2bea98f5d910 100644 --- a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java +++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/apache/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java @@ -182,57 +182,57 @@ public void testSetParam() throws SQLException, MalformedURLException { ResultSet resultSet = preparedStatement.executeQuery(); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).clearParameters(); - verify(mysqlPreparedStatement, times(1)).executeQuery(); - verify(mysqlPreparedStatement, times(1)).close(); - verify(mysqlPreparedStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class)); - verify(mysqlPreparedStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class), anyInt()); - verify(mysqlPreparedStatement, times(1)).setAsciiStream(anyInt(), any(InputStream.class), anyLong()); - verify(mysqlPreparedStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class)); - verify(mysqlPreparedStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class), anyInt()); - verify(mysqlPreparedStatement, times(1)).setCharacterStream(anyInt(), any(Reader.class), anyLong()); - verify(mysqlPreparedStatement, times(1)).setShort(anyInt(), anyShort()); - verify(mysqlPreparedStatement, times(1)).setInt(anyInt(), anyInt()); - verify(mysqlPreparedStatement, times(1)).setString(anyInt(), anyString()); - verify(mysqlPreparedStatement, times(1)).setBoolean(anyInt(), anyBoolean()); - verify(mysqlPreparedStatement, times(1)).setLong(anyInt(), anyLong()); - verify(mysqlPreparedStatement, times(1)).setDouble(anyInt(), anyDouble()); - verify(mysqlPreparedStatement, times(1)).setFloat(anyInt(), anyFloat()); - verify(mysqlPreparedStatement, times(1)).setByte(anyInt(), anyByte()); - verify(mysqlPreparedStatement, times(1)).setBytes(14, bytesParam); - verify(mysqlPreparedStatement, times(1)).setDate(anyInt(), any(Date.class)); - verify(mysqlPreparedStatement, times(1)).setNull(anyInt(), anyInt()); - verify(mysqlPreparedStatement, times(1)).setNull(anyInt(), anyInt(), anyString()); - verify(mysqlPreparedStatement, times(1)).setBigDecimal(anyInt(), any(BigDecimal.class)); - verify(mysqlPreparedStatement, times(1)).setBlob(anyInt(), any(InputStream.class)); - verify(mysqlPreparedStatement, times(1)).setBlob(anyInt(), any(InputStream.class), anyLong()); - verify(mysqlPreparedStatement, times(1)).setClob(anyInt(), any(Clob.class)); - verify(mysqlPreparedStatement, times(1)).setClob(anyInt(), any(Reader.class)); - verify(mysqlPreparedStatement, times(1)).setClob(anyInt(), any(Reader.class), anyInt()); - verify(mysqlPreparedStatement, times(1)).setNString(anyInt(), anyString()); - verify(mysqlPreparedStatement, times(1)).setNCharacterStream(anyInt(), any(Reader.class)); - verify(mysqlPreparedStatement, times(1)).setNCharacterStream(anyInt(), any(Reader.class), anyInt()); - verify(mysqlPreparedStatement, times(1)).setNClob(27, nClob); - verify(mysqlPreparedStatement, times(1)).setNClob(28, reader, 1); - verify(mysqlPreparedStatement, times(1)).setObject(anyInt(), Matchers.anyObject()); - verify(mysqlPreparedStatement, times(1)).setObject(anyInt(), Matchers.anyObject(), anyInt()); - verify(mysqlPreparedStatement, times(1)).setObject(anyInt(), Matchers.anyObject(), anyInt(), anyInt()); - verify(mysqlPreparedStatement, times(1)).setRef(anyInt(), any(Ref.class)); - verify(mysqlPreparedStatement, times(1)).setRowId(anyInt(), any(RowId.class)); - verify(mysqlPreparedStatement, times(1)).setSQLXML(anyInt(), any(SQLXML.class)); - verify(mysqlPreparedStatement, times(1)).setTime(anyInt(), any(Time.class)); - verify(mysqlPreparedStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class)); - verify(mysqlPreparedStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class)); - verify(mysqlPreparedStatement, times(1)).setURL(anyInt(), any(URL.class)); - verify(mysqlPreparedStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class)); - verify(mysqlPreparedStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class), anyInt()); - verify(mysqlPreparedStatement, times(1)).setBinaryStream(anyInt(), any(InputStream.class), anyLong()); - verify(mysqlPreparedStatement, times(1)).setNClob(42, reader); - verify(mysqlPreparedStatement, times(1)).setTime(anyInt(), any(Time.class), any(Calendar.class)); - verify(mysqlPreparedStatement, times(1)).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class)); - verify(mysqlPreparedStatement, times(1)).setArray(anyInt(), any(Array.class)); - verify(mysqlPreparedStatement, times(1)).setBlob(anyInt(), any(Blob.class)); - verify(mysqlPreparedStatement, times(1)).setDate(anyInt(), any(Date.class), any(Calendar.class)); + verify(mysqlPreparedStatement).clearParameters(); + verify(mysqlPreparedStatement).executeQuery(); + verify(mysqlPreparedStatement).close(); + verify(mysqlPreparedStatement).setAsciiStream(anyInt(), any(InputStream.class)); + verify(mysqlPreparedStatement).setAsciiStream(anyInt(), any(InputStream.class), anyInt()); + verify(mysqlPreparedStatement).setAsciiStream(anyInt(), any(InputStream.class), anyLong()); + verify(mysqlPreparedStatement).setCharacterStream(anyInt(), any(Reader.class)); + verify(mysqlPreparedStatement).setCharacterStream(anyInt(), any(Reader.class), anyInt()); + verify(mysqlPreparedStatement).setCharacterStream(anyInt(), any(Reader.class), anyLong()); + verify(mysqlPreparedStatement).setShort(anyInt(), anyShort()); + verify(mysqlPreparedStatement).setInt(anyInt(), anyInt()); + verify(mysqlPreparedStatement).setString(anyInt(), anyString()); + verify(mysqlPreparedStatement).setBoolean(anyInt(), anyBoolean()); + verify(mysqlPreparedStatement).setLong(anyInt(), anyLong()); + verify(mysqlPreparedStatement).setDouble(anyInt(), anyDouble()); + verify(mysqlPreparedStatement).setFloat(anyInt(), anyFloat()); + verify(mysqlPreparedStatement).setByte(anyInt(), anyByte()); + verify(mysqlPreparedStatement).setBytes(14, bytesParam); + verify(mysqlPreparedStatement).setDate(anyInt(), any(Date.class)); + verify(mysqlPreparedStatement).setNull(anyInt(), anyInt()); + verify(mysqlPreparedStatement).setNull(anyInt(), anyInt(), anyString()); + verify(mysqlPreparedStatement).setBigDecimal(anyInt(), any(BigDecimal.class)); + verify(mysqlPreparedStatement).setBlob(anyInt(), any(InputStream.class)); + verify(mysqlPreparedStatement).setBlob(anyInt(), any(InputStream.class), anyLong()); + verify(mysqlPreparedStatement).setClob(anyInt(), any(Clob.class)); + verify(mysqlPreparedStatement).setClob(anyInt(), any(Reader.class)); + verify(mysqlPreparedStatement).setClob(anyInt(), any(Reader.class), anyInt()); + verify(mysqlPreparedStatement).setNString(anyInt(), anyString()); + verify(mysqlPreparedStatement).setNCharacterStream(anyInt(), any(Reader.class)); + verify(mysqlPreparedStatement).setNCharacterStream(anyInt(), any(Reader.class), anyInt()); + verify(mysqlPreparedStatement).setNClob(27, nClob); + verify(mysqlPreparedStatement).setNClob(28, reader, 1); + verify(mysqlPreparedStatement).setObject(anyInt(), Matchers.anyObject()); + verify(mysqlPreparedStatement).setObject(anyInt(), Matchers.anyObject(), anyInt()); + verify(mysqlPreparedStatement).setObject(anyInt(), Matchers.anyObject(), anyInt(), anyInt()); + verify(mysqlPreparedStatement).setRef(anyInt(), any(Ref.class)); + verify(mysqlPreparedStatement).setRowId(anyInt(), any(RowId.class)); + verify(mysqlPreparedStatement).setSQLXML(anyInt(), any(SQLXML.class)); + verify(mysqlPreparedStatement).setTime(anyInt(), any(Time.class)); + verify(mysqlPreparedStatement).setTimestamp(anyInt(), any(Timestamp.class)); + verify(mysqlPreparedStatement).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class)); + verify(mysqlPreparedStatement).setURL(anyInt(), any(URL.class)); + verify(mysqlPreparedStatement).setBinaryStream(anyInt(), any(InputStream.class)); + verify(mysqlPreparedStatement).setBinaryStream(anyInt(), any(InputStream.class), anyInt()); + verify(mysqlPreparedStatement).setBinaryStream(anyInt(), any(InputStream.class), anyLong()); + verify(mysqlPreparedStatement).setNClob(42, reader); + verify(mysqlPreparedStatement).setTime(anyInt(), any(Time.class), any(Calendar.class)); + verify(mysqlPreparedStatement).setTimestamp(anyInt(), any(Timestamp.class), any(Calendar.class)); + verify(mysqlPreparedStatement).setArray(anyInt(), any(Array.class)); + verify(mysqlPreparedStatement).setBlob(anyInt(), any(Blob.class)); + verify(mysqlPreparedStatement).setDate(anyInt(), any(Date.class), any(Calendar.class)); } @Test @@ -272,32 +272,32 @@ public void testPreparedStatementConfig() throws SQLException { preparedStatement.getResultSet(); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).getUpdateCount(); - verify(mysqlPreparedStatement, times(1)).getMoreResults(); - verify(mysqlPreparedStatement, times(1)).setFetchDirection(anyInt()); - verify(mysqlPreparedStatement, times(1)).getFetchDirection(); - verify(mysqlPreparedStatement, times(1)).getResultSetType(); - verify(mysqlPreparedStatement, times(1)).isClosed(); - verify(mysqlPreparedStatement, times(1)).setPoolable(anyBoolean()); - verify(mysqlPreparedStatement, times(1)).getWarnings(); - verify(mysqlPreparedStatement, times(1)).clearWarnings(); - verify(mysqlPreparedStatement, times(1)).setCursorName(anyString()); - verify(mysqlPreparedStatement, times(1)).setMaxFieldSize(anyInt()); - verify(mysqlPreparedStatement, times(1)).getMaxFieldSize(); - verify(mysqlPreparedStatement, times(1)).setMaxRows(anyInt()); - verify(mysqlPreparedStatement, times(1)).getMaxRows(); - verify(mysqlPreparedStatement, times(1)).setEscapeProcessing(anyBoolean()); - verify(mysqlPreparedStatement, times(1)).getResultSetConcurrency(); - verify(mysqlPreparedStatement, times(1)).getResultSetConcurrency(); - verify(mysqlPreparedStatement, times(1)).getResultSetType(); - verify(mysqlPreparedStatement, times(1)).getMetaData(); - verify(mysqlPreparedStatement, times(1)).getParameterMetaData(); - verify(mysqlPreparedStatement, times(1)).getMoreResults(anyInt()); - verify(mysqlPreparedStatement, times(1)).setFetchSize(anyInt()); - verify(mysqlPreparedStatement, times(1)).getFetchSize(); - verify(mysqlPreparedStatement, times(1)).getQueryTimeout(); - verify(mysqlPreparedStatement, times(1)).setQueryTimeout(anyInt()); - verify(mysqlPreparedStatement, times(1)).getResultSet(); + verify(mysqlPreparedStatement).getUpdateCount(); + verify(mysqlPreparedStatement).getMoreResults(); + verify(mysqlPreparedStatement).setFetchDirection(anyInt()); + verify(mysqlPreparedStatement).getFetchDirection(); + verify(mysqlPreparedStatement).getResultSetType(); + verify(mysqlPreparedStatement).isClosed(); + verify(mysqlPreparedStatement).setPoolable(anyBoolean()); + verify(mysqlPreparedStatement).getWarnings(); + verify(mysqlPreparedStatement).clearWarnings(); + verify(mysqlPreparedStatement).setCursorName(anyString()); + verify(mysqlPreparedStatement).setMaxFieldSize(anyInt()); + verify(mysqlPreparedStatement).getMaxFieldSize(); + verify(mysqlPreparedStatement).setMaxRows(anyInt()); + verify(mysqlPreparedStatement).getMaxRows(); + verify(mysqlPreparedStatement).setEscapeProcessing(anyBoolean()); + verify(mysqlPreparedStatement).getResultSetConcurrency(); + verify(mysqlPreparedStatement).getResultSetConcurrency(); + verify(mysqlPreparedStatement).getResultSetType(); + verify(mysqlPreparedStatement).getMetaData(); + verify(mysqlPreparedStatement).getParameterMetaData(); + verify(mysqlPreparedStatement).getMoreResults(anyInt()); + verify(mysqlPreparedStatement).setFetchSize(anyInt()); + verify(mysqlPreparedStatement).getFetchSize(); + verify(mysqlPreparedStatement).getQueryTimeout(); + verify(mysqlPreparedStatement).setQueryTimeout(anyInt()); + verify(mysqlPreparedStatement).getResultSet(); assertThat(connection, CoreMatchers.is(swConnection)); } @@ -308,8 +308,8 @@ public void testExecuteQuery() throws SQLException { preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).executeQuery(); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).executeQuery(); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -323,8 +323,8 @@ public void testExecute() throws SQLException { preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).execute(); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).execute(); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -339,8 +339,8 @@ public void testQuerySqlWithSql() throws SQLException { preparedStatement.getGeneratedKeys(); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).executeQuery(anyString()); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).executeQuery(anyString()); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -354,8 +354,8 @@ public void testInsertWithAutoGeneratedKey() throws SQLException { boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", 1); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).execute(anyString(), anyInt()); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).execute(anyString(), anyInt()); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -369,7 +369,7 @@ public void testInsertWithIntColumnIndexes() throws SQLException { boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", new int[] {1, 2}); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -383,7 +383,7 @@ public void testInsertWithStringColumnIndexes() throws SQLException { boolean insertCount = preparedStatement.execute("INSERT INTO test VALUES(1)", new String[] {"1", "2"}); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -399,8 +399,8 @@ public void testExecuteWithSQL() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).execute(anyString()); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).execute(anyString()); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -416,8 +416,8 @@ public void testExecuteUpdate() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).executeUpdate(); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).executeUpdate(); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -433,8 +433,8 @@ public void testUpdateSql() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).executeUpdate(anyString()); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).executeUpdate(anyString()); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -450,7 +450,7 @@ public void testUpdateWithAutoGeneratedKey() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -465,7 +465,7 @@ public void testUpdateWithIntColumnIndexes() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -481,7 +481,7 @@ public void testUpdateWithStringColumnIndexes() throws SQLException { preparedStatement.cancel(); preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).close(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertThat(spans.size(), is(1)); @@ -497,9 +497,9 @@ public void testBatch() throws SQLException, MalformedURLException { int[] resultSet = preparedStatement.executeBatch(); preparedStatement.clearBatch(); - verify(mysqlPreparedStatement, times(1)).executeBatch(); - verify(mysqlPreparedStatement, times(1)).addBatch(); - verify(mysqlPreparedStatement, times(1)).clearBatch(); + verify(mysqlPreparedStatement).executeBatch(); + verify(mysqlPreparedStatement).addBatch(); + verify(mysqlPreparedStatement).clearBatch(); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); @@ -519,8 +519,8 @@ public void testQueryWithMultiHost() throws SQLException { preparedStatement.close(); - verify(mysqlPreparedStatement, times(1)).executeQuery(); - verify(mysqlPreparedStatement, times(1)).close(); + verify(mysqlPreparedStatement).executeQuery(); + verify(mysqlPreparedStatement).close(); } @Test(expected = SQLException.class) @@ -539,12 +539,12 @@ public void testMultiHostWithException() throws SQLException { preparedStatement.close(); } finally { - verify(mysqlPreparedStatement, times(1)).executeQuery(); + verify(mysqlPreparedStatement).executeQuery(); verify(mysqlPreparedStatement, times(0)).close(); - verify(mysqlPreparedStatement, times(1)).setBigDecimal(anyInt(), any(BigDecimal.class)); - verify(mysqlPreparedStatement, times(1)).setBlob(anyInt(), any(InputStream.class)); - verify(mysqlPreparedStatement, times(1)).setBlob(anyInt(), any(InputStream.class), anyLong()); - verify(mysqlPreparedStatement, times(1)).setByte(anyInt(), anyByte()); + verify(mysqlPreparedStatement).setBigDecimal(anyInt(), any(BigDecimal.class)); + verify(mysqlPreparedStatement).setBlob(anyInt(), any(InputStream.class)); + verify(mysqlPreparedStatement).setBlob(anyInt(), any(InputStream.class), anyLong()); + verify(mysqlPreparedStatement).setByte(anyInt(), anyByte()); TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); diff --git a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithHostAndPortArgInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithHostAndPortArgInterceptorTest.java index 72dc6da27842..49ffc1f527fd 100644 --- a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithHostAndPortArgInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithHostAndPortArgInterceptorTest.java @@ -28,7 +28,6 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; import redis.clients.jedis.HostAndPort; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @RunWith(MockitoJUnitRunner.class) @@ -52,7 +51,7 @@ public void tearDown() throws Exception { @Test public void onConstruct() throws Exception { interceptor.onConstruct(enhancedInstance, new Object[] {new HostAndPort("127.0.0.1", 6379)}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:6379"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:6379"); } } diff --git a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptorTest.java index f1520744ff5d..b2fbc81ae601 100644 --- a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptorTest.java @@ -29,7 +29,6 @@ import org.mockito.runners.MockitoJUnitRunner; import redis.clients.jedis.HostAndPort; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @RunWith(MockitoJUnitRunner.class) @@ -59,7 +58,7 @@ public void tearDown() throws Exception { public void onConstruct() throws Exception { interceptor.onConstruct(enhancedInstance, new Object[] {hostAndPortSet}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:6379;127.0.0.1:16379;"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:6379;127.0.0.1:16379;"); } } diff --git a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithShardInfoArgInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithShardInfoArgInterceptorTest.java index aca152a76d7c..371bf750c49f 100644 --- a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithShardInfoArgInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithShardInfoArgInterceptorTest.java @@ -28,7 +28,6 @@ import org.mockito.runners.MockitoJUnitRunner; import redis.clients.jedis.JedisShardInfo; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @RunWith(MockitoJUnitRunner.class) @@ -51,7 +50,7 @@ public void tearDown() throws Exception { public void onConstruct() throws Exception { interceptor.onConstruct(enhancedInstance, new Object[] {new JedisShardInfo("127.0.0.1", 6379)}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:6379"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:6379"); } } diff --git a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithStringArgInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithStringArgInterceptorTest.java index a1e9234a9741..f645b7c66616 100644 --- a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithStringArgInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithStringArgInterceptorTest.java @@ -26,7 +26,6 @@ import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @RunWith(MockitoJUnitRunner.class) @@ -46,14 +45,14 @@ public void setUp() throws Exception { public void onConstruct() throws Exception { interceptor.onConstruct(enhancedInstance, new Object[] {"127.0.0.1"}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:6379"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:6379"); } @Test public void onConstructWithPort() { interceptor.onConstruct(enhancedInstance, new Object[] {"127.0.0.1", 16379}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:16379"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:16379"); } } diff --git a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithUriArgInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithUriArgInterceptorTest.java index 3b4264f8c1a1..d22c7b290b7d 100644 --- a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithUriArgInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisConstructorWithUriArgInterceptorTest.java @@ -28,7 +28,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @RunWith(PowerMockRunner.class) @@ -50,6 +49,6 @@ public void setUp() throws Exception { public void onConstruct() throws Exception { interceptor.onConstruct(enhancedInstance, new Object[] {uri}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:6379"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:6379"); } } diff --git a/apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/apache/skywalking/apm/plugin/motan/MotanConsumerInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/apache/skywalking/apm/plugin/motan/MotanConsumerInterceptorTest.java index 59722627aaf5..1f0f2b04081d 100644 --- a/apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/apache/skywalking/apm/plugin/motan/MotanConsumerInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/apache/skywalking/apm/plugin/motan/MotanConsumerInterceptorTest.java @@ -48,7 +48,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.apache.skywalking.apm.agent.test.tools.SpanAssert.assertComponent; @@ -94,7 +93,7 @@ public void testInvokeInterceptor() throws Throwable { TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertMotanConsumerSpan(spans.get(0)); - verify(request, times(1)).setAttachment(anyString(), anyString()); + verify(request).setAttachment(anyString(), anyString()); } @Test @@ -112,7 +111,7 @@ public void testResponseWithException() throws Throwable { private void assertTraceSegmentWhenOccurException(AbstractTracingSpan tracingSpan) { assertMotanConsumerSpan(tracingSpan); - verify(request, times(1)).setAttachment(anyString(), anyString()); + verify(request).setAttachment(anyString(), anyString()); List logDataEntities = SpanHelper.getLogs(tracingSpan); assertThat(logDataEntities.size(), is(1)); SpanAssert.assertException(logDataEntities.get(0), RuntimeException.class); diff --git a/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v5/ConnectionImplCreateInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v5/ConnectionImplCreateInterceptorTest.java index c71ed23c713d..b333fb7a5421 100644 --- a/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v5/ConnectionImplCreateInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v5/ConnectionImplCreateInterceptorTest.java @@ -27,7 +27,6 @@ import org.mockito.runners.MockitoJUnitRunner; import static org.mockito.Mockito.verify; -import static org.mockito.internal.verification.VerificationModeFactory.times; /** * @@ -49,6 +48,6 @@ public void setUp() { @Test public void testResultIsEnhanceInstance() throws Throwable { interceptor.afterMethod(null,null,new Object[]{"localhost",3360,null,"test","jdbc:mysql:replication://localhost:3360,localhost:3360,localhost:3360/test?useUnicode=true&characterEncoding=utf8&useSSL=false&roundRobinLoadBalance=true"},null,objectInstance); - verify(objectInstance,times(1)).setSkyWalkingDynamicField(Matchers.any()); + verify(objectInstance).setSkyWalkingDynamicField(Matchers.any()); } } \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/mysql-8.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v8/ConnectionImplCreateInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mysql-8.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v8/ConnectionImplCreateInterceptorTest.java index 2022d24a1316..a4f95bcf7b7d 100644 --- a/apm-sniffer/apm-sdk-plugin/mysql-8.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v8/ConnectionImplCreateInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/mysql-8.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v8/ConnectionImplCreateInterceptorTest.java @@ -28,7 +28,6 @@ import org.mockito.runners.MockitoJUnitRunner; import static org.mockito.Mockito.verify; -import static org.mockito.internal.verification.VerificationModeFactory.times; /** * @@ -52,6 +51,6 @@ public void testResultIsEnhanceInstance() throws Throwable { final ConnectionUrlParser connectionUrlParser = ConnectionUrlParser.parseConnectionString("jdbc:mysql:replication://localhost:3360,localhost:3360,localhost:3360/test?useUnicode=true&characterEncoding=utf8&useSSL=false&roundRobinLoadBalance=true"); interceptor.afterMethod(null,null,connectionUrlParser.getHosts().toArray(),null,objectInstance); - verify(objectInstance,times(1)).setSkyWalkingDynamicField(Matchers.any()); + verify(objectInstance).setSkyWalkingDynamicField(Matchers.any()); } } \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptorTest.java index 9ccb856971ad..569c1a750121 100644 --- a/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreateCallableStatementInterceptorTest.java @@ -56,7 +56,7 @@ public void setUp() { @Test public void testResultIsEnhanceInstance() throws Throwable { interceptor.afterMethod(objectInstance, null, new Object[] {"SELECT * FROM test"}, null, ret); - verify(ret, times(1)).setSkyWalkingDynamicField(Matchers.any()); + verify(ret).setSkyWalkingDynamicField(Matchers.any()); } @Test diff --git a/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptorTest.java index 9806db06a533..4d6d829adc1d 100644 --- a/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreatePreparedStatementInterceptorTest.java @@ -55,7 +55,7 @@ public void setUp() { @Test public void testResultIsEnhanceInstance() throws Throwable { interceptor.afterMethod(objectInstance, null, new Object[] {"SELECT * FROM test"}, null, ret); - verify(ret, times(1)).setSkyWalkingDynamicField(Matchers.any()); + verify(ret).setSkyWalkingDynamicField(Matchers.any()); } @Test diff --git a/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptorTest.java index e22db05dce74..b50fdbec43d2 100644 --- a/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/mysql-common/src/test/java/org/apache/skywalking/apm/plugin/jdbc/mysql/CreateStatementInterceptorTest.java @@ -56,7 +56,7 @@ public void setUp() { @Test public void testResultIsEnhanceInstance() throws Throwable { interceptor.afterMethod(objectInstance, null, new Object[] {"SELECT * FROM test"}, null, ret); - verify(ret, times(1)).setSkyWalkingDynamicField(Matchers.any()); + verify(ret).setSkyWalkingDynamicField(Matchers.any()); } @Test diff --git a/apm-sniffer/apm-sdk-plugin/nutz-plugins/http-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/nutz/http/sync/SenderInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/nutz-plugins/http-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/nutz/http/sync/SenderInterceptorTest.java index 15128246e3e2..973176670d1f 100644 --- a/apm-sniffer/apm-sdk-plugin/nutz-plugins/http-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/nutz/http/sync/SenderInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/nutz-plugins/http-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/nutz/http/sync/SenderInterceptorTest.java @@ -46,7 +46,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -91,7 +90,7 @@ public void setupSender(Class klass) throws NoSuchMethodExcept public void test_constructor() { Request request = Request.create("https://nutz.cn/yvr/list", METHOD.GET); constructorInterceptPoint.onConstruct(enhancedInstance, new Object[] {request}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField(request); + verify(enhancedInstance).setSkyWalkingDynamicField(request); } @Test @@ -115,7 +114,7 @@ public void test_filepostsender_send() throws NoSuchMethodException, SecurityExc protected void _sender_sender_test() throws Throwable { Request request = Request.create("https://nutz.cn/yvr/list", METHOD.GET); constructorInterceptPoint.onConstruct(enhancedInstance, new Object[] {request}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField(request); + verify(enhancedInstance).setSkyWalkingDynamicField(request); when(enhancedInstance.getSkyWalkingDynamicField()).thenReturn(request); when(resp.getStatus()).thenReturn(200); diff --git a/apm-sniffer/apm-sdk-plugin/rocketMQ-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/rocketMQ/v3/MessageSendInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/rocketMQ-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/rocketMQ/v3/MessageSendInterceptorTest.java index 283bae54276d..935f6dff7907 100644 --- a/apm-sniffer/apm-sdk-plugin/rocketMQ-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/rocketMQ/v3/MessageSendInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/rocketMQ-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/rocketMQ/v3/MessageSendInterceptorTest.java @@ -46,7 +46,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.powermock.api.mockito.PowerMockito.when; @@ -111,8 +110,8 @@ public void testSendMessage() throws Throwable { SpanAssert.assertLayer(mqSpan, SpanLayer.MQ); SpanAssert.assertComponent(mqSpan, ComponentsDefine.ROCKET_MQ_PRODUCER); SpanAssert.assertTag(mqSpan, 0, "127.0.0.1"); - verify(messageRequestHeader, times(1)).setProperties(anyString()); - verify(callBack, times(1)).setSkyWalkingDynamicField(Matchers.any()); + verify(messageRequestHeader).setProperties(anyString()); + verify(callBack).setSkyWalkingDynamicField(Matchers.any()); } @Test @@ -130,7 +129,7 @@ public void testSendMessageWithoutCallBack() throws Throwable { SpanAssert.assertLayer(mqSpan, SpanLayer.MQ); SpanAssert.assertComponent(mqSpan, ComponentsDefine.ROCKET_MQ_PRODUCER); SpanAssert.assertTag(mqSpan, 0, "127.0.0.1"); - verify(messageRequestHeader, times(1)).setProperties(anyString()); + verify(messageRequestHeader).setProperties(anyString()); } } diff --git a/apm-sniffer/apm-sdk-plugin/rocketMQ-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/rocketMQ/v4/MessageSendInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/rocketMQ-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/rocketMQ/v4/MessageSendInterceptorTest.java index 7c3d76229346..1c41f7f08f29 100644 --- a/apm-sniffer/apm-sdk-plugin/rocketMQ-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/rocketMQ/v4/MessageSendInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/rocketMQ-4.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/rocketMQ/v4/MessageSendInterceptorTest.java @@ -46,7 +46,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.powermock.api.mockito.PowerMockito.when; @@ -111,8 +110,8 @@ public void testSendMessage() throws Throwable { SpanAssert.assertLayer(mqSpan, SpanLayer.MQ); SpanAssert.assertComponent(mqSpan, ComponentsDefine.ROCKET_MQ_PRODUCER); SpanAssert.assertTag(mqSpan, 0, "127.0.0.1"); - verify(messageRequestHeader, times(1)).setProperties(anyString()); - verify(callBack, times(1)).setSkyWalkingDynamicField(Matchers.any()); + verify(messageRequestHeader).setProperties(anyString()); + verify(callBack).setSkyWalkingDynamicField(Matchers.any()); } @Test @@ -130,7 +129,7 @@ public void testSendMessageWithoutCallBack() throws Throwable { SpanAssert.assertLayer(mqSpan, SpanLayer.MQ); SpanAssert.assertComponent(mqSpan, ComponentsDefine.ROCKET_MQ_PRODUCER); SpanAssert.assertTag(mqSpan, 0, "127.0.0.1"); - verify(messageRequestHeader, times(1)).setProperties(anyString()); + verify(messageRequestHeader).setProperties(anyString()); } } diff --git a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/ProducerOperationHandlerInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/ProducerOperationHandlerInterceptorTest.java index 0d8aa41ea55c..4ca96f939e4e 100644 --- a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/ProducerOperationHandlerInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/ProducerOperationHandlerInterceptorTest.java @@ -51,7 +51,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -119,7 +118,7 @@ public void testConsumer() throws Throwable { List spans = SegmentHelper.getSpans(traceSegment); assertCombSpan(spans.get(0)); - verify(invocation, times(1)).getContext(); + verify(invocation).getContext(); } private void assertCombSpan(AbstractTracingSpan span) { diff --git a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/TransportClientHandlerInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/TransportClientHandlerInterceptorTest.java index e32ffb0180e7..fd2793801a02 100644 --- a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/TransportClientHandlerInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-0.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/TransportClientHandlerInterceptorTest.java @@ -51,7 +51,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -114,7 +113,7 @@ public void testConsumer() throws Throwable { TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertCombSpan(spans.get(0)); - verify(invocation, times(1)).getContext(); + verify(invocation).getContext(); } private void assertCombSpan(AbstractTracingSpan span) { diff --git a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/v1/ProducerOperationHandlerInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/v1/ProducerOperationHandlerInterceptorTest.java index 81495bb59c34..00ecffd24eaa 100644 --- a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/v1/ProducerOperationHandlerInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/v1/ProducerOperationHandlerInterceptorTest.java @@ -51,7 +51,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -119,7 +118,7 @@ public void testConsumer() throws Throwable { List spans = SegmentHelper.getSpans(traceSegment); assertCombSpan(spans.get(0)); - verify(invocation, times(1)).getContext(); + verify(invocation).getContext(); } private void assertCombSpan(AbstractTracingSpan span) { diff --git a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/v1/TransportClientHandlerInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/v1/TransportClientHandlerInterceptorTest.java index 3e7a3766311d..959ad367cd09 100644 --- a/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/v1/TransportClientHandlerInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/servicecomb-plugin/servicecomb-java-chassis-1.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/servicecomb/v1/TransportClientHandlerInterceptorTest.java @@ -51,7 +51,6 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -114,7 +113,7 @@ public void testConsumer() throws Throwable { TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0); List spans = SegmentHelper.getSpans(traceSegment); assertCombSpan(spans.get(0)); - verify(invocation, times(1)).getContext(); + verify(invocation).getContext(); } private void assertCombSpan(AbstractTracingSpan span) { diff --git a/apm-sniffer/apm-sdk-plugin/spymemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spymemcached/v2/MemcachedConstructorWithInetSocketAddressListArgInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/spymemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spymemcached/v2/MemcachedConstructorWithInetSocketAddressListArgInterceptorTest.java index 3c92ffc813ca..4d920d2736ba 100644 --- a/apm-sniffer/apm-sdk-plugin/spymemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spymemcached/v2/MemcachedConstructorWithInetSocketAddressListArgInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/spymemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spymemcached/v2/MemcachedConstructorWithInetSocketAddressListArgInterceptorTest.java @@ -29,7 +29,6 @@ import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @RunWith(MockitoJUnitRunner.class) @@ -52,6 +51,6 @@ public void onConstructWithInetSocketAddressList() { inetSocketAddressList.add(new InetSocketAddress("127.0.0.2", 11211)); interceptor.onConstruct(enhancedInstance, new Object[] {null, inetSocketAddressList}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:11211;127.0.0.2:11211"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:11211;127.0.0.2:11211"); } } diff --git a/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithComplexArgInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithComplexArgInterceptorTest.java index d09038da3d4c..a91af969da67 100644 --- a/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithComplexArgInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithComplexArgInterceptorTest.java @@ -19,7 +19,6 @@ package org.apache.skywalking.apm.plugin.xmemcached.v2; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.net.InetSocketAddress; @@ -52,6 +51,6 @@ public void onConstructWithComplex() { inetSocketAddressMap.put(new InetSocketAddress("127.0.0.1", 11211), new InetSocketAddress("127.0.0.2", 11211)); interceptor.onConstruct(enhancedInstance, new Object[]{null, null, null, null, null, null, inetSocketAddressMap}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:11211;127.0.0.2:11211"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:11211;127.0.0.2:11211"); } } diff --git a/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithHostPortArgInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithHostPortArgInterceptorTest.java index 179a450eb972..165746f37387 100644 --- a/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithHostPortArgInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithHostPortArgInterceptorTest.java @@ -19,7 +19,6 @@ package org.apache.skywalking.apm.plugin.xmemcached.v2; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; @@ -46,6 +45,6 @@ public void setUp() throws Exception { public void onConstructWithHostPort() { interceptor.onConstruct(enhancedInstance, new Object[]{"127.0.0.1", 11211}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:11211"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:11211"); } } diff --git a/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithInetSocketAddressArgInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithInetSocketAddressArgInterceptorTest.java index 1f715e67a461..ca658c057640 100644 --- a/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithInetSocketAddressArgInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithInetSocketAddressArgInterceptorTest.java @@ -19,7 +19,6 @@ package org.apache.skywalking.apm.plugin.xmemcached.v2; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.net.InetSocketAddress; @@ -48,6 +47,6 @@ public void setUp() throws Exception { public void onConstructWithInetSocketAddress() { interceptor.onConstruct(enhancedInstance, new Object[]{new InetSocketAddress("127.0.0.1", 11211)}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:11211"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:11211"); } } diff --git a/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithInetSocketAddressListArgInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithInetSocketAddressListArgInterceptorTest.java index 69df20c7a844..847cfc261700 100644 --- a/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithInetSocketAddressListArgInterceptorTest.java +++ b/apm-sniffer/apm-sdk-plugin/xmemcached-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/xmemcached/v2/XMemcachedConstructorWithInetSocketAddressListArgInterceptorTest.java @@ -19,7 +19,6 @@ package org.apache.skywalking.apm.plugin.xmemcached.v2; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.net.InetSocketAddress; @@ -53,6 +52,6 @@ public void onConstructWithInetSocketAddressList() { inetSocketAddressList.add(new InetSocketAddress("127.0.0.2", 11211)); interceptor.onConstruct(enhancedInstance, new Object[]{inetSocketAddressList}); - verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:11211;127.0.0.2:11211"); + verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:11211;127.0.0.2:11211"); } } From 37c92523d500ac30cafba0f962e2f2b701021743 Mon Sep 17 00:00:00 2001 From: SataQiu Date: Wed, 8 May 2019 15:08:37 +0800 Subject: [PATCH 14/24] add test cases for Base64 (#2630) --- .../apm/agent/core/base64/Base64Test.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/base64/Base64Test.java diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/base64/Base64Test.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/base64/Base64Test.java new file mode 100644 index 000000000000..b46176358a2c --- /dev/null +++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/base64/Base64Test.java @@ -0,0 +1,39 @@ +/* + * 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.apm.agent.core.base64; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +/** + * Created by SataQiu on 2019/5/8. + */ +public class Base64Test { + + @Test + public void testDecode2UTFString() { + assertEquals(Base64.decode2UTFString("U2t5V2Fsa2luZw=="), "SkyWalking"); + } + + @Test + public void testEncode() { + assertEquals(Base64.encode("SkyWalking"), "U2t5V2Fsa2luZw=="); + } +} From c46554a1aea5f65d7dc6aad60119b954398a60ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E7=8E=89=E6=A1=94?= <769213327@qq.com> Date: Thu, 9 May 2019 23:52:42 +0800 Subject: [PATCH 15/24] fix spring data redis usercase NPE (#2621) --- .../v5/AbstractRedisClientInterceptor.java | 57 +++++++++++++++ .../AbstractRedisClientInstrumentation.java | 70 +++++++++++++++++++ .../src/main/resources/skywalking-plugin.def | 1 + 3 files changed, 128 insertions(+) create mode 100644 apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/AbstractRedisClientInterceptor.java create mode 100644 apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/define/AbstractRedisClientInstrumentation.java diff --git a/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/AbstractRedisClientInterceptor.java b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/AbstractRedisClientInterceptor.java new file mode 100644 index 000000000000..e9f0fec8b91e --- /dev/null +++ b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/AbstractRedisClientInterceptor.java @@ -0,0 +1,57 @@ +/* + * 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.apm.plugin.lettuce.v5; + +import io.lettuce.core.AbstractRedisClient; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; + +import java.lang.reflect.Method; + +/** + * @author zhaoyuguang + */ +public class AbstractRedisClientInterceptor implements InstanceMethodsAroundInterceptor { + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + EnhancedInstance clientOptions = (EnhancedInstance) allArguments[0]; + if (clientOptions == null) { + return; + } + AbstractRedisClient client = (AbstractRedisClient) objInst; + if (client.getOptions() == null || ((EnhancedInstance) client.getOptions()).getSkyWalkingDynamicField() == null) { + return; + } + clientOptions.setSkyWalkingDynamicField(((EnhancedInstance) client.getOptions()).getSkyWalkingDynamicField()); + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Object ret) throws Throwable { + return ret; + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + } +} diff --git a/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/define/AbstractRedisClientInstrumentation.java b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/define/AbstractRedisClientInstrumentation.java new file mode 100644 index 000000000000..c461647a085c --- /dev/null +++ b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/define/AbstractRedisClientInstrumentation.java @@ -0,0 +1,70 @@ +/* + * 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.apm.plugin.lettuce.v5.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +/** + * @author zhaoyuguang + */ +public class AbstractRedisClientInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "io.lettuce.core.AbstractRedisClient"; + + private static final String ABSTRACT_REDIS_CLIENT_CONSTRUCTOR_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.lettuce.v5.AbstractRedisClientInterceptor"; + + @Override + protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named("setOptions").and(takesArgumentWithType(0, "io.lettuce.core.ClientOptions")); + } + + @Override public String getMethodsInterceptor() { + return ABSTRACT_REDIS_CLIENT_CONSTRUCTOR_INTERCEPTOR_CLASS; + } + + @Override public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + public ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } +} diff --git a/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/resources/skywalking-plugin.def index 95739fbbcd78..7ab687d0cbe3 100644 --- a/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/resources/skywalking-plugin.def +++ b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/resources/skywalking-plugin.def @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +lettuce-5.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.AbstractRedisClientInstrumentation lettuce-5.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.AsyncCommandInstrumentation lettuce-5.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.ClientOptionsInstrumentation lettuce-5.x=org.apache.skywalking.apm.plugin.lettuce.v5.define.RedisChannelWriterInstrumentation From ed78dabe8b142be3d546d349046768135f0a752a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E5=8B=87=E5=8D=87=20pengys?= Date: Fri, 10 May 2019 08:05:37 +0800 Subject: [PATCH 16/24] Rename metric and indicator to metrics. (#2643) * Rename metric to metrics. * Fixed test case execute failure issues. --- CHANGES.md | 12 +- README.md | 4 +- .../apm/agent/core/jvm/JVMService.java | 2 +- ...cAccessor.java => CPUMetricsAccessor.java} | 7 +- .../apm/agent/core/jvm/cpu/CPUProvider.java | 13 +- .../core/jvm/cpu/NoSupportedCPUAccessor.java | 2 +- .../agent/core/jvm/cpu/SunCpuAccessor.java | 2 +- ...or.java => MemoryPoolMetricsAccessor.java} | 7 +- .../core/jvm/memorypool/MemoryPoolModule.java | 11 +- .../jvm/memorypool/MemoryPoolProvider.java | 15 +- .../jvm/memorypool/UnknownMemoryPool.java | 4 +- docker/config/alarm-settings.yml | 14 +- docs/en/concepts-and-designs/README.md | 2 +- .../concepts-and-designs/backend-overview.md | 14 +- docs/en/concepts-and-designs/oal.md | 18 +- .../probe-introduction.md | 6 +- docs/en/concepts-and-designs/project-goals.md | 4 +- .../concepts-and-designs/scope-definitions.md | 16 +- .../service-mesh-probe.md | 6 +- docs/en/guides/README.md | 4 +- docs/en/guides/backend-oal-scripts.md | 4 +- docs/en/guides/inventory-extension.md | 2 +- docs/en/guides/source-extension.md | 6 +- docs/en/guides/storage-extention.md | 2 +- docs/en/protocols/README.md | 30 ++-- docs/en/protocols/Trace-Data-Protocol-v2.md | 6 +- docs/en/setup/backend/backend-alarm.md | 26 +-- docs/en/setup/backend/backend-receivers.md | 8 +- docs/en/setup/backend/backend-setup.md | 16 +- docs/en/setup/backend/backend-telemetry.md | 2 +- ...metric-exporter.md => metrics-exporter.md} | 12 +- .../backend/telemetry/mesh-mode-grafana.json | 2 +- .../backend/telemetry/trace-mode-grafana.json | 2 +- docs/en/setup/backend/trace-sampling.md | 2 +- docs/en/setup/backend/ttl.md | 4 +- docs/en/setup/istio/README.md | 4 +- .../exporter/provider/MetricFormatter.java | 4 +- .../exporter/provider/grpc/GRPCExporter.java | 40 ++--- .../provider/grpc/GRPCExporterTest.java | 14 +- ...cator.java => MockDoubleValueMetrics.java} | 4 +- ...ndicator.java => MockIntValueMetrics.java} | 4 +- ...dicator.java => MockLongValueMetrics.java} | 4 +- .../{MockIndicator.java => MockMetrics.java} | 14 +- .../org/apache/skywalking/oal/tool/Main.java | 2 +- .../oal/tool/output/DispatcherContext.java | 2 +- .../oal/tool/output/FileGenerator.java | 12 +- .../oal/tool/parser/AnalysisResult.java | 4 +- .../oal/tool/parser/DeepAnalysis.java | 21 ++- .../{Indicators.java => MetricsHolder.java} | 25 ++- .../oal/tool/parser/OALListener.java | 8 +- .../oal/tool/parser/OALScripts.java | 4 +- .../code-templates/DispatcherTemplate.ftl | 34 ++-- ...Implementor.ftl => MetricsImplementor.ftl} | 98 +++++------ .../oal/tool/output/FileGeneratorTest.java | 20 +-- .../oal/tool/parser/DeepAnalysisTest.java | 8 +- .../oal/tool/parser/ScriptParserTest.java | 20 +-- ...d.java => MetricsImplementorExpected.java} | 98 +++++------ .../ServiceDispatcherExpected.java | 14 +- .../src/test/resources/oal_test.oal | 14 +- .../src/main/resources/official_analysis.oal | 18 +- .../server/core/alarm/provider/AlarmCore.java | 30 ++-- .../alarm/provider/AlarmModuleProvider.java | 2 +- .../server/core/alarm/provider/AlarmRule.java | 2 +- ...orValueType.java => MetricsValueType.java} | 2 +- .../core/alarm/provider/NotifyHandler.java | 20 +-- .../core/alarm/provider/RulesReader.java | 8 +- .../core/alarm/provider/RunningRule.java | 66 ++++--- .../server/core/alarm/provider/Threshold.java | 4 +- .../provider/AlarmMessageFormatterTest.java | 4 +- .../alarm/provider/NotifyHandlerTest.java | 72 +++----- .../core/alarm/provider/RunningRuleTest.java | 60 +++---- .../core/alarm/provider/ThresholdTest.java | 8 +- .../src/test/resources/alarm-settings.yml | 12 +- .../NamespacedPodListWatchTest.java | 166 ------------------ .../oap/server/core/CoreModuleProvider.java | 4 +- .../oap/server/core/alarm/AlarmEntrance.java | 12 +- .../oap/server/core/alarm/AlarmModule.java | 2 +- .../core/alarm/EndpointMetaInAlarm.java | 2 +- .../oap/server/core/alarm/MetaInAlarm.java | 2 +- ...ndicatorNotify.java => MetricsNotify.java} | 8 +- .../alarm/ServiceInstanceMetaInAlarm.java | 6 +- .../server/core/alarm/ServiceMetaInAlarm.java | 6 +- .../core/analysis/data/MergeDataCache.java | 14 +- .../EndpointCallRelationDispatcher.java | 16 +- ...=> EndpointRelationServerSideMetrics.java} | 90 +++++----- .../ServiceCallRelationDispatcher.java | 30 ++-- ... => ServiceRelationClientSideMetrics.java} | 90 +++++----- ... => ServiceRelationServerSideMetrics.java} | 90 +++++----- .../CPMMetrics.java} | 14 +- .../CountMetrics.java} | 14 +- .../DoubleAvgMetrics.java} | 14 +- .../DoubleValueHolder.java | 2 +- .../IntKeyLongValue.java | 2 +- .../IntKeyLongValueArray.java | 2 +- .../IntValueHolder.java | 2 +- .../LongAvgMetrics.java} | 14 +- .../LongValueHolder.java | 2 +- .../MaxDoubleMetrics.java} | 14 +- .../MaxLongMetrics.java} | 14 +- .../Indicator.java => metrics/Metrics.java} | 12 +- .../MetricsMetaInfo.java} | 18 +- .../P50Metrics.java} | 10 +- .../P75Metrics.java} | 10 +- .../P90Metrics.java} | 10 +- .../P95Metrics.java} | 10 +- .../P99Metrics.java} | 10 +- .../PercentMetrics.java} | 16 +- .../PxxMetrics.java} | 18 +- .../SumMetrics.java} | 14 +- .../ThermodynamicMetrics.java} | 28 ++- .../{indicator => metrics}/WithMetadata.java | 6 +- .../annotation/Arg.java | 2 +- .../annotation/ConstOne.java | 2 +- .../annotation/Entrance.java | 2 +- .../annotation/Expression.java | 2 +- .../annotation/ExpressionArg0.java | 2 +- .../annotation/ExpressionArg1.java | 2 +- .../annotation/MetricsAnnotationUtils.java} | 8 +- .../annotation/MetricsFunction.java} | 6 +- .../annotation/MetricsType.java} | 4 +- .../annotation/MetricsTypeListener.java} | 12 +- .../annotation/SourceFrom.java | 2 +- .../expression/BinaryMatchExpression.java | 2 +- .../expression/EqualMatch.java | 2 +- .../expression/GreaterEqualMatch.java | 2 +- .../expression/GreaterMatch.java | 2 +- .../expression/LessEqualMatch.java | 2 +- .../expression/LessMatch.java | 2 +- .../analysis/worker/AlarmNotifyWorker.java | 10 +- .../core/analysis/worker/ExportWorker.java | 10 +- .../analysis/worker/IndicatorProcess.java | 95 ---------- .../analysis/worker/IndicatorTransWorker.java | 91 ---------- ...orker.java => MetricsAggregateWorker.java} | 66 +++---- ...rker.java => MetricsPersistentWorker.java} | 80 ++++----- .../core/analysis/worker/MetricsProcess.java | 95 ++++++++++ ...teWorker.java => MetricsRemoteWorker.java} | 14 +- .../analysis/worker/MetricsTransWorker.java | 91 ++++++++++ .../exporter/MetricValuesExportService.java | 6 +- .../server/core/query/MetricQueryService.java | 12 +- .../worker/RegisterPersistentWorker.java | 8 +- .../register/worker/RegisterRemoteWorker.java | 4 +- .../core/remote/RemoteServiceHandler.java | 20 +-- .../core/remote/client/GRPCRemoteClient.java | 12 +- .../remote/client/RemoteClientManager.java | 6 +- .../core/remote/client/SelfRemoteClient.java | 6 +- .../core/source/DefaultScopeDefine.java | 4 +- .../core/source/EnvoyInstanceMetric.java | 4 +- .../{IIndicatorDAO.java => IMetricsDAO.java} | 10 +- .../server/core/storage/PersistenceTimer.java | 26 +-- .../oap/server/core/storage/StorageDAO.java | 4 +- .../server/core/storage/StorageModule.java | 2 +- .../annotation/StorageAnnotationListener.java | 6 +- .../oap/server/core/storage/model/Model.java | 8 +- .../core/storage/model/ModelInstaller.java | 2 +- ...ricQueryDAO.java => IMetricsQueryDAO.java} | 2 +- .../core/storage/ttl/DataTTLKeeperTimer.java | 12 +- .../analysis/indicator/PxxIndicatorTest.java | 130 -------------- .../indicator/ThermodynamicIndicatorTest.java | 123 ------------- .../CountMetricsTest.java} | 18 +- .../LongAvgMetricsTest.java} | 18 +- .../MaxLongMetricsTest.java} | 18 +- .../MetricsTest.java} | 24 +-- .../PercentMetricsTest.java} | 22 +-- .../core/analysis/metrics/PxxMetricsTest.java | 129 ++++++++++++++ .../metrics/ThermodynamicMetricsTest.java | 123 +++++++++++++ .../remote/RemoteServiceHandlerTestCase.java | 10 +- .../client/GRPCRemoteClientRealClient.java | 6 +- .../client/GRPCRemoteClientTestCase.java | 6 +- .../client/RemoteClientManagerTestCase.java | 6 +- .../src/test/resources/application.yml | 2 +- .../query/graphql/resolver/MetricQuery.java | 14 +- .../envoy/EnvoyMetricReceiverModule.java | 4 +- .../envoy/MetricServiceGRPCHandler.java | 26 +-- .../src/test/resources/envoy-metric.msg | 10 +- .../CLRMetricReportServiceHandler.java | 8 +- .../provider/handler/CLRSourceDispatcher.java | 8 +- .../provider/IstioTelemetryGRPCHandler.java | 22 +-- .../JVMMetricReportServiceHandler.java | 8 +- .../handler/JVMMetricsServiceHandler.java | 8 +- .../provider/handler/JVMSourceDispatcher.java | 10 +- .../mesh/MeshDataBufferFileCache.java | 24 +-- .../server/receiver/mesh/MeshGRPCHandler.java | 16 +- .../mesh/TelemetryDataDispatcher.java | 160 ++++++++--------- .../provider/TraceServiceModuleConfig.java | 2 +- .../TraceSegmentReportServiceHandler.java | 10 +- .../trace/provider/parser/SegmentParse.java | 20 +-- .../trace/provider/parser/SegmentParseV2.java | 20 +-- .../SegmentStandardizationWorker.java | 8 +- .../main/assembly/alarm-settings-sample.yml | 12 +- .../src/main/assembly/alarm-settings.yml | 20 +-- .../src/main/assembly/application.yml | 4 +- .../oap/server/starter/OAPServerStartUp.java | 4 +- .../src/main/resources/alarm-settings.yml | 12 +- .../src/main/resources/application.yml | 4 +- .../StorageModuleElasticsearchProvider.java | 6 +- .../base/ColumnTypeEsMapping.java | 2 +- .../plugin/elasticsearch/base/EsDAO.java | 4 +- ...{IndicatorEsDAO.java => MetricsEsDAO.java} | 26 +-- .../elasticsearch/base/StorageEsDAO.java | 6 +- .../query/AggregationQueryEsDAO.java | 18 +- ...QueryEsDAO.java => MetricsQueryEsDAO.java} | 18 +- .../query/TopologyQueryEsDAO.java | 42 ++--- .../plugin/jdbc/h2/H2StorageProvider.java | 6 +- .../jdbc/h2/dao/H2AggregationQueryDAO.java | 10 +- ...{H2IndicatorDAO.java => H2MetricsDAO.java} | 22 +-- ...icQueryDAO.java => H2MetricsQueryDAO.java} | 24 ++- .../plugin/jdbc/h2/dao/H2SQLExecutor.java | 12 +- .../plugin/jdbc/h2/dao/H2StorageDAO.java | 8 +- .../plugin/jdbc/h2/dao/H2TableInstaller.java | 2 +- .../jdbc/h2/dao/H2TopologyQueryDAO.java | 44 ++--- .../jdbc/mysql/MySQLAggregationQueryDAO.java | 10 +- .../jdbc/mysql/MySQLStorageProvider.java | 6 +- .../jdbc/mysql/MySQLTableInstaller.java | 6 +- .../oap/server/telemetry/TelemetryModule.java | 4 +- ...CounterMetric.java => CounterMetrics.java} | 4 +- .../{GaugeMetric.java => GaugeMetrics.java} | 4 +- ...ogramMetric.java => HistogramMetrics.java} | 10 +- ...MetricCreator.java => MetricsCreator.java} | 16 +- .../api/{MetricTag.java => MetricsTag.java} | 4 +- .../api/TelemetryRelatedContext.java | 2 +- ...eatorNoop.java => MetricsCreatorNoop.java} | 18 +- .../telemetry/none/NoneTelemetryProvider.java | 4 +- .../{BaseMetric.java => BaseMetrics.java} | 24 +-- ...ric.java => PrometheusCounterMetrics.java} | 20 +-- ...etric.java => PrometheusGaugeMetrics.java} | 40 ++--- ...c.java => PrometheusHistogramMetrics.java} | 20 +-- ...tor.java => PrometheusMetricsCreator.java} | 18 +- .../PrometheusTelemetryProvider.java | 4 +- 228 files changed, 1973 insertions(+), 2183 deletions(-) rename apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/{CPUMetricAccessor.java => CPUMetricsAccessor.java} (89%) rename apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/{MemoryPoolMetricAccessor.java => MemoryPoolMetricsAccessor.java} (85%) rename docs/en/setup/backend/{metric-exporter.md => metrics-exporter.md} (75%) rename oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/{MockDoubleValueIndicator.java => MockDoubleValueMetrics.java} (85%) rename oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/{MockIntValueIndicator.java => MockIntValueMetrics.java} (85%) rename oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/{MockLongValueIndicator.java => MockLongValueMetrics.java} (85%) rename oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/{MockIndicator.java => MockMetrics.java} (83%) rename oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/{Indicators.java => MetricsHolder.java} (56%) rename oap-server/generate-tool/src/main/resources/code-templates/{IndicatorImplementor.ftl => MetricsImplementor.ftl} (72%) rename oap-server/generate-tool/src/test/resources/expectedFiles/{IndicatorImplementorExpected.java => MetricsImplementorExpected.java} (59%) rename oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/{IndicatorValueType.java => MetricsValueType.java} (96%) delete mode 100644 oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/dependencies/NamespacedPodListWatchTest.java rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/{IndicatorNotify.java => MetricsNotify.java} (81%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/{EndpointRelationServerSideIndicator.java => EndpointRelationServerSideMetrics.java} (62%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/{ServiceRelationClientSideIndicator.java => ServiceRelationClientSideMetrics.java} (62%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/{ServiceRelationServerSideIndicator.java => ServiceRelationServerSideMetrics.java} (63%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/CPMIndicator.java => metrics/CPMMetrics.java} (77%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/CountIndicator.java => metrics/CountMetrics.java} (74%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/DoubleAvgIndicator.java => metrics/DoubleAvgMetrics.java} (78%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/DoubleValueHolder.java (93%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/IntKeyLongValue.java (97%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/IntKeyLongValueArray.java (97%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/IntValueHolder.java (93%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/LongAvgIndicator.java => metrics/LongAvgMetrics.java} (78%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/LongValueHolder.java (93%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/MaxDoubleIndicator.java => metrics/MaxDoubleMetrics.java} (73%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/MaxLongIndicator.java => metrics/MaxLongMetrics.java} (74%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/Indicator.java => metrics/Metrics.java} (91%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/IndicatorMetaInfo.java => metrics/MetricsMetaInfo.java} (72%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/P50Indicator.java => metrics/P50Metrics.java} (75%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/P75Indicator.java => metrics/P75Metrics.java} (75%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/P90Indicator.java => metrics/P90Metrics.java} (75%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/P95Indicator.java => metrics/P95Metrics.java} (75%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/P99Indicator.java => metrics/P99Metrics.java} (75%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/PercentIndicator.java => metrics/PercentMetrics.java} (78%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/PxxIndicator.java => metrics/PxxMetrics.java} (86%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/SumIndicator.java => metrics/SumMetrics.java} (75%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/ThermodynamicIndicator.java => metrics/ThermodynamicMetrics.java} (81%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/WithMetadata.java (82%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/annotation/Arg.java (93%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/annotation/ConstOne.java (92%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/annotation/Entrance.java (92%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/annotation/Expression.java (93%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/annotation/ExpressionArg0.java (93%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/annotation/ExpressionArg1.java (93%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/annotation/IndicatorAnnotationUtils.java => metrics/annotation/MetricsAnnotationUtils.java} (78%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/annotation/IndicatorFunction.java => metrics/annotation/MetricsFunction.java} (83%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/annotation/IndicatorType.java => metrics/annotation/MetricsType.java} (89%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator/annotation/IndicatorTypeListener.java => metrics/annotation/MetricsTypeListener.java} (76%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/annotation/SourceFrom.java (92%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/expression/BinaryMatchExpression.java (94%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/expression/EqualMatch.java (92%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/expression/GreaterEqualMatch.java (94%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/expression/GreaterMatch.java (94%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/expression/LessEqualMatch.java (94%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/{indicator => metrics}/expression/LessMatch.java (94%) delete mode 100644 oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorProcess.java delete mode 100644 oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorTransWorker.java rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/{IndicatorAggregateWorker.java => MetricsAggregateWorker.java} (63%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/{IndicatorPersistentWorker.java => MetricsPersistentWorker.java} (62%) create mode 100644 oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsProcess.java rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/{IndicatorRemoteWorker.java => MetricsRemoteWorker.java} (78%) create mode 100644 oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsTransWorker.java rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/{IIndicatorDAO.java => IMetricsDAO.java} (70%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/{IMetricQueryDAO.java => IMetricsQueryDAO.java} (96%) delete mode 100644 oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicatorTest.java delete mode 100644 oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/ThermodynamicIndicatorTest.java rename oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/{indicator/CountIndicatorTest.java => metrics/CountMetricsTest.java} (80%) rename oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/{indicator/LongAvgIndicatorTest.java => metrics/LongAvgMetricsTest.java} (79%) rename oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/{indicator/MaxLongIndicatorTest.java => metrics/MaxLongMetricsTest.java} (78%) rename oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/{indicator/IndicatorTest.java => metrics/MetricsTest.java} (83%) rename oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/{indicator/PercentIndicatorTest.java => metrics/PercentMetricsTest.java} (79%) create mode 100644 oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PxxMetricsTest.java create mode 100644 oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/ThermodynamicMetricsTest.java rename oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/{IndicatorEsDAO.java => MetricsEsDAO.java} (77%) rename oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/{MetricQueryEsDAO.java => MetricsQueryEsDAO.java} (91%) rename oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/{H2IndicatorDAO.java => H2MetricsDAO.java} (63%) rename oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/{H2MetricQueryDAO.java => H2MetricsQueryDAO.java} (90%) rename oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/{CounterMetric.java => CounterMetrics.java} (89%) rename oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/{GaugeMetric.java => GaugeMetrics.java} (91%) rename oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/{HistogramMetric.java => HistogramMetrics.java} (89%) rename oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/{MetricCreator.java => MetricsCreator.java} (66%) rename oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/{MetricTag.java => MetricsTag.java} (96%) rename oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/{MetricCreatorNoop.java => MetricsCreatorNoop.java} (71%) rename oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/{BaseMetric.java => BaseMetrics.java} (82%) rename oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/{PrometheusCounterMetric.java => PrometheusCounterMetrics.java} (72%) rename oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/{PrometheusGaugeMetric.java => PrometheusGaugeMetrics.java} (64%) rename oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/{PrometheusHistogramMetric.java => PrometheusHistogramMetrics.java} (76%) rename oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/{PrometheusMetricCreator.java => PrometheusMetricsCreator.java} (57%) diff --git a/CHANGES.md b/CHANGES.md index 031ca79d476d..bee3f1fa98f3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -32,7 +32,7 @@ Release Notes. **Performance improved, especially in CPU limited environment. 3x improvement in service mesh scenario(no trace) in 8C16G VM. Significantly cost less CPU in low payload.** -- Support database metric and SLOW SQL detection. +- Support database metrics and SLOW SQL detection. - Support to set max size of metadata query. And change default to 5000 from 100. - Support ElasticSearch template for new feature in the future. - Support shutdown Zipkin trace analysis, because it doesn't fit production environment. @@ -42,10 +42,10 @@ Significantly cost less CPU in low payload.** - Support group endpoint name by regax rules in mesh receiver. - Support `disable` statement in OAL. - Support basic auth in ElasticSearch connection. -- Support metric exporter module and gRPC implementor. +- Support metrics exporter module and gRPC implementor. - Support `>, <, >=, <=` in OAL. - Support role mode in backend. -- Support Envoy metric. +- Support Envoy metrics. - Support query segment by service instance. - Support to set host/port manually at cluster coordinator, rather than based on core settings. - Make sure OAP shutdown when it faces startup error. @@ -62,7 +62,7 @@ Significantly cost less CPU in low payload.** #### UI - RocketBot UI has been accepted and bind in this release. -- Support CLR metric. +- Support CLR metrics. #### Document - Documents updated, matching Top Level Project requirement. @@ -183,10 +183,10 @@ The core and most important features in v6 are 1. Support to collect telemetry data from different sources, such as multiple language agents and service mesh. 1. Extensible stream analysis core. Make SQL and cache analysis available in core level, although haven't provided in this release. -1. Provide **Observability Analysis Language(OAL)** to make analysis metric customization available. +1. Provide **Observability Analysis Language(OAL)** to make analysis metrics customization available. 1. New GraphQL query protocol. Not binding with UI now. 1. UI topology is better now. -1. New alarm core provided. In alpha, only on service related metric. +1. New alarm core provided. In alpha, only on service related metrics. All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/29?closed=1) diff --git a/README.md b/README.md index b7b7e2e57efc..fc8f1c320194 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ The core features are following. - Slow services and endpoints detected - Performance optimization - Distributed tracing and context propagation -- Database access metric. Detect slow database access statements(including SQL statements). +- Database access metrics. Detect slow database access statements(including SQL statements). - Alarm @@ -38,7 +38,7 @@ including 1. Istio telemetry format 1. Zipkin v1/v2 format 1. Jaeger gRPC format. -1. Envoy metrics format (the metric entries itself is prometheus client [metric family](https://github.com/prometheus/client_model/blob/fd36f4220a901265f90734c3183c5f0c91daa0b8/metrics.proto#L77)) +1. Envoy metrics format (the metrics entries itself is prometheus client [metrics family](https://github.com/prometheus/client_model/blob/fd36f4220a901265f90734c3183c5f0c91daa0b8/metrics.proto#L77)) # Document diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java index d5f1032aa004..791375f56381 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/JVMService.java @@ -107,7 +107,7 @@ public void run() { jvmBuilder.setTime(currentTimeMillis); jvmBuilder.setCpu(CPUProvider.INSTANCE.getCpuMetric()); jvmBuilder.addAllMemory(MemoryProvider.INSTANCE.getMemoryMetricList()); - jvmBuilder.addAllMemoryPool(MemoryPoolProvider.INSTANCE.getMemoryPoolMetricList()); + jvmBuilder.addAllMemoryPool(MemoryPoolProvider.INSTANCE.getMemoryPoolMetricsList()); jvmBuilder.addAllGc(GCProvider.INSTANCE.getGCList()); JVMMetric jvmMetric = jvmBuilder.build(); diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricAccessor.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricsAccessor.java similarity index 89% rename from apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricAccessor.java rename to apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricsAccessor.java index 9b6d345614e8..174d209b5d31 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricAccessor.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricsAccessor.java @@ -20,17 +20,16 @@ package org.apache.skywalking.apm.agent.core.jvm.cpu; import org.apache.skywalking.apm.network.common.CPU; -import org.apache.skywalking.apm.network.language.agent.*; /** * @author wusheng */ -public abstract class CPUMetricAccessor { +public abstract class CPUMetricsAccessor { private long lastCPUTimeNs; private long lastSampleTimeNs; private final int cpuCoreNum; - public CPUMetricAccessor(int cpuCoreNum) { + public CPUMetricsAccessor(int cpuCoreNum) { this.cpuCoreNum = cpuCoreNum; } @@ -41,7 +40,7 @@ protected void init() { protected abstract long getCpuTime(); - public CPU getCPUMetric() { + public CPU getCPUMetrics() { long cpuTime = this.getCpuTime(); long cpuCost = cpuTime - lastCPUTimeNs; long now = System.nanoTime(); diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUProvider.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUProvider.java index bb9422daf5d1..b906fbcd7431 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUProvider.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUProvider.java @@ -23,29 +23,28 @@ import org.apache.skywalking.apm.agent.core.logging.api.LogManager; import org.apache.skywalking.apm.agent.core.os.ProcessorUtil; import org.apache.skywalking.apm.network.common.CPU; -import org.apache.skywalking.apm.network.language.agent.*; /** * @author wusheng */ public enum CPUProvider { INSTANCE; - private CPUMetricAccessor cpuMetricAccessor; + private CPUMetricsAccessor cpuMetricsAccessor; CPUProvider() { int processorNum = ProcessorUtil.getNumberOfProcessors(); try { - this.cpuMetricAccessor = - (CPUMetricAccessor)CPUProvider.class.getClassLoader().loadClass("org.apache.skywalking.apm.agent.core.jvm.cpu.SunCpuAccessor") + this.cpuMetricsAccessor = + (CPUMetricsAccessor)CPUProvider.class.getClassLoader().loadClass("org.apache.skywalking.apm.agent.core.jvm.cpu.SunCpuAccessor") .getConstructor(int.class).newInstance(processorNum); } catch (Exception e) { - this.cpuMetricAccessor = new NoSupportedCPUAccessor(processorNum); + this.cpuMetricsAccessor = new NoSupportedCPUAccessor(processorNum); ILog logger = LogManager.getLogger(CPUProvider.class); - logger.error(e, "Only support accessing CPU metric in SUN JVM platform."); + logger.error(e, "Only support accessing CPU metrics in SUN JVM platform."); } } public CPU getCpuMetric() { - return cpuMetricAccessor.getCPUMetric(); + return cpuMetricsAccessor.getCPUMetrics(); } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/NoSupportedCPUAccessor.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/NoSupportedCPUAccessor.java index 341e4d15e9e6..c2865cfa1238 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/NoSupportedCPUAccessor.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/NoSupportedCPUAccessor.java @@ -22,7 +22,7 @@ /** * @author wusheng */ -public class NoSupportedCPUAccessor extends CPUMetricAccessor { +public class NoSupportedCPUAccessor extends CPUMetricsAccessor { public NoSupportedCPUAccessor(int cpuCoreNum) { super(cpuCoreNum); } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/SunCpuAccessor.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/SunCpuAccessor.java index 2a68fae42428..f46300f5ba2e 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/SunCpuAccessor.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/SunCpuAccessor.java @@ -25,7 +25,7 @@ /** * @author wusheng */ -public class SunCpuAccessor extends CPUMetricAccessor { +public class SunCpuAccessor extends CPUMetricsAccessor { private final OperatingSystemMXBean osMBean; public SunCpuAccessor(int cpuCoreNum) { diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolMetricAccessor.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolMetricsAccessor.java similarity index 85% rename from apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolMetricAccessor.java rename to apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolMetricsAccessor.java index 9734ce922b36..7a38f1078e83 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolMetricAccessor.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolMetricsAccessor.java @@ -16,15 +16,14 @@ * */ - package org.apache.skywalking.apm.agent.core.jvm.memorypool; import java.util.List; -import org.apache.skywalking.apm.network.language.agent.*; +import org.apache.skywalking.apm.network.language.agent.MemoryPool; /** * @author wusheng */ -public interface MemoryPoolMetricAccessor { - List getMemoryPoolMetricList(); +public interface MemoryPoolMetricsAccessor { + List getMemoryPoolMetricsList(); } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolModule.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolModule.java index 36a7617f4644..3ab0291c1fc0 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolModule.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolModule.java @@ -16,19 +16,16 @@ * */ - package org.apache.skywalking.apm.agent.core.jvm.memorypool; -import java.lang.management.MemoryPoolMXBean; -import java.lang.management.MemoryUsage; -import java.util.LinkedList; -import java.util.List; +import java.lang.management.*; +import java.util.*; import org.apache.skywalking.apm.network.language.agent.*; /** * @author wusheng */ -public abstract class MemoryPoolModule implements MemoryPoolMetricAccessor { +public abstract class MemoryPoolModule implements MemoryPoolMetricsAccessor { private List beans; public MemoryPoolModule(List beans) { @@ -36,7 +33,7 @@ public MemoryPoolModule(List beans) { } @Override - public List getMemoryPoolMetricList() { + public List getMemoryPoolMetricsList() { List poolList = new LinkedList(); for (MemoryPoolMXBean bean : beans) { String name = bean.getName(); diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolProvider.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolProvider.java index 4dc2962064d1..d85c478536b3 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolProvider.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/MemoryPoolProvider.java @@ -19,10 +19,9 @@ package org.apache.skywalking.apm.agent.core.jvm.memorypool; -import java.lang.management.ManagementFactory; -import java.lang.management.MemoryPoolMXBean; +import java.lang.management.*; import java.util.List; -import org.apache.skywalking.apm.network.language.agent.*; +import org.apache.skywalking.apm.network.language.agent.MemoryPool; /** * @author wusheng @@ -30,14 +29,14 @@ public enum MemoryPoolProvider { INSTANCE; - private MemoryPoolMetricAccessor metricAccessor; + private MemoryPoolMetricsAccessor metricAccessor; private List beans; MemoryPoolProvider() { beans = ManagementFactory.getMemoryPoolMXBeans(); for (MemoryPoolMXBean bean : beans) { String name = bean.getName(); - MemoryPoolMetricAccessor accessor = findByBeanName(name); + MemoryPoolMetricsAccessor accessor = findByBeanName(name); if (accessor != null) { metricAccessor = accessor; break; @@ -48,11 +47,11 @@ public enum MemoryPoolProvider { } } - public List getMemoryPoolMetricList() { - return metricAccessor.getMemoryPoolMetricList(); + public List getMemoryPoolMetricsList() { + return metricAccessor.getMemoryPoolMetricsList(); } - private MemoryPoolMetricAccessor findByBeanName(String name) { + private MemoryPoolMetricsAccessor findByBeanName(String name) { if (name.indexOf("PS") > -1) { //Parallel (Old) collector ( -XX:+UseParallelOldGC ) return new ParallelCollectorModule(beans); diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/UnknownMemoryPool.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/UnknownMemoryPool.java index 3b9bbf8e88a0..32428fb6613a 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/UnknownMemoryPool.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/memorypool/UnknownMemoryPool.java @@ -26,9 +26,9 @@ /** * @author wusheng */ -public class UnknownMemoryPool implements MemoryPoolMetricAccessor { +public class UnknownMemoryPool implements MemoryPoolMetricsAccessor { @Override - public List getMemoryPoolMetricList() { + public List getMemoryPoolMetricsList() { List poolList = new LinkedList(); poolList.add(MemoryPool.newBuilder().setType(PoolType.CODE_CACHE_USAGE).build()); poolList.add(MemoryPool.newBuilder().setType(PoolType.NEWGEN_USAGE).build()); diff --git a/docker/config/alarm-settings.yml b/docker/config/alarm-settings.yml index abb38b7e148e..829246aefae3 100644 --- a/docker/config/alarm-settings.yml +++ b/docker/config/alarm-settings.yml @@ -18,7 +18,7 @@ rules: # Rule unique name, must be ended with `_rule`. service_resp_time_rule: - indicator-name: service_resp_time + metrics-name: service_resp_time op: ">" threshold: 1000 period: 10 @@ -26,8 +26,8 @@ rules: silence-period: 5 message: Response time of service {name} is more than 1000ms in last 3 minutes. service_sla_rule: - # Indicator value need to be long, double or int - indicator-name: service_sla + # Metrics value need to be long, double or int + metrics-name: service_sla op: "<" threshold: 8000 # The length of time to evaluate the metric @@ -38,8 +38,8 @@ rules: silence-period: 3 message: Successful rate of service {name} is lower than 80% in last 2 minutes. service_p90_sla_rule: - # Indicator value need to be long, double or int - indicator-name: service_p90 + # Metrics value need to be long, double or int + metrics-name: service_p90 op: ">" threshold: 1000 period: 10 @@ -47,7 +47,7 @@ rules: silence-period: 5 message: 90% response time of service {name} is more than 1000ms in last 3 minutes service_instance_resp_time_rule: - indicator-name: service_instance_resp_time + metrics-name: service_instance_resp_time op: ">" threshold: 1000 period: 10 @@ -58,7 +58,7 @@ rules: # Because the number of endpoint is much more than service and instance. # # endpoint_avg_rule: -# indicator-name: endpoint_avg +# metrics-name: endpoint_avg # op: ">" # threshold: 1000 # period: 10 diff --git a/docs/en/concepts-and-designs/README.md b/docs/en/concepts-and-designs/README.md index 271e20ccc57d..86f6c66792f4 100644 --- a/docs/en/concepts-and-designs/README.md +++ b/docs/en/concepts-and-designs/README.md @@ -18,6 +18,6 @@ SkyWalking already support. - Backend - [Overview](backend-overview.md). Provides a high level introduction about the OAP backend. - [Observability Analysis Language](oal.md). Introduces the core languages, which is designed for aggregation behaviour definition. - - [Query in OAP](../protocols/README.md#query-protocol). A set of query protocol provided, based on the Observability Analysis Language metric definition. + - [Query in OAP](../protocols/README.md#query-protocol). A set of query protocol provided, based on the Observability Analysis Language metrics definition. - UI - [Overview](ui-overview.md). A simple brief about SkyWalking UI. diff --git a/docs/en/concepts-and-designs/backend-overview.md b/docs/en/concepts-and-designs/backend-overview.md index 658099f1b041..2e4b6cb777e1 100644 --- a/docs/en/concepts-and-designs/backend-overview.md +++ b/docs/en/concepts-and-designs/backend-overview.md @@ -3,11 +3,11 @@ OAP(Observability Analysis Platform) is a new concept, which starts in SkyWalkin old SkyWalking whole backend. The capabilities of the platform are following. ## OAP capabilities -OAP accepts data from more sources, which belongs two groups: **Tracing** and **Metric**. +OAP accepts data from more sources, which belongs two groups: **Tracing** and **Metrics**. - **Tracing**. Including, SkyWalking native data formats. Zipkin v1,v2 data formats and Jaeger data formats. -- **Metric**. SkyWalking integrates with Service Mesh platforms, such as Istio, Envoy, Linkerd, to provide observability from data panel -or control panel. Also, SkyWalking native agents can run in metric mode, which highly improve the +- **Metrics**. SkyWalking integrates with Service Mesh platforms, such as Istio, Envoy, Linkerd, to provide observability from data panel +or control panel. Also, SkyWalking native agents can run in metrics mode, which highly improve the performance. At the same time by using any integration solution provided, such as SkyWalking log plugin or toolkits, @@ -19,16 +19,16 @@ As usual, all services provided by gRPC and HTTP protocol to make integration ea ## Tracing in OAP Tracing in OAP has two ways to process. 1. Traditional way in SkyWalking 5 series. Format tracing data in SkyWalking trace segment and span formats, -even for Zipkin data format. The OAP analysis the segments to get metrics, and push the metric data into +even for Zipkin data format. The OAP analysis the segments to get metrics, and push the metrics data into the streaming aggregation. 1. Consider tracing as some kinds of logging only. Just provide save and visualization capabilities for trace. Also, SkyWalking accepts trace formats from other project, such as Zipkin, Jeager, OpenCensus. These formats could be processed in the two ways too. -## Metric in OAP -Metric in OAP is totally new feature in 6 series. Build observability for a distributed system based on metric of connected nodes. +## Metrics in OAP +Metrics in OAP is totally new feature in 6 series. Build observability for a distributed system based on metrics of connected nodes. No tracing data is required. -Metric data are aggregated inside OAP cluster in streaming mode. See about [Observability Analysis Language](oal.md), +Metrics data are aggregated inside OAP cluster in streaming mode. See about [Observability Analysis Language](oal.md), which provides the easy way to do aggregation and analysis in script style. \ No newline at end of file diff --git a/docs/en/concepts-and-designs/oal.md b/docs/en/concepts-and-designs/oal.md index cf149163911e..5a89269d1a1f 100644 --- a/docs/en/concepts-and-designs/oal.md +++ b/docs/en/concepts-and-designs/oal.md @@ -1,7 +1,7 @@ # Observability Analysis Language Provide OAL(Observability Analysis Language) to analysis incoming data in streaming mode. -OAL focuses on metric in Service, Service Instance and Endpoint. Because of that, the language is easy to +OAL focuses on metrics in Service, Service Instance and Endpoint. Because of that, the language is easy to learn and use. Considering performance, reading and debugging, OAL is defined as a compile language. @@ -10,13 +10,13 @@ The OAL scripts will be compiled to normal Java codes in package stage. ## Grammar Scripts should be named as `*.oal` ``` -// Declare the metric. -METRIC_NAME = from(SCOPE.(* | [FIELD][,FIELD ...])) +// Declare the metrics. +METRICS_NAME = from(SCOPE.(* | [FIELD][,FIELD ...])) [.filter(FIELD OP [INT | STRING])] .FUNCTION([PARAM][, PARAM ...]) // Disable hard code -disable(METRIC_NAME); +disable(METRICS_NAME); ``` ## Scope @@ -62,17 +62,17 @@ In this case, p99 value of all incoming requests. In this case, thermodynamic heatmap of all incoming requests. -## Metric name -The metric name for storage implementor, alarm and query modules. The type inference supported by core. +## Metrics name +The metrics name for storage implementor, alarm and query modules. The type inference supported by core. ## Group -All metric data will be grouped by Scope.ID and min-level TimeBucket. +All metrics data will be grouped by Scope.ID and min-level TimeBucket. - In `Endpoint` scope, the Scope.ID = Endpoint id (the unique id based on service and its Endpoint) ## Disable `Disable` is an advanced statement in OAL, which is only used in certain case. -Some of the aggregation and metric are defined through core hard codes, +Some of the aggregation and metrics are defined through core hard codes, this `disable` statement is designed for make them de-active, such as `segment`, `top_n_database_statement`. In default, no one is being disable. @@ -89,7 +89,7 @@ serv_Endpoint_p99 = from(Endpoint.latency).filter(name like ("serv%")).summary(0 Endpoint_avg = from(Endpoint.latency).avg() // Caculate the histogram of each Endpoint by 50 ms steps. -// Always thermodynamic diagram in UI matches this metric. +// Always thermodynamic diagram in UI matches this metrics. Endpoint_histogram = from(Endpoint.latency).histogram(50) // Caculate the percent of response status is true, for each service. diff --git a/docs/en/concepts-and-designs/probe-introduction.md b/docs/en/concepts-and-designs/probe-introduction.md index 29fe205dcad3..7e4ed470807d 100644 --- a/docs/en/concepts-and-designs/probe-introduction.md +++ b/docs/en/concepts-and-designs/probe-introduction.md @@ -1,6 +1,6 @@ # Probe Introduction In SkyWalking, probe means an agent or SDK library integrated into target system, which take charge of -collecting telemetry data including tracing and metric. Based on the target system tech stack, probe could use very different +collecting telemetry data including tracing and metrics. Based on the target system tech stack, probe could use very different ways to do so. But ultimately they are same, just collect and reformat data, then send to backend. In high level, there are three typical groups in all SkyWalking probes. @@ -13,11 +13,11 @@ of agents based on languages and libraries. is only used as ingress of the whole cluster, but with the Service Mesh and sidecar, now we can do observe based on that. - **3rd-party instrument library**. SkyWalking accepts other popular used instrument libraries data format. It analysis the -data, transfer it to SkyWalking formats of trace, metric or both. This feature starts with accepting Zipkin span data. See +data, transfer it to SkyWalking formats of trace, metrics or both. This feature starts with accepting Zipkin span data. See [Receiver for other tracers](../setup/backend/backend-receivers.md) to know more. You don't need to use **Language based native agent** and **Service Mesh probe** at the same time, because they both collect -metric data. As a result of that, your system suffers twice payloads, and the analytic numbers are doubled. +metrics data. As a result of that, your system suffers twice payloads, and the analytic numbers are doubled. There are several recommend ways in using these probes: 1. Use **Language based native agent** only. diff --git a/docs/en/concepts-and-designs/project-goals.md b/docs/en/concepts-and-designs/project-goals.md index 1af038cf8e4d..5366fa1eb73a 100644 --- a/docs/en/concepts-and-designs/project-goals.md +++ b/docs/en/concepts-and-designs/project-goals.md @@ -4,9 +4,9 @@ The document outlines the core design goals for SkyWalking project. - **Keep Observability**. No matter how does the target system deploy, SkyWalking could provide a solution or integration way to keep observability for it. Based on this, SkyWalking provides several runtime forms and probes. -- **Topology, Metric and Trace Together**. The first step to see and understand a distributed system should be +- **Topology, Metrics and Trace Together**. The first step to see and understand a distributed system should be from topology map. It visualizes the whole complex system as an easy map. Under that topology, OSS people requires -more about metric for service, instance, endpoint and calls. Trace exists as detail logs for making sense of those metric. +more about metrics for service, instance, endpoint and calls. Trace exists as detail logs for making sense of those metrics. Such as when endpoint latency becomes long, you want to see the slowest the trace to find out why. So you can see, they are from big picture to details, they are all needed. SkyWalking integrates and provides a lot of features to make this possible and easy understand. diff --git a/docs/en/concepts-and-designs/scope-definitions.md b/docs/en/concepts-and-designs/scope-definitions.md index d039b18e0075..3a88a1f75fe5 100644 --- a/docs/en/concepts-and-designs/scope-definitions.md +++ b/docs/en/concepts-and-designs/scope-definitions.md @@ -13,7 +13,7 @@ By using Aggregation Function, the requests will group by time and **Group Key(s ### SCOPE `Service` -Calculate the metric data from each request of the service. +Calculate the metrics data from each request of the service. | Name | Remarks | Group Key | Type | |---|---|---|---| @@ -28,7 +28,7 @@ Calculate the metric data from each request of the service. ### SCOPE `ServiceInstance` -Calculate the metric data from each request of the service instance. +Calculate the metrics data from each request of the service instance. | Name | Remarks | Group Key | Type | |---|---|---|---| @@ -43,7 +43,7 @@ Calculate the metric data from each request of the service instance. #### Secondary scopes of `ServiceInstance` -Calculate the metric data if the service instance is a JVM and collected by javaagent. +Calculate the metrics data if the service instance is a JVM and collected by javaagent. 1. SCOPE `ServiceInstanceJVMCPU` @@ -61,7 +61,7 @@ Calculate the metric data if the service instance is a JVM and collected by java | id | Represent the unique id of the service instance, usually a number. | yes | int | | name | Represent the name of the service instance. Such as `ip:port@Service Name`. **Notice**: current native agent uses `processId@Service name` as instance name, which is useless when you want to setup a filter in aggregation. | | string| | serviceName | Represent the name of the service. | | string | -| heapStatus | Represent this value the memory metric values are heap or not | | bool | +| heapStatus | Represent this value the memory metrics values are heap or not | | bool | | init | See JVM document | | long | | max | See JVM document | | long | | used | See JVM document | | long | @@ -93,7 +93,7 @@ Calculate the metric data if the service instance is a JVM and collected by java ### SCOPE `Endpoint` -Calculate the metric data from each request of the endpoint in the service. +Calculate the metrics data from each request of the endpoint in the service. | Name | Remarks | Group Key | Type | |---|---|---|---| @@ -108,7 +108,7 @@ Calculate the metric data from each request of the endpoint in the service. ### SCOPE `ServiceRelation` -Calculate the metric data from each request between one service and the other service +Calculate the metrics data from each request between one service and the other service | Name | Remarks | Group Key | Type | |---|---|---|---| @@ -129,7 +129,7 @@ Calculate the metric data from each request between one service and the other se ### SCOPE `ServiceInstanceRelation` -Calculate the metric data from each request between one service instance and the other service instance +Calculate the metrics data from each request between one service instance and the other service instance | Name | Remarks | Group Key | Type | |---|---|---|---| @@ -149,7 +149,7 @@ Calculate the metric data from each request between one service instance and the ### SCOPE `EndpointRelation` -Calculate the metric data of the dependency between one endpoint and the other endpoint. +Calculate the metrics data of the dependency between one endpoint and the other endpoint. This relation is hard to detect, also depends on tracing lib to propagate the prev endpoint. So `EndpointRelation` scope aggregation effects only in service under tracing by SkyWalking native agents, including auto instrument agents(like Java, .NET), OpenCensus SkyWalking exporter implementation or others propagate tracing context in SkyWalking spec. diff --git a/docs/en/concepts-and-designs/service-mesh-probe.md b/docs/en/concepts-and-designs/service-mesh-probe.md index ab48fc840dff..8656688f0bd7 100644 --- a/docs/en/concepts-and-designs/service-mesh-probe.md +++ b/docs/en/concepts-and-designs/service-mesh-probe.md @@ -24,9 +24,9 @@ platform still works? Service Mesh probes collects telemetry data from each request, so it knows the source, destination, endpoint, latency and status. By those, backend can tell the whole topology map by combining these call -as lines, and also the metric of each nodes through their incoming request. Backend asked for the same -metric data from parsing tracing data. So, the right expression is: -**Service Mesh metric are exact the metric, what the traces parsers generate. They are same.** +as lines, and also the metrics of each nodes through their incoming request. Backend asked for the same +metrics data from parsing tracing data. So, the right expression is: +**Service Mesh metrics are exact the metrics, what the traces parsers generate. They are same.** ## What is Next? - If you want to use the service mesh probe, read [set SkyWalking on Service Mesh](../setup/README.md#on-service-mesh) document. diff --git a/docs/en/guides/README.md b/docs/en/guides/README.md index 320545bfe38b..63bf3477a144 100644 --- a/docs/en/guides/README.md +++ b/docs/en/guides/README.md @@ -36,8 +36,8 @@ and private plugin developer should read this. - If you want to build a new probe or plugin in any language, please read [Component library definition and extension](Component-library-settings.md) document. - [Storage extension development guide](storage-extention.md). Help potential contributors to build a new storage implementor besides the official. -- [Customize analysis by oal script](write-oal.md). Guide you to use oal script to make your own metric available. -- [Source and scope extension for new metric](source-extension.md). If you want to analysis a new metric, which SkyWalking +- [Customize analysis by oal script](write-oal.md). Guide you to use oal script to make your own metrics available. +- [Source and scope extension for new metrics](source-extension.md). If you want to analysis a new metrics, which SkyWalking haven't provide. You need to add a new receiver rather than choosing [existed receiver](../setup/backend/backend-receivers.md). At that moment, diff --git a/docs/en/guides/backend-oal-scripts.md b/docs/en/guides/backend-oal-scripts.md index 6c79a9cfd6b8..7fc905791459 100644 --- a/docs/en/guides/backend-oal-scripts.md +++ b/docs/en/guides/backend-oal-scripts.md @@ -9,7 +9,7 @@ You need to use OAL tool code generator to build the real analysis codes from it All generated codes are under `oal` folder in **oap-server/generated-analysis/target/generated-sources**. All metrics named in this script could be used in alarm and UI query. Of course, you can change this -scripts and re-generate the analysis process and metric, such as adding filter condition. +scripts and re-generate the analysis process and metrics, such as adding filter condition. -If you try to add or remove some metric, UI may break, we only recommend you to do this when you plan +If you try to add or remove some metrics, UI may break, we only recommend you to do this when you plan to build your own UI based on the customization analysis core. \ No newline at end of file diff --git a/docs/en/guides/inventory-extension.md b/docs/en/guides/inventory-extension.md index cee70eb2884c..3a78bba3626a 100644 --- a/docs/en/guides/inventory-extension.md +++ b/docs/en/guides/inventory-extension.md @@ -5,7 +5,7 @@ SkyWalking includes four inventory entities. - Endpoint Inventory - Network Address Inventory -All metric, topology, trace and alarm are related to these entity IDs. +All metrics, topology, trace and alarm are related to these entity IDs. For understanding the **Service**, **Service Instance** and **Endpoint** concepts, please read [Project Overview](../concepts-and-designs/overview.md#why-use-skywalking). diff --git a/docs/en/guides/source-extension.md b/docs/en/guides/source-extension.md index 8338b5e17cc2..47fc6f49f314 100644 --- a/docs/en/guides/source-extension.md +++ b/docs/en/guides/source-extension.md @@ -1,4 +1,4 @@ -# Source and Scope extension for new metric +# Source and Scope extension for new metrics From [OAL scope introduction](../concepts-and-designs/oal.md#scope), you should already have understood what the scope is. At here, as you want to do more extension, you need understand deeper, which is the **Source**. @@ -53,11 +53,11 @@ This value is used in [OAL group mechanism](../concepts-and-designs/oal.md#group 7. Set the default columns for new scope, at `generator-scope-meta.yml` file in `generated-analysis/src/main/resources`. If you want to understand why need these columns, you have to understand all existing query(s). But there is an easy way, -follow other existing scopes. Such as, if you are adding metric, connection number for service instance, follow existing `ServiceInstance`. +follow other existing scopes. Such as, if you are adding metrics, connection number for service instance, follow existing `ServiceInstance`. ___ After you done all of these, you could build a receiver, which do -1. Get the original data of the metric, +1. Get the original data of the metrics, 1. Build the source, send into `SourceReceiver`. 1. Write your whole OAL scripts. 1. Repackage the project. \ No newline at end of file diff --git a/docs/en/guides/storage-extention.md b/docs/en/guides/storage-extention.md index 3fb76cfff84b..63d8fde0dd87 100644 --- a/docs/en/guides/storage-extention.md +++ b/docs/en/guides/storage-extention.md @@ -22,7 +22,7 @@ Here is the list of all DAO interfaces in storage 1. StorageDAO 1. IRegisterLockDAO 1. H2TopologyQueryDAO -1. IMetricQueryDAO +1. IMetricsQueryDAO 1. ITraceQueryDAO 1. IMetadataQueryDAO 1. IAggregationQueryDAO diff --git a/docs/en/protocols/README.md b/docs/en/protocols/README.md index 9c548e7c6f7f..0daf2cb7a3ba 100644 --- a/docs/en/protocols/README.md +++ b/docs/en/protocols/README.md @@ -1,7 +1,7 @@ # Protocols There are two types of protocols list here. -- [**Probe Protocol**](#probe-protocols). Include the descriptions and definitions about how agent send collected metric data and traces, also the formats of each entities. +- [**Probe Protocol**](#probe-protocols). Include the descriptions and definitions about how agent send collected metrics data and traces, also the formats of each entities. - [**Query Protocol**](#query-protocol). The backend provide query capability to SkyWalking own UI and others. These queries are based on GraphQL. @@ -66,20 +66,20 @@ There are 5 dimensionality data is provided. 1. Metadata. Metadata includes the brief info of the whole under monitoring services and their instances, endpoints, etc. Use multiple ways to query this meta data. 1. Topology. Show the topology and dependency graph of services or endpoints. Including direct relationship or global map. -1. Metric. Metric query targets all the objects defined in [OAL script](../concepts-and-designs/oal.md). You could get the -metric data in linear or thermodynamic matrix formats based on the aggregation functions in script. -1. Aggregation. Aggregation query means the metric data need a secondary aggregation in query stage, which makes the query +1. Metrics. Metrics query targets all the objects defined in [OAL script](../concepts-and-designs/oal.md). You could get the +metrics data in linear or thermodynamic matrix formats based on the aggregation functions in script. +1. Aggregation. Aggregation query means the metrics data need a secondary aggregation in query stage, which makes the query interfaces have some different arguments. Such as, `TopN` list of services is a very typical aggregation query, -metric stream aggregation just calculates the metric values of each service, but the expected list needs ordering metric data +metrics stream aggregation just calculates the metrics values of each service, but the expected list needs ordering metrics data by the values. 1. Trace. Query distributed traces by this. 1. Alarm. Through alarm query, you can have alarm trend and details. The actual query GraphQL scrips could be found inside `query-protocol` folder in [here](../../../oap-server/server-query-plugin/query-graphql-plugin/src/main/resources). -Here is the list of all existing metric names, based on [official_analysis.oal](../../../oap-server/generated-analysis/src/main/resources/official_analysis.oal) +Here is the list of all existing metrics names, based on [official_analysis.oal](../../../oap-server/generated-analysis/src/main/resources/official_analysis.oal) -**Global metric** +**Global metrics** - all_p99, p99 response time of all services - all_p95 - all_p90 @@ -87,7 +87,7 @@ Here is the list of all existing metric names, based on [official_analysis.oal]( - all_p70 - all_heatmap, the response time heatmap of all services -**Service metric** +**Service metrics** - service_resp_time, avg response time of service - service_sla, successful rate of service - service_cpm, calls per minute of service @@ -97,12 +97,12 @@ Here is the list of all existing metric names, based on [official_analysis.oal]( - service_p75 - service_p50 -**Service instance metric** +**Service instance metrics** - service_instance_sla, successful rate of service instance - service_instance_resp_time, avg response time of service instance - service_instance_cpm, calls per minute of service instance -**Endpoint metric** +**Endpoint metrics** - endpoint_cpm, calls per minute of endpoint - endpoint_avg, avg response time of endpoint - endpoint_sla, successful rate of endpoint @@ -112,7 +112,7 @@ Here is the list of all existing metric names, based on [official_analysis.oal]( - endpoint_p75 - endpoint_p50 -**JVM metric**, JVM related metric, only work when javaagent is active +**JVM metrics**, JVM related metrics, only work when javaagent is active - instance_jvm_cpu - instance_jvm_memory_heap - instance_jvm_memory_noheap @@ -123,8 +123,8 @@ Here is the list of all existing metric names, based on [official_analysis.oal]( - instance_jvm_young_gc_count - instance_jvm_old_gc_count -**Service relation metric**, represents the metric of calls between service. -The metric ID could be +**Service relation metrics**, represents the metrics of calls between service. +The metrics ID could be got in topology query only. - service_relation_client_cpm, calls per minute detected at client side - service_relation_server_cpm, calls per minute detected at server side @@ -133,7 +133,7 @@ got in topology query only. - service_relation_client_resp_time, avg response time detected at client side - service_relation_server_resp_time, avg response time detected at server side -**Endpoint relation metric**, represents the metric between dependency endpoints. Only work when tracing agent. -The metric ID could be got in topology query only. +**Endpoint relation metrics**, represents the metrics between dependency endpoints. Only work when tracing agent. +The metrics ID could be got in topology query only. - endpoint_relation_cpm - endpoint_relation_resp_time diff --git a/docs/en/protocols/Trace-Data-Protocol-v2.md b/docs/en/protocols/Trace-Data-Protocol-v2.md index c25f8a12d823..a80a8404c223 100644 --- a/docs/en/protocols/Trace-Data-Protocol-v2.md +++ b/docs/en/protocols/Trace-Data-Protocol-v2.md @@ -5,7 +5,7 @@ Trace Data Protocol describes the data format between SkyWalking agent/sniffer a Trace data protocol is defined and provided in [gRPC format](https://github.com/apache/skywalking-data-collect-protocol). For each agent/SDK, it needs to register service id and service instance id before reporting any kind of trace -or metric data. +or metrics data. ### Step 1. Do register [Register service](https://github.com/apache/skywalking-data-collect-protocol/tree/master/register/Register.proto) takes charge of @@ -23,8 +23,8 @@ In most cases, you need to set a timer to call these services repeated, until yo Because batch is supported, even for most language agent/SDK, no scenario to do batch register. We suggest to check the `serviceName` and `UUID` in response, and match with your expected value. -### Step 2. Send trace and metric -After you have service id and service instance id, you could send traces and metric. Now we +### Step 2. Send trace and metrics +After you have service id and service instance id, you could send traces and metrics. Now we have 1. `TraceSegmentReportService#collect` for skywalking native trace format 1. `JVMMetricReportService#collect` for skywalking native jvm format diff --git a/docs/en/setup/backend/backend-alarm.md b/docs/en/setup/backend/backend-alarm.md index aa22b9f6fd32..053429d2cf61 100644 --- a/docs/en/setup/backend/backend-alarm.md +++ b/docs/en/setup/backend/backend-alarm.md @@ -1,14 +1,14 @@ # Alarm Alarm core is driven a collection of rules, which are defined in `config/alarm-settings.yml`. There are two parts in alarm rule definition. -1. Alarm rules. They define how metric alarm should be triggered, what conditions should be considered. +1. Alarm rules. They define how metrics alarm should be triggered, what conditions should be considered. 1. Webhooks. The list of web service endpoint, which should be called after the alarm is triggered. ## Rules Alarm rule is constituted by following keys - **Rule name**. Unique name, show in alarm message. Must end with `_rule`. -- **Indicator name**. A.K.A. metric name in oal script. Only long, double, int types are supported. See -[List of all potential metric name](#list-of-all-potential-metric-name). +- **Metrics name**. A.K.A. metrics name in oal script. Only long, double, int types are supported. See +[List of all potential metrics name](#list-of-all-potential-metrics-name). - **Include names**. The following entity names are included in this rule. Such as Service name, endpoint name. - **Threshold**. The target value. @@ -19,27 +19,27 @@ backend deployment env time. should send. - **Silence period**. After alarm is triggered in Time-N, then keep silence in the **TN -> TN + period**. By default, it is as same as **Period**, which means in a period, same alarm(same ID in same -indicator name) will be trigger once. +metrics name) will be trigger once. ```yaml rules: # Rule unique name, must be ended with `_rule`. endpoint_percent_rule: - # Indicator value need to be long, double or int - indicator-name: endpoint_percent + # Metrics value need to be long, double or int + metrics-name: endpoint_percent threshold: 75 op: < - # The length of time to evaluate the metric + # The length of time to evaluate the metrics period: 10 - # How many times after the metric match the condition, will trigger alarm + # How many times after the metrics match the condition, will trigger alarm count: 3 # How many times of checks, the alarm keeps silence after alarm triggered, default as same as period. silence-period: 10 service_percent_rule: - indicator-name: service_percent - # [Optional] Default, match all services in this indicator + metrics-name: service_percent + # [Optional] Default, match all services in this metrics include-names: - service_a - service_b @@ -59,8 +59,8 @@ We provided a default `alarm-setting.yml` in our distribution only for convenien -## List of all potential metric name -The metric names are defined in official [OAL scripts](../../guides/backend-oal-scripts.md), right now -metric from **Service**, **Service Instance**, **Endpoint** scopes could be used in Alarm, we will extend in further versions. +## List of all potential metrics name +The metrics names are defined in official [OAL scripts](../../guides/backend-oal-scripts.md), right now +metrics from **Service**, **Service Instance**, **Endpoint** scopes could be used in Alarm, we will extend in further versions. Submit issue or pull request if you want to support any other scope in alarm. diff --git a/docs/en/setup/backend/backend-receivers.md b/docs/en/setup/backend/backend-receivers.md index 3c5ea57f51ab..2a2540f7c8d1 100644 --- a/docs/en/setup/backend/backend-receivers.md +++ b/docs/en/setup/backend/backend-receivers.md @@ -8,9 +8,9 @@ We have following receivers, and `default` implementors are provided in our Apac 1. **receiver-trace**. gRPC and HTTPRestful services to accept SkyWalking format traces. 1. **receiver-register**. gRPC and HTTPRestful services to provide service, service instance and endpoint register. 1. **service-mesh**. gRPC services accept data from inbound mesh probes. -1. **receiver-jvm**. gRPC services accept JVM metric data. +1. **receiver-jvm**. gRPC services accept JVM metrics data. 1. **istio-telemetry**. Istio telemetry is from Istio official bypass adaptor, this receiver match its gRPC services. -1. **envoy-metric**. Envoy `metrics_service` supported by this receiver. OAL script support all GAUGE type metrics. +1. **envoy-metrics**. Envoy `metrics_service` supported by this receiver. OAL script support all GAUGE type metrics. 1. **receiver_zipkin**. See [details](#zipkin-receiver). 1. **receiver_jaeger**. See [details](#jaeger-receiver). @@ -35,7 +35,7 @@ service-mesh: bufferFileCleanWhenRestart: false istio-telemetry: default: -envoy-metric: +envoy-metrics: default: receiver_zipkin: default: @@ -66,7 +66,7 @@ Zipkin receiver could work in two different mode. 1. Tracing mode(default). Tracing mode is that, skywalking OAP acts like zipkin collector, fully supports Zipkin v1/v2 formats through HTTP service, also provide persistence and query in skywalking UI. -But it wouldn't analysis metric from them. In most case, I suggest you could use this feature, when metrics come from service mesh. +But it wouldn't analysis metrics from them. In most case, I suggest you could use this feature, when metrics come from service mesh. Notice, in this mode, Zipkin receiver requires `zipkin-elasticsearch` storage implementation active. Read [this](backend-storage.md#elasticsearch-6-with-zipkin-trace-extension) to know how to active. diff --git a/docs/en/setup/backend/backend-setup.md b/docs/en/setup/backend/backend-setup.md index 341950e0aefd..0092b5c1adde 100644 --- a/docs/en/setup/backend/backend-setup.md +++ b/docs/en/setup/backend/backend-setup.md @@ -66,20 +66,20 @@ DB. But clearly, it doesn't fit the product env. In here, you could find what ot Choose the one you like, we are also welcome anyone to contribute new storage implementor, 1. [Set receivers](backend-receivers.md). You could choose receivers by your requirements, most receivers are harmless, at least our default receivers are. You would set and active all receivers provided. -1. Do [trace sampling](trace-sampling.md) at backend. This sample keep the metric accurate, only don't save some of traces +1. Do [trace sampling](trace-sampling.md) at backend. This sample keep the metrics accurate, only don't save some of traces in storage based on rate. 1. Follow [slow DB statement threshold](slow-db-statement.md) config document to understand that, how to detect the Slow database statements(including SQL statements) in your system. 1. Official [OAL scripts](../../guides/backend-oal-scripts.md). As you known from our [OAL introduction](../../concepts-and-designs/oal.md), most of backend analysis capabilities based on the scripts. Here is the description of official scripts, -which helps you to understand which metric data are in process, also could be used in alarm. +which helps you to understand which metrics data are in process, also could be used in alarm. 1. [Alarm](backend-alarm.md). Alarm provides a time-series based check mechanism. You could set alarm -rules targeting the analysis oal metric objects. +rules targeting the analysis oal metrics objects. 1. [Advanced deployment options](advanced-deployment.md). If you want to deploy backend in very large scale and support high payload, you may need this. -1. [Metric exporter](metric-exporter.md). Use metric data exporter to forward metric data to 3rd party +1. [Metrics exporter](metrics-exporter.md). Use metrics data exporter to forward metrics data to 3rd party system. -1. [Time To Live (TTL)](ttl.md). Metric and trace are time series data, they would be saved forever, you could +1. [Time To Live (TTL)](ttl.md). Metrics and trace are time series data, they would be saved forever, you could set the expired time for each dimension. ## Telemetry for backend @@ -89,11 +89,11 @@ we provide the telemetry for OAP backend itself. Follow [document](backend-telem ## FAQs #### When and why do we need to set Timezone? -SkyWalking provides downsampling time series metric features. -Query and storage at each time dimension(minute, hour, day, month metric indexes) +SkyWalking provides downsampling time series metrics features. +Query and storage at each time dimension(minute, hour, day, month metrics indexes) related to timezone when doing time format. -For example, metric time will be formatted like YYYYMMDDHHmm in minute dimension metric, +For example, metrics time will be formatted like YYYYMMDDHHmm in minute dimension metrics, which format process is timezone related. In default, SkyWalking OAP backend choose the OS default timezone. diff --git a/docs/en/setup/backend/backend-telemetry.md b/docs/en/setup/backend/backend-telemetry.md index f60f405bbf91..0034f13f19a5 100644 --- a/docs/en/setup/backend/backend-telemetry.md +++ b/docs/en/setup/backend/backend-telemetry.md @@ -7,7 +7,7 @@ telemetry: ## Prometheus Prometheus is supported as telemetry implementor. -By using this, prometheus collects metric from skywalking backend. +By using this, prometheus collects metrics from skywalking backend. Set `prometheus` to provider. The endpoint open at `http://0.0.0.0:1234/` and `http://0.0.0.0:1234/metrics`. ```yaml diff --git a/docs/en/setup/backend/metric-exporter.md b/docs/en/setup/backend/metrics-exporter.md similarity index 75% rename from docs/en/setup/backend/metric-exporter.md rename to docs/en/setup/backend/metrics-exporter.md index 2ab318fac3d0..9ffe33745d13 100644 --- a/docs/en/setup/backend/metric-exporter.md +++ b/docs/en/setup/backend/metrics-exporter.md @@ -1,9 +1,9 @@ -# Metric Exporter -SkyWalking provides basic and most important metric aggregation, alarm and analysis. +# Metrics Exporter +SkyWalking provides basic and most important metrics aggregation, alarm and analysis. In real world, people may want to forward the data to their 3rd party system, for deeper analysis or anything else. -**Metric Exporter** makes that possible. +**Metrics Exporter** makes that possible. -Metric exporter is an independent module, you need manually active it. +Metrics exporter is an independent module, you need manually active it. Right now, we provide the following exporters 1. gRPC exporter @@ -59,9 +59,9 @@ exporter: ## For target exporter service ### subscription implementation -Return the expected metric name list, all the names must match the OAL script definition. Return empty list, if you want +Return the expected metrics name list, all the names must match the OAL script definition. Return empty list, if you want to export all metrics. ### export implementation Stream service, all subscribed metrics will be sent to here, based on OAP core schedule. Also, if the OAP deployed as cluster, -then this method will be called concurrently. For metric value, you need follow `#type` to choose `#longValue` or `#doubleValue`. \ No newline at end of file +then this method will be called concurrently. For metrics value, you need follow `#type` to choose `#longValue` or `#doubleValue`. \ No newline at end of file diff --git a/docs/en/setup/backend/telemetry/mesh-mode-grafana.json b/docs/en/setup/backend/telemetry/mesh-mode-grafana.json index ce56d32efbe0..03a2e2650eec 100644 --- a/docs/en/setup/backend/telemetry/mesh-mode-grafana.json +++ b/docs/en/setup/backend/telemetry/mesh-mode-grafana.json @@ -1026,7 +1026,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(indicator_aggregation {dimensionality=\"min\"} [1m])) by (level)", + "expr": "sum(rate(metrics_aggregation {dimensionality=\"min\"} [1m])) by (level)", "format": "time_series", "hide": false, "intervalFactor": 1, diff --git a/docs/en/setup/backend/telemetry/trace-mode-grafana.json b/docs/en/setup/backend/telemetry/trace-mode-grafana.json index c76afcbcf4ad..2bf795946bb7 100644 --- a/docs/en/setup/backend/telemetry/trace-mode-grafana.json +++ b/docs/en/setup/backend/telemetry/trace-mode-grafana.json @@ -1110,7 +1110,7 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(indicator_aggregation {dimensionality=\"min\"} [1m])) by (level)", + "expr": "sum(rate(metrics_aggregation {dimensionality=\"min\"} [1m])) by (level)", "format": "time_series", "hide": false, "intervalFactor": 1, diff --git a/docs/en/setup/backend/trace-sampling.md b/docs/en/setup/backend/trace-sampling.md index a1df89318dfb..f0ce701d9dd6 100644 --- a/docs/en/setup/backend/trace-sampling.md +++ b/docs/en/setup/backend/trace-sampling.md @@ -1,6 +1,6 @@ # Trace Sampling at server side When we run a distributed tracing system, the trace bring us detailed info, but cost a lot at storage. -Open server side trace sampling mechanism, the metric of service, service instance, endpoint and topology are all accurate +Open server side trace sampling mechanism, the metrics of service, service instance, endpoint and topology are all accurate as before, but only don't save all the traces into storage. Of course, even you open sampling, the traces will be kept as consistent as possible. **Consistent** means, once the trace diff --git a/docs/en/setup/backend/ttl.md b/docs/en/setup/backend/ttl.md index f82b64119cbf..e38978f056d0 100644 --- a/docs/en/setup/backend/ttl.md +++ b/docs/en/setup/backend/ttl.md @@ -6,7 +6,7 @@ Metric is separated in minute/hour/day/month dimensions in storage, different in You have following settings for different types. ```yaml - # Set a timeout on metric data. After the timeout has expired, the metric data will automatically be deleted. + # Set a timeout on metrics data. After the timeout has expired, the metrics data will automatically be deleted. recordDataTTL: ${SW_CORE_RECORD_DATA_TTL:90} # Unit is minute minuteMetricsDataTTL: ${SW_CORE_MINUTE_METRIC_DATA_TTL:90} # Unit is minute hourMetricsDataTTL: ${SW_CORE_HOUR_METRIC_DATA_TTL:36} # Unit is hour @@ -16,4 +16,4 @@ You have following settings for different types. - `recordDataTTL` affects **Record** data. - `minuteMetricsDataTTL`, `hourMetricsDataTTL`, `dayMetricsDataTTL` and `monthMetricsDataTTL` affects -metric data in minute/hour/day/month dimensions. \ No newline at end of file +metrics data in minute/hour/day/month dimensions. \ No newline at end of file diff --git a/docs/en/setup/istio/README.md b/docs/en/setup/istio/README.md index 6981caefeda2..819340386eda 100644 --- a/docs/en/setup/istio/README.md +++ b/docs/en/setup/istio/README.md @@ -1,6 +1,6 @@ # Work with Istio -Instructions for transport Istio's metrics to skywalking oap server. +Instructions for transport Istio's metrics to SkyWalking OAP server. ## Prerequisites @@ -13,6 +13,6 @@ Follow the [deploying backend in kubernetes](../backend/backend-k8s.md) to insta ## Setup Istio to send metrics to oap -Follow instructions in the [setup Istio to send metric to oap](https://github.com/apache/skywalking-kubernetes#setup-istio-to-send-metric-to-oap) +Follow instructions in the [setup Istio to send metrics to oap](https://github.com/apache/skywalking-kubernetes#setup-istio-to-send-metrics-to-oap) to setup Istio with oap. \ No newline at end of file diff --git a/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/MetricFormatter.java b/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/MetricFormatter.java index 800d24898880..6c04b909c361 100644 --- a/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/MetricFormatter.java +++ b/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/MetricFormatter.java @@ -19,7 +19,7 @@ package org.apache.skywalking.oap.server.exporter.provider; import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; import org.apache.skywalking.oap.server.core.cache.*; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; @@ -32,7 +32,7 @@ public class MetricFormatter { private ServiceInstanceInventoryCache serviceInstanceInventoryCache; private EndpointInventoryCache endpointInventoryCache; - protected String getEntityName(IndicatorMetaInfo meta) { + protected String getEntityName(MetricsMetaInfo meta) { int scope = meta.getScope(); if (DefaultScopeDefine.inServiceCatalog(scope)) { return serviceInventoryCache.get(scope).getName(); diff --git a/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporter.java b/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporter.java index 730a3f1a2de2..4fdd05c7ae55 100644 --- a/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporter.java +++ b/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporter.java @@ -25,7 +25,7 @@ import lombok.*; import org.apache.skywalking.apm.commons.datacarrier.DataCarrier; import org.apache.skywalking.apm.commons.datacarrier.consumer.IConsumer; -import org.apache.skywalking.oap.server.core.analysis.indicator.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; import org.apache.skywalking.oap.server.core.exporter.MetricValuesExportService; import org.apache.skywalking.oap.server.exporter.grpc.*; import org.apache.skywalking.oap.server.exporter.provider.MetricFormatter; @@ -56,9 +56,9 @@ public GRPCExporter(GRPCExporterSetting setting) { subscriptionSet = new HashSet<>(); } - @Override public void export(IndicatorMetaInfo meta, Indicator indicator) { - if (subscriptionSet.size() == 0 || subscriptionSet.contains(meta.getIndicatorName())) { - exportBuffer.produce(new ExportData(meta, indicator)); + @Override public void export(MetricsMetaInfo meta, Metrics metrics) { + if (subscriptionSet.size() == 0 || subscriptionSet.contains(meta.getMetricsName())) { + exportBuffer.produce(new ExportData(meta, metrics)); } } @@ -97,25 +97,25 @@ public void initSubscriptionList() { data.forEach(row -> { ExportMetricValue.Builder builder = ExportMetricValue.newBuilder(); - Indicator indicator = row.getIndicator(); - if (indicator instanceof LongValueHolder) { - long value = ((LongValueHolder)indicator).getValue(); + Metrics metrics = row.getMetrics(); + if (metrics instanceof LongValueHolder) { + long value = ((LongValueHolder)metrics).getValue(); builder.setLongValue(value); builder.setType(ValueType.LONG); - } else if (indicator instanceof IntValueHolder) { - long value = ((IntValueHolder)indicator).getValue(); + } else if (metrics instanceof IntValueHolder) { + long value = ((IntValueHolder)metrics).getValue(); builder.setLongValue(value); builder.setType(ValueType.LONG); - } else if (indicator instanceof DoubleValueHolder) { - double value = ((DoubleValueHolder)indicator).getValue(); + } else if (metrics instanceof DoubleValueHolder) { + double value = ((DoubleValueHolder)metrics).getValue(); builder.setDoubleValue(value); builder.setType(ValueType.DOUBLE); } else { return; } - IndicatorMetaInfo meta = row.getMeta(); - builder.setMetricName(meta.getIndicatorName()); + MetricsMetaInfo meta = row.getMeta(); + builder.setMetricName(meta.getMetricsName()); String entityName = getEntityName(meta); if (entityName == null) { return; @@ -123,7 +123,7 @@ public void initSubscriptionList() { builder.setEntityName(entityName); builder.setEntityId(meta.getId()); - builder.setTimeBucket(indicator.getTimeBucket()); + builder.setTimeBucket(metrics.getTimeBucket()); streamObserver.onNext(builder.build()); exportNum.getAndIncrement(); @@ -144,13 +144,13 @@ public void initSubscriptionList() { } if (sleepTime > 2000L) { - logger.warn("Export {} metric(s) to {}:{}, wait {} milliseconds.", + logger.warn("Export {} metrics to {}:{}, wait {} milliseconds.", exportNum.get(), setting.getTargetHost(), setting.getTargetPort(), sleepTime); cycle = 2000L; } } - logger.debug("Exported {} metric(s) to {}:{} in {} milliseconds.", + logger.debug("Exported {} metrics to {}:{} in {} milliseconds.", exportNum.get(), setting.getTargetHost(), setting.getTargetPort(), sleepTime); } @@ -164,12 +164,12 @@ public void initSubscriptionList() { @Getter(AccessLevel.PRIVATE) public class ExportData { - private IndicatorMetaInfo meta; - private Indicator indicator; + private MetricsMetaInfo meta; + private Metrics metrics; - public ExportData(IndicatorMetaInfo meta, Indicator indicator) { + public ExportData(MetricsMetaInfo meta, Metrics metrics) { this.meta = meta; - this.indicator = indicator; + this.metrics = metrics; } } diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterTest.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterTest.java index f4fcca2288e3..0b347d443d4b 100644 --- a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterTest.java +++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterTest.java @@ -19,7 +19,7 @@ package org.apache.skywalking.oap.server.exporter.provider.grpc; import io.grpc.testing.GrpcServerRule; -import org.apache.skywalking.oap.server.core.analysis.indicator.IndicatorMetaInfo; +import org.apache.skywalking.oap.server.core.analysis.metrics.MetricsMetaInfo; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; import org.apache.skywalking.oap.server.exporter.grpc.MetricExportServiceGrpc; import org.junit.Before; @@ -42,7 +42,7 @@ public class GRPCExporterTest { public final GrpcServerRule grpcServerRule = new GrpcServerRule().directExecutor(); private MetricExportServiceGrpc.MetricExportServiceImplBase server = new MockMetricExportServiceImpl(); - private IndicatorMetaInfo metaInfo = new IndicatorMetaInfo("mock-indicator", DefaultScopeDefine.ALL); + private MetricsMetaInfo metaInfo = new MetricsMetaInfo("mock-metrics", DefaultScopeDefine.ALL); private MetricExportServiceGrpc.MetricExportServiceBlockingStub stub; @@ -58,7 +58,7 @@ public void setUp() throws Exception { @Test public void export() { - exporter.export(metaInfo, new MockIndicator()); + exporter.export(metaInfo, new MockMetrics()); } @Test @@ -94,10 +94,10 @@ public void onExit() { private List dataList() { List dataList = new LinkedList<>(); - dataList.add(exporter.new ExportData(metaInfo, new MockIndicator())); - dataList.add(exporter.new ExportData(metaInfo, new MockIntValueIndicator())); - dataList.add(exporter.new ExportData(metaInfo, new MockLongValueIndicator())); - dataList.add(exporter.new ExportData(metaInfo, new MockDoubleValueIndicator())); + dataList.add(exporter.new ExportData(metaInfo, new MockMetrics())); + dataList.add(exporter.new ExportData(metaInfo, new MockIntValueMetrics())); + dataList.add(exporter.new ExportData(metaInfo, new MockLongValueMetrics())); + dataList.add(exporter.new ExportData(metaInfo, new MockDoubleValueMetrics())); return dataList; } } \ No newline at end of file diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockDoubleValueIndicator.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockDoubleValueMetrics.java similarity index 85% rename from oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockDoubleValueIndicator.java rename to oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockDoubleValueMetrics.java index 6b4fc9c15ea3..0bb524635d0a 100644 --- a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockDoubleValueIndicator.java +++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockDoubleValueMetrics.java @@ -18,12 +18,12 @@ package org.apache.skywalking.oap.server.exporter.provider.grpc; -import org.apache.skywalking.oap.server.core.analysis.indicator.DoubleValueHolder; +import org.apache.skywalking.oap.server.core.analysis.metrics.DoubleValueHolder; /** * Created by dengming, 2019.04.20 */ -public class MockDoubleValueIndicator extends MockIndicator implements DoubleValueHolder { +public class MockDoubleValueMetrics extends MockMetrics implements DoubleValueHolder { @Override public double getValue() { return 2.3; diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIntValueIndicator.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIntValueMetrics.java similarity index 85% rename from oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIntValueIndicator.java rename to oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIntValueMetrics.java index 509727f64335..919aed46696b 100644 --- a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIntValueIndicator.java +++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIntValueMetrics.java @@ -18,12 +18,12 @@ package org.apache.skywalking.oap.server.exporter.provider.grpc; -import org.apache.skywalking.oap.server.core.analysis.indicator.IntValueHolder; +import org.apache.skywalking.oap.server.core.analysis.metrics.IntValueHolder; /** * Created by dengming, 2019.04.20 */ -public class MockIntValueIndicator extends MockIndicator implements IntValueHolder { +public class MockIntValueMetrics extends MockMetrics implements IntValueHolder { @Override public int getValue() { return 12; diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockLongValueIndicator.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockLongValueMetrics.java similarity index 85% rename from oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockLongValueIndicator.java rename to oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockLongValueMetrics.java index a8ee9157d641..e6abd78ab534 100644 --- a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockLongValueIndicator.java +++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockLongValueMetrics.java @@ -18,12 +18,12 @@ package org.apache.skywalking.oap.server.exporter.provider.grpc; -import org.apache.skywalking.oap.server.core.analysis.indicator.LongValueHolder; +import org.apache.skywalking.oap.server.core.analysis.metrics.LongValueHolder; /** * Created by dengming, 2019.04.20 */ -public class MockLongValueIndicator extends MockIndicator implements LongValueHolder { +public class MockLongValueMetrics extends MockMetrics implements LongValueHolder { @Override public long getValue() { return 1234567891234563312L; diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIndicator.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockMetrics.java similarity index 83% rename from oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIndicator.java rename to oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockMetrics.java index f1a74c47d772..b56c9f3a4ca2 100644 --- a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIndicator.java +++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockMetrics.java @@ -18,21 +18,21 @@ package org.apache.skywalking.oap.server.exporter.provider.grpc; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; /** * Created by dengming, 2019.04.20 */ -public class MockIndicator extends Indicator { +public class MockMetrics extends Metrics { @Override public String id() { - return "mock-indicator"; + return "mock-metrics"; } @Override - public void combine(Indicator indicator) { + public void combine(Metrics metrics) { } @@ -42,17 +42,17 @@ public void calculate() { } @Override - public Indicator toHour() { + public Metrics toHour() { return this; } @Override - public Indicator toDay() { + public Metrics toDay() { return this; } @Override - public Indicator toMonth() { + public Metrics toMonth() { return this; } diff --git a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/Main.java b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/Main.java index ea35936b72ec..04a48c96c669 100644 --- a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/Main.java +++ b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/Main.java @@ -41,7 +41,7 @@ public static void main(String[] args) throws IOException, TemplateException { "org", "apache", "skywalking", "oap", "server", "core", "analysis"); String metaFilePath = StringUtil.join(File.separatorChar, modulePath, "src", "main", "resources", "generator-scope-meta.yml"); - Indicators.init(); + MetricsHolder.init(); File scriptFile = new File(scriptFilePath); if (!scriptFile.exists()) { diff --git a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/output/DispatcherContext.java b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/output/DispatcherContext.java index 8c8361006f5a..b8913e3423e7 100644 --- a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/output/DispatcherContext.java +++ b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/output/DispatcherContext.java @@ -27,5 +27,5 @@ public class DispatcherContext { private String source; private String packageName; - private List indicators = new ArrayList<>(); + private List metrics = new ArrayList<>(); } diff --git a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/output/FileGenerator.java b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/output/FileGenerator.java index e2a1db3672b8..deab81b582fe 100644 --- a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/output/FileGenerator.java +++ b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/output/FileGenerator.java @@ -31,7 +31,7 @@ public class FileGenerator { private AllDispatcherContext allDispatcherContext; public FileGenerator(OALScripts oalScripts, String outputPath) { - this.results = oalScripts.getIndicatorStmts(); + this.results = oalScripts.getMetricsStmts(); this.collection = oalScripts.getDisableCollection(); this.outputPath = outputPath; configuration = new Configuration(new Version("2.3.28")); @@ -43,7 +43,7 @@ public FileGenerator(OALScripts oalScripts, String outputPath) { public void generate() throws IOException, TemplateException { for (AnalysisResult result : results) { - generate(result, "Indicator.java", writer -> generateIndicatorImplementor(result, writer)); + generate(result, "Metrics.java", writer -> generateMetricsImplementor(result, writer)); String scopeName = result.getSourceName(); File file = new File(outputPath, "generated/" + scopeName.toLowerCase() + "/" + scopeName + "Dispatcher.java"); @@ -77,11 +77,11 @@ private void createFile(File file) throws IOException { private String buildSubFolderName(AnalysisResult result, String suffix) { return "generated/" + result.getSourceName().toLowerCase() + "/" - + result.getMetricName() + suffix; + + result.getMetricsName() + suffix; } - void generateIndicatorImplementor(AnalysisResult result, Writer output) throws IOException, TemplateException { - configuration.getTemplate("IndicatorImplementor.ftl").process(result, output); + void generateMetricsImplementor(AnalysisResult result, Writer output) throws IOException, TemplateException { + configuration.getTemplate("MetricsImplementor.ftl").process(result, output); } void generateDispatcher(AnalysisResult result, Writer output) throws IOException, TemplateException { @@ -103,7 +103,7 @@ private void buildDispatcherContext() { context.setPackageName(sourceName.toLowerCase()); allDispatcherContext.getAllContext().put(sourceName, context); } - context.getIndicators().add(result); + context.getMetrics().add(result); } } diff --git a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/AnalysisResult.java b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/AnalysisResult.java index 716594cf0217..20a7e49f13b8 100644 --- a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/AnalysisResult.java +++ b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/AnalysisResult.java @@ -26,7 +26,7 @@ public class AnalysisResult { private String varName; - private String metricName; + private String metricsName; private String tableName; @@ -40,7 +40,7 @@ public class AnalysisResult { private String aggregationFunctionName; - private String indicatorClassName; + private String metricsClassName; private EntryMethod entryMethod; diff --git a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/DeepAnalysis.java b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/DeepAnalysis.java index 34d8a633cce9..5645360724fe 100644 --- a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/DeepAnalysis.java +++ b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/DeepAnalysis.java @@ -22,19 +22,18 @@ import java.lang.reflect.*; import java.util.List; import org.apache.skywalking.oal.tool.util.ClassMethodUtil; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; import org.apache.skywalking.oap.server.core.storage.annotation.Column; public class DeepAnalysis { public AnalysisResult analysis(AnalysisResult result) { - // 1. Set sub package name by source.metric + // 1. Set sub package name by source.metrics result.setPackageName(result.getSourceName().toLowerCase()); - Class indicatorClass = Indicators.find(result.getAggregationFunctionName()); - String indicatorClassSimpleName = indicatorClass.getSimpleName(); + Class metricsClass = MetricsHolder.find(result.getAggregationFunctionName()); + String metricsClassSimpleName = metricsClass.getSimpleName(); - result.setIndicatorClassName(indicatorClassSimpleName); + result.setMetricsClassName(metricsClassSimpleName); // Optional for filter List expressions = result.getFilterExpressionsParserResult(); @@ -77,8 +76,8 @@ public AnalysisResult analysis(AnalysisResult result) { } } - // 3. Find Entrance method of this indicator - Class c = indicatorClass; + // 3. Find Entrance method of this metrics + Class c = metricsClass; Method entranceMethod = null; SearchEntrance: while (!c.equals(Object.class)) { @@ -92,7 +91,7 @@ public AnalysisResult analysis(AnalysisResult result) { c = c.getSuperclass(); } if (entranceMethod == null) { - throw new IllegalArgumentException("Can't find Entrance method in class: " + indicatorClass.getName()); + throw new IllegalArgumentException("Can't find Entrance method in class: " + metricsClass.getName()); } EntryMethod entryMethod = new EntryMethod(); result.setEntryMethod(entryMethod); @@ -138,8 +137,8 @@ public AnalysisResult analysis(AnalysisResult result) { } } - // 5. Get all column declared in Indicator class. - c = indicatorClass; + // 5. Get all column declared in MetricsHolder class. + c = metricsClass; while (!c.equals(Object.class)) { for (Field field : c.getDeclaredFields()) { Column column = field.getAnnotation(Column.class); diff --git a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/Indicators.java b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/MetricsHolder.java similarity index 56% rename from oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/Indicators.java rename to oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/MetricsHolder.java index 4138a7aa679e..56b90667baae 100644 --- a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/Indicators.java +++ b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/MetricsHolder.java @@ -22,31 +22,30 @@ import com.google.common.reflect.ClassPath; import java.io.IOException; import java.util.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorFunction; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsFunction; -public class Indicators { - private static Map> REGISTER = new HashMap<>(); +public class MetricsHolder { + private static Map> REGISTER = new HashMap<>(); public static void init() throws IOException { - ClassPath classpath = ClassPath.from(Indicators.class.getClassLoader()); + ClassPath classpath = ClassPath.from(MetricsHolder.class.getClassLoader()); ImmutableSet classes = classpath.getTopLevelClassesRecursive("org.apache.skywalking"); for (ClassPath.ClassInfo classInfo : classes) { Class aClass = classInfo.load(); - if (aClass.isAnnotationPresent(IndicatorFunction.class)) { - IndicatorFunction indicatorFunction = aClass.getAnnotation(IndicatorFunction.class); - REGISTER.put(indicatorFunction.functionName(), (Class)aClass); + if (aClass.isAnnotationPresent(MetricsFunction.class)) { + MetricsFunction metricsFunction = aClass.getAnnotation(MetricsFunction.class); + REGISTER.put(metricsFunction.functionName(), (Class)aClass); } } } - public static Class find(String functionName) { + public static Class find(String functionName) { String func = functionName; - Class indicatorClass = REGISTER.get(func); - if (indicatorClass == null) { - throw new IllegalArgumentException("Can't find indicator."); + Class metricsClass = REGISTER.get(func); + if (metricsClass == null) { + throw new IllegalArgumentException("Can't find metrics."); } - return indicatorClass; + return metricsClass; } } diff --git a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/OALListener.java b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/OALListener.java index 6433032a27ab..8af30730a668 100644 --- a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/OALListener.java +++ b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/OALListener.java @@ -31,7 +31,7 @@ public class OALListener extends OALParserBaseListener { private ConditionExpression conditionExpression; public OALListener(OALScripts scripts) { - this.results = scripts.getIndicatorStmts(); + this.results = scripts.getMetricsStmts(); this.collection = scripts.getDisableCollection(); } @@ -49,7 +49,7 @@ public void exitAggregationStatement(@NotNull OALParser.AggregationStatementCont @Override public void enterSource(OALParser.SourceContext ctx) { current.setSourceName(ctx.getText()); - current.setSourceScopeId(DefaultScopeDefine.valueOf(metricNameFormat(ctx.getText()))); + current.setSourceScopeId(DefaultScopeDefine.valueOf(metricsNameFormat(ctx.getText()))); } @Override @@ -62,7 +62,7 @@ public void enterSourceAttribute(OALParser.SourceAttributeContext ctx) { @Override public void exitVariable(OALParser.VariableContext ctx) { current.setVarName(ctx.getText()); - current.setMetricName(metricNameFormat(ctx.getText())); + current.setMetricsName(metricsNameFormat(ctx.getText())); current.setTableName(ctx.getText().toLowerCase()); } @@ -143,7 +143,7 @@ public void enterSourceAttribute(OALParser.SourceAttributeContext ctx) { current.addFuncArg(ctx.getText()); } - private String metricNameFormat(String source) { + private String metricsNameFormat(String source) { source = firstLetterUpper(source); int idx; while ((idx = source.indexOf("_")) > -1) { diff --git a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/OALScripts.java b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/OALScripts.java index 8d5b4fc42fd2..cfb427756eeb 100644 --- a/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/OALScripts.java +++ b/oap-server/generate-tool/src/main/java/org/apache/skywalking/oal/tool/parser/OALScripts.java @@ -23,11 +23,11 @@ @Getter public class OALScripts { - private List indicatorStmts; + private List metricsStmts; private DisableCollection disableCollection; public OALScripts() { - indicatorStmts = new LinkedList<>(); + metricsStmts = new LinkedList<>(); disableCollection = new DisableCollection(); } } diff --git a/oap-server/generate-tool/src/main/resources/code-templates/DispatcherTemplate.ftl b/oap-server/generate-tool/src/main/resources/code-templates/DispatcherTemplate.ftl index f814d727e0a3..3576b1be6607 100644 --- a/oap-server/generate-tool/src/main/resources/code-templates/DispatcherTemplate.ftl +++ b/oap-server/generate-tool/src/main/resources/code-templates/DispatcherTemplate.ftl @@ -19,11 +19,11 @@ package org.apache.skywalking.oap.server.core.analysis.generated.${packageName}; import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher; -<#if (indicators?size>0)> -import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess; - <#list indicators as indicator> - <#if indicator.filterExpressions??> -import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*; +<#if (metrics?size>0)> +import org.apache.skywalking.oap.server.core.analysis.worker.MetricsProcess; + <#list metrics as metrics> + <#if metrics.filterExpressions??> +import org.apache.skywalking.oap.server.core.analysis.metrics.expression.*; <#break> @@ -38,17 +38,17 @@ import org.apache.skywalking.oap.server.core.source.*; public class ${source}Dispatcher implements SourceDispatcher<${source}> { @Override public void dispatch(${source} source) { -<#list indicators as indicator> - do${indicator.metricName}(source); +<#list metrics as metrics> + do${metrics.metricsName}(source); } -<#list indicators as indicator> - private void do${indicator.metricName}(${source} source) { - ${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator(); +<#list metrics as metrics> + private void do${metrics.metricsName}(${source} source) { + ${metrics.metricsName}Metrics metrics = new ${metrics.metricsName}Metrics(); - <#if indicator.filterExpressions??> - <#list indicator.filterExpressions as filterExpression> + <#if metrics.filterExpressions??> + <#list metrics.filterExpressions as filterExpression> <#if filterExpression.expressionObject == "GreaterMatch" || filterExpression.expressionObject == "LessMatch" || filterExpression.expressionObject == "GreaterEqualMatch" || filterExpression.expressionObject == "LessEqualMatch"> if (!new ${filterExpression.expressionObject}().match(${filterExpression.left}, ${filterExpression.right})) { return; @@ -61,12 +61,12 @@ public class ${source}Dispatcher implements SourceDispatcher<${source}> { - indicator.setTimeBucket(source.getTimeBucket()); - <#list indicator.fieldsFromSource as field> - indicator.${field.fieldSetter}(source.${field.fieldGetter}()); + metrics.setTimeBucket(source.getTimeBucket()); + <#list metrics.fieldsFromSource as field> + metrics.${field.fieldSetter}(source.${field.fieldGetter}()); - indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, ); - IndicatorProcess.INSTANCE.in(indicator); + metrics.${metrics.entryMethod.methodName}(<#list metrics.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, ); + MetricsProcess.INSTANCE.in(metrics); } } diff --git a/oap-server/generate-tool/src/main/resources/code-templates/IndicatorImplementor.ftl b/oap-server/generate-tool/src/main/resources/code-templates/MetricsImplementor.ftl similarity index 72% rename from oap-server/generate-tool/src/main/resources/code-templates/IndicatorImplementor.ftl rename to oap-server/generate-tool/src/main/resources/code-templates/MetricsImplementor.ftl index aa7be17d53fd..a92caa6c5d2a 100644 --- a/oap-server/generate-tool/src/main/resources/code-templates/IndicatorImplementor.ftl +++ b/oap-server/generate-tool/src/main/resources/code-templates/MetricsImplementor.ftl @@ -28,8 +28,8 @@ import org.apache.skywalking.oap.server.core.Const; <#break> -import org.apache.skywalking.oap.server.core.analysis.indicator.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsType; import org.apache.skywalking.oap.server.core.remote.annotation.StreamData; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.apache.skywalking.oap.server.core.storage.annotation.*; @@ -40,10 +40,10 @@ import org.apache.skywalking.oap.server.core.storage.StorageBuilder; * * @author Observability Analysis Language code generator */ -@IndicatorType +@MetricsType @StreamData -@StorageEntity(name = "${tableName}", builder = ${metricName}Indicator.Builder.class, sourceScopeId = ${sourceScopeId}) -public class ${metricName}Indicator extends ${indicatorClassName} implements WithMetadata { +@StorageEntity(name = "${tableName}", builder = ${metricsName}Metrics.Builder.class, sourceScopeId = ${sourceScopeId}) +public class ${metricsName}Metrics extends ${metricsClassName} implements WithMetadata { <#list fieldsFromSource as sourceField> @Setter @Getter @Column(columnName = "${sourceField.columnName}") <#if sourceField.isID()>@IDColumn private ${sourceField.typeName} ${sourceField.fieldName}; @@ -100,19 +100,19 @@ public class ${metricName}Indicator extends ${indicatorClassName} implements Wit if (getClass() != obj.getClass()) return false; - ${metricName}Indicator indicator = (${metricName}Indicator)obj; + ${metricsName}Metrics metrics = (${metricsName}Metrics)obj; <#list fieldsFromSource as sourceField> <#if sourceField.isID()> <#if sourceField.getTypeName() == "java.lang.String"> - if (!${sourceField.fieldName}.equals(indicator.${sourceField.fieldName})) + if (!${sourceField.fieldName}.equals(metrics.${sourceField.fieldName})) <#else> - if (${sourceField.fieldName} != indicator.${sourceField.fieldName}) + if (${sourceField.fieldName} != metrics.${sourceField.fieldName}) return false; - if (getTimeBucket() != indicator.getTimeBucket()) + if (getTimeBucket() != metrics.getTimeBucket()) return false; return true; @@ -168,97 +168,97 @@ public class ${metricName}Indicator extends ${indicatorClassName} implements Wit } - @Override public IndicatorMetaInfo getMeta() { - return new IndicatorMetaInfo("${varName}", ${sourceScopeId}<#if (fieldsFromSource?size>0) ><#list fieldsFromSource as field><#if field.isID()>, ${field.fieldName}); + @Override public MetricsMetaInfo getMeta() { + return new MetricsMetaInfo("${varName}", ${sourceScopeId}<#if (fieldsFromSource?size>0) ><#list fieldsFromSource as field><#if field.isID()>, ${field.fieldName}); } @Override - public Indicator toHour() { - ${metricName}Indicator indicator = new ${metricName}Indicator(); + public Metrics toHour() { + ${metricsName}Metrics metrics = new ${metricsName}Metrics(); <#list fieldsFromSource as field> <#if field.columnName == "time_bucket"> - indicator.setTimeBucket(toTimeBucketInHour()); + metrics.setTimeBucket(toTimeBucketInHour()); <#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float"> - indicator.${field.fieldSetter}(this.${field.fieldGetter}()); + metrics.${field.fieldSetter}(this.${field.fieldGetter}()); <#else> ${field.typeName} newValue = new ${field.typeName}(); newValue.copyFrom(this.${field.fieldGetter}()); - indicator.${field.fieldSetter}(newValue); + metrics.${field.fieldSetter}(newValue); <#list persistentFields as field> <#if field.columnName == "time_bucket"> - indicator.setTimeBucket(toTimeBucketInHour()); + metrics.setTimeBucket(toTimeBucketInHour()); <#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float"> - indicator.${field.fieldSetter}(this.${field.fieldGetter}()); + metrics.${field.fieldSetter}(this.${field.fieldGetter}()); <#else> ${field.typeName} newValue = new ${field.typeName}(); newValue.copyFrom(this.${field.fieldGetter}()); - indicator.${field.fieldSetter}(newValue); + metrics.${field.fieldSetter}(newValue); - return indicator; + return metrics; } @Override - public Indicator toDay() { - ${metricName}Indicator indicator = new ${metricName}Indicator(); + public Metrics toDay() { + ${metricsName}Metrics metrics = new ${metricsName}Metrics(); <#list fieldsFromSource as field> <#if field.columnName == "time_bucket"> - indicator.setTimeBucket(toTimeBucketInDay()); + metrics.setTimeBucket(toTimeBucketInDay()); <#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float"> - indicator.${field.fieldSetter}(this.${field.fieldGetter}()); + metrics.${field.fieldSetter}(this.${field.fieldGetter}()); <#else> ${field.typeName} newValue = new ${field.typeName}(); newValue.copyFrom(this.${field.fieldGetter}()); - indicator.${field.fieldSetter}(newValue); + metrics.${field.fieldSetter}(newValue); <#list persistentFields as field> <#if field.columnName == "time_bucket"> - indicator.setTimeBucket(toTimeBucketInDay()); + metrics.setTimeBucket(toTimeBucketInDay()); <#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float"> - indicator.${field.fieldSetter}(this.${field.fieldGetter}()); + metrics.${field.fieldSetter}(this.${field.fieldGetter}()); <#else> ${field.typeName} newValue = new ${field.typeName}(); newValue.copyFrom(this.${field.fieldGetter}()); - indicator.${field.fieldSetter}(newValue); + metrics.${field.fieldSetter}(newValue); - return indicator; + return metrics; } @Override - public Indicator toMonth() { - ${metricName}Indicator indicator = new ${metricName}Indicator(); + public Metrics toMonth() { + ${metricsName}Metrics metrics = new ${metricsName}Metrics(); <#list fieldsFromSource as field> <#if field.columnName == "time_bucket"> - indicator.setTimeBucket(toTimeBucketInMonth()); + metrics.setTimeBucket(toTimeBucketInMonth()); <#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float"> - indicator.${field.fieldSetter}(this.${field.fieldGetter}()); + metrics.${field.fieldSetter}(this.${field.fieldGetter}()); <#else> ${field.typeName} newValue = new ${field.typeName}(); newValue.copyFrom(this.${field.fieldGetter}()); - indicator.${field.fieldSetter}(newValue); + metrics.${field.fieldSetter}(newValue); <#list persistentFields as field> <#if field.columnName == "time_bucket"> - indicator.setTimeBucket(toTimeBucketInMonth()); + metrics.setTimeBucket(toTimeBucketInMonth()); <#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float"> - indicator.${field.fieldSetter}(this.${field.fieldGetter}()); + metrics.${field.fieldSetter}(this.${field.fieldGetter}()); <#else> ${field.typeName} newValue = new ${field.typeName}(); newValue.copyFrom(this.${field.fieldGetter}()); - indicator.${field.fieldSetter}(newValue); + metrics.${field.fieldSetter}(newValue); - return indicator; + return metrics; } - public static class Builder implements StorageBuilder<${metricName}Indicator> { + public static class Builder implements StorageBuilder<${metricsName}Metrics> { - @Override public Map data2Map(${metricName}Indicator storageData) { + @Override public Map data2Map(${metricsName}Metrics storageData) { Map map = new HashMap<>(); <#list fieldsFromSource as field> map.put("${field.columnName}", storageData.${field.fieldGetter}()); @@ -269,27 +269,27 @@ public class ${metricName}Indicator extends ${indicatorClassName} implements Wit return map; } - @Override public ${metricName}Indicator map2Data(Map dbMap) { - ${metricName}Indicator indicator = new ${metricName}Indicator(); + @Override public ${metricsName}Metrics map2Data(Map dbMap) { + ${metricsName}Metrics metrics = new ${metricsName}Metrics(); <#list fieldsFromSource as field> <#if field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float"> - indicator.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value()); + metrics.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value()); <#elseif field.typeName == "java.lang.String"> - indicator.${field.fieldSetter}((String)dbMap.get("${field.columnName}")); + metrics.${field.fieldSetter}((String)dbMap.get("${field.columnName}")); <#else> - indicator.${field.fieldSetter}(new ${field.typeName}((String)dbMap.get("${field.columnName}"))); + metrics.${field.fieldSetter}(new ${field.typeName}((String)dbMap.get("${field.columnName}"))); <#list persistentFields as field> <#if field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float"> - indicator.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value()); + metrics.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value()); <#elseif field.typeName == "java.lang.String"> - indicator.${field.fieldSetter}((String)dbMap.get("${field.columnName}")); + metrics.${field.fieldSetter}((String)dbMap.get("${field.columnName}")); <#else> - indicator.${field.fieldSetter}(new ${field.typeName}((String)dbMap.get("${field.columnName}"))); + metrics.${field.fieldSetter}(new ${field.typeName}((String)dbMap.get("${field.columnName}"))); - return indicator; + return metrics; } } } diff --git a/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/output/FileGeneratorTest.java b/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/output/FileGeneratorTest.java index 1a708264e8d8..88ce38c63d2c 100644 --- a/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/output/FileGeneratorTest.java +++ b/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/output/FileGeneratorTest.java @@ -20,7 +20,7 @@ import freemarker.template.TemplateException; import java.io.*; -import java.util.*; +import java.util.LinkedList; import org.apache.skywalking.oal.tool.meta.*; import org.apache.skywalking.oal.tool.parser.*; import org.junit.*; @@ -36,15 +36,15 @@ public static void init() { private AnalysisResult buildResult() { AnalysisResult result = new AnalysisResult(); - result.setVarName("generate_indicator"); + result.setVarName("generate_metrics"); result.setSourceName("Service"); result.setSourceScopeId(1); result.setPackageName("service.serviceavg"); result.setTableName("service_avg"); result.setSourceAttribute("latency"); - result.setMetricName("ServiceAvg"); + result.setMetricsName("ServiceAvg"); result.setAggregationFunctionName("avg"); - result.setIndicatorClassName("LongAvgIndicator"); + result.setMetricsClassName("LongAvgMetrics"); FilterExpression equalExpression = new FilterExpression(); equalExpression.setExpressionObject("EqualMatch"); @@ -76,18 +76,18 @@ private AnalysisResult buildResult() { } @Test - public void testGenerateIndicatorImplementor() throws IOException, TemplateException { + public void testGenerateMetricsImplementor() throws IOException, TemplateException { AnalysisResult result = buildResult(); OALScripts oalScripts = new OALScripts(); - oalScripts.getIndicatorStmts().add(result); + oalScripts.getMetricsStmts().add(result); FileGenerator fileGenerator = new FileGenerator(oalScripts, "."); StringWriter writer = new StringWriter(); - fileGenerator.generateIndicatorImplementor(result, writer); - Assert.assertEquals(readExpectedFile("IndicatorImplementorExpected.java"), writer.toString()); + fileGenerator.generateMetricsImplementor(result, writer); + Assert.assertEquals(readExpectedFile("MetricsImplementorExpected.java"), writer.toString()); - // fileGenerator.generateIndicatorImplementor(result, new OutputStreamWriter(System.out)); +// fileGenerator.generateMetricsImplementor(result, new OutputStreamWriter(System.out)); } @Test @@ -95,7 +95,7 @@ public void testServiceDispatcher() throws IOException, TemplateException { AnalysisResult result = buildResult(); OALScripts oalScripts = new OALScripts(); - oalScripts.getIndicatorStmts().add(result); + oalScripts.getMetricsStmts().add(result); FileGenerator fileGenerator = new FileGenerator(oalScripts, "."); StringWriter writer = new StringWriter(); diff --git a/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/parser/DeepAnalysisTest.java b/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/parser/DeepAnalysisTest.java index 14826176764d..0334ae7ed986 100644 --- a/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/parser/DeepAnalysisTest.java +++ b/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/parser/DeepAnalysisTest.java @@ -30,7 +30,7 @@ public static void init() throws IOException { InputStream stream = MetaReaderTest.class.getResourceAsStream("/scope-meta.yml"); MetaSettings metaSettings = reader.read(stream); SourceColumnsFactory.setSettings(metaSettings); - Indicators.init(); + MetricsHolder.init(); } @Test @@ -39,7 +39,7 @@ public void testServiceAnalysis() { result.setSourceName("Service"); result.setPackageName("service.serviceavg"); result.setSourceAttribute("latency"); - result.setMetricName("ServiceAvg"); + result.setMetricsName("ServiceAvg"); result.setAggregationFunctionName("longAvg"); DeepAnalysis analysis = new DeepAnalysis(); @@ -63,7 +63,7 @@ public void testEndpointAnalysis() { result.setSourceName("Endpoint"); result.setPackageName("endpoint.endpointavg"); result.setSourceAttribute("latency"); - result.setMetricName("EndpointAvg"); + result.setMetricsName("EndpointAvg"); result.setAggregationFunctionName("longAvg"); DeepAnalysis analysis = new DeepAnalysis(); @@ -87,7 +87,7 @@ public void testFilterAnalysis() { result.setSourceName("Endpoint"); result.setPackageName("endpoint.endpointavg"); result.setSourceAttribute("latency"); - result.setMetricName("EndpointAvg"); + result.setMetricsName("EndpointAvg"); result.setAggregationFunctionName("longAvg"); ConditionExpression expression = new ConditionExpression(); expression.setExpressionType("stringMatch"); diff --git a/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/parser/ScriptParserTest.java b/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/parser/ScriptParserTest.java index 041f0e70087c..59c384914253 100644 --- a/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/parser/ScriptParserTest.java +++ b/oap-server/generate-tool/src/test/java/org/apache/skywalking/oal/tool/parser/ScriptParserTest.java @@ -32,7 +32,7 @@ public static void init() throws IOException { InputStream stream = MetaReaderTest.class.getResourceAsStream("/scope-meta.yml"); MetaSettings metaSettings = reader.read(stream); SourceColumnsFactory.setSettings(metaSettings); - Indicators.init(); + MetricsHolder.init(); AnnotationScan scopeScan = new AnnotationScan(); scopeScan.registerListener(new DefaultScopeDefine.Listener()); @@ -50,18 +50,18 @@ public void testParse() throws IOException { "Endpoint_avg = from(Endpoint.latency).longAvg(); //comment test" + "\n" + "Service_avg = from(Service.latency).longAvg()" ); - List results = parser.parse().getIndicatorStmts(); + List results = parser.parse().getMetricsStmts(); Assert.assertEquals(2, results.size()); AnalysisResult endpointAvg = results.get(0); - Assert.assertEquals("EndpointAvg", endpointAvg.getMetricName()); + Assert.assertEquals("EndpointAvg", endpointAvg.getMetricsName()); Assert.assertEquals("Endpoint", endpointAvg.getSourceName()); Assert.assertEquals("latency", endpointAvg.getSourceAttribute()); Assert.assertEquals("longAvg", endpointAvg.getAggregationFunctionName()); AnalysisResult serviceAvg = results.get(1); - Assert.assertEquals("ServiceAvg", serviceAvg.getMetricName()); + Assert.assertEquals("ServiceAvg", serviceAvg.getMetricsName()); Assert.assertEquals("Service", serviceAvg.getSourceName()); Assert.assertEquals("latency", serviceAvg.getSourceAttribute()); Assert.assertEquals("longAvg", serviceAvg.getAggregationFunctionName()); @@ -72,10 +72,10 @@ public void testParse2() throws IOException { ScriptParser parser = ScriptParser.createFromScriptText( "Endpoint_percent = from(Endpoint.*).percent(status == true);" ); - List results = parser.parse().getIndicatorStmts(); + List results = parser.parse().getMetricsStmts(); AnalysisResult endpointPercent = results.get(0); - Assert.assertEquals("EndpointPercent", endpointPercent.getMetricName()); + Assert.assertEquals("EndpointPercent", endpointPercent.getMetricsName()); Assert.assertEquals("Endpoint", endpointPercent.getSourceName()); Assert.assertEquals("*", endpointPercent.getSourceAttribute()); Assert.assertEquals("percent", endpointPercent.getAggregationFunctionName()); @@ -91,10 +91,10 @@ public void testParse3() throws IOException { ScriptParser parser = ScriptParser.createFromScriptText( "Endpoint_percent = from(Endpoint.*).filter(status == true).filter(name == \"/product/abc\").longAvg();" ); - List results = parser.parse().getIndicatorStmts(); + List results = parser.parse().getMetricsStmts(); AnalysisResult endpointPercent = results.get(0); - Assert.assertEquals("EndpointPercent", endpointPercent.getMetricName()); + Assert.assertEquals("EndpointPercent", endpointPercent.getMetricsName()); Assert.assertEquals("Endpoint", endpointPercent.getSourceName()); Assert.assertEquals("*", endpointPercent.getSourceAttribute()); Assert.assertEquals("longAvg", endpointPercent.getAggregationFunctionName()); @@ -121,10 +121,10 @@ public void testParse4() throws IOException { "service_response_s3_summary = from(Service.latency).filter(latency >= 3000).sum();" + "\n" + "service_response_s4_summary = from(Service.latency).filter(latency <= 4000).sum();" ); - List results = parser.parse().getIndicatorStmts(); + List results = parser.parse().getMetricsStmts(); AnalysisResult responseSummary = results.get(0); - Assert.assertEquals("ServiceResponseS1Summary", responseSummary.getMetricName()); + Assert.assertEquals("ServiceResponseS1Summary", responseSummary.getMetricsName()); Assert.assertEquals("Service", responseSummary.getSourceName()); Assert.assertEquals("latency", responseSummary.getSourceAttribute()); Assert.assertEquals("sum", responseSummary.getAggregationFunctionName()); diff --git a/oap-server/generate-tool/src/test/resources/expectedFiles/IndicatorImplementorExpected.java b/oap-server/generate-tool/src/test/resources/expectedFiles/MetricsImplementorExpected.java similarity index 59% rename from oap-server/generate-tool/src/test/resources/expectedFiles/IndicatorImplementorExpected.java rename to oap-server/generate-tool/src/test/resources/expectedFiles/MetricsImplementorExpected.java index 25a102a9fa13..f46403596094 100644 --- a/oap-server/generate-tool/src/test/resources/expectedFiles/IndicatorImplementorExpected.java +++ b/oap-server/generate-tool/src/test/resources/expectedFiles/MetricsImplementorExpected.java @@ -21,8 +21,8 @@ import java.util.*; import lombok.*; import org.apache.skywalking.oap.server.core.Const; -import org.apache.skywalking.oap.server.core.analysis.indicator.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsType; import org.apache.skywalking.oap.server.core.remote.annotation.StreamData; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.apache.skywalking.oap.server.core.storage.annotation.*; @@ -33,10 +33,10 @@ * * @author Observability Analysis Language code generator */ -@IndicatorType +@MetricsType @StreamData -@StorageEntity(name = "service_avg", builder = ServiceAvgIndicator.Builder.class, sourceScopeId = 1) -public class ServiceAvgIndicator extends LongAvgIndicator implements WithMetadata { +@StorageEntity(name = "service_avg", builder = ServiceAvgMetrics.Builder.class, sourceScopeId = 1) +public class ServiceAvgMetrics extends LongAvgMetrics implements WithMetadata { @Setter @Getter @Column(columnName = "entity_id") @IDColumn private java.lang.String entityId; @@ -67,11 +67,11 @@ public class ServiceAvgIndicator extends LongAvgIndicator implements WithMetadat if (getClass() != obj.getClass()) return false; - ServiceAvgIndicator indicator = (ServiceAvgIndicator)obj; - if (!entityId.equals(indicator.entityId)) + ServiceAvgMetrics metrics = (ServiceAvgMetrics)obj; + if (!entityId.equals(metrics.entityId)) return false; - if (getTimeBucket() != indicator.getTimeBucket()) + if (getTimeBucket() != metrics.getTimeBucket()) return false; return true; @@ -106,49 +106,49 @@ public class ServiceAvgIndicator extends LongAvgIndicator implements WithMetadat } - @Override public IndicatorMetaInfo getMeta() { - return new IndicatorMetaInfo("generate_indicator", 1, entityId); + @Override public MetricsMetaInfo getMeta() { + return new MetricsMetaInfo("generate_metrics", 1, entityId); } @Override - public Indicator toHour() { - ServiceAvgIndicator indicator = new ServiceAvgIndicator(); - indicator.setEntityId(this.getEntityId()); - indicator.setSummation(this.getSummation()); - indicator.setCount(this.getCount()); - indicator.setValue(this.getValue()); - indicator.setTimeBucket(toTimeBucketInHour()); - indicator.setStringField(this.getStringField()); - return indicator; + public Metrics toHour() { + ServiceAvgMetrics metrics = new ServiceAvgMetrics(); + metrics.setEntityId(this.getEntityId()); + metrics.setSummation(this.getSummation()); + metrics.setCount(this.getCount()); + metrics.setValue(this.getValue()); + metrics.setTimeBucket(toTimeBucketInHour()); + metrics.setStringField(this.getStringField()); + return metrics; } @Override - public Indicator toDay() { - ServiceAvgIndicator indicator = new ServiceAvgIndicator(); - indicator.setEntityId(this.getEntityId()); - indicator.setSummation(this.getSummation()); - indicator.setCount(this.getCount()); - indicator.setValue(this.getValue()); - indicator.setTimeBucket(toTimeBucketInDay()); - indicator.setStringField(this.getStringField()); - return indicator; + public Metrics toDay() { + ServiceAvgMetrics metrics = new ServiceAvgMetrics(); + metrics.setEntityId(this.getEntityId()); + metrics.setSummation(this.getSummation()); + metrics.setCount(this.getCount()); + metrics.setValue(this.getValue()); + metrics.setTimeBucket(toTimeBucketInDay()); + metrics.setStringField(this.getStringField()); + return metrics; } @Override - public Indicator toMonth() { - ServiceAvgIndicator indicator = new ServiceAvgIndicator(); - indicator.setEntityId(this.getEntityId()); - indicator.setSummation(this.getSummation()); - indicator.setCount(this.getCount()); - indicator.setValue(this.getValue()); - indicator.setTimeBucket(toTimeBucketInMonth()); - indicator.setStringField(this.getStringField()); - return indicator; + public Metrics toMonth() { + ServiceAvgMetrics metrics = new ServiceAvgMetrics(); + metrics.setEntityId(this.getEntityId()); + metrics.setSummation(this.getSummation()); + metrics.setCount(this.getCount()); + metrics.setValue(this.getValue()); + metrics.setTimeBucket(toTimeBucketInMonth()); + metrics.setStringField(this.getStringField()); + return metrics; } - public static class Builder implements StorageBuilder { + public static class Builder implements StorageBuilder { - @Override public Map data2Map(ServiceAvgIndicator storageData) { + @Override public Map data2Map(ServiceAvgMetrics storageData) { Map map = new HashMap<>(); map.put("entity_id", storageData.getEntityId()); map.put("summation", storageData.getSummation()); @@ -159,15 +159,15 @@ public static class Builder implements StorageBuilder { return map; } - @Override public ServiceAvgIndicator map2Data(Map dbMap) { - ServiceAvgIndicator indicator = new ServiceAvgIndicator(); - indicator.setEntityId((String)dbMap.get("entity_id")); - indicator.setSummation(((Number)dbMap.get("summation")).longValue()); - indicator.setCount(((Number)dbMap.get("count")).intValue()); - indicator.setValue(((Number)dbMap.get("value")).longValue()); - indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue()); - indicator.setStringField((String)dbMap.get("string_field")); - return indicator; + @Override public ServiceAvgMetrics map2Data(Map dbMap) { + ServiceAvgMetrics metrics = new ServiceAvgMetrics(); + metrics.setEntityId((String)dbMap.get("entity_id")); + metrics.setSummation(((Number)dbMap.get("summation")).longValue()); + metrics.setCount(((Number)dbMap.get("count")).intValue()); + metrics.setValue(((Number)dbMap.get("value")).longValue()); + metrics.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue()); + metrics.setStringField((String)dbMap.get("string_field")); + return metrics; } } -} +} \ No newline at end of file diff --git a/oap-server/generate-tool/src/test/resources/expectedFiles/ServiceDispatcherExpected.java b/oap-server/generate-tool/src/test/resources/expectedFiles/ServiceDispatcherExpected.java index d673df7057cc..92f27fe95d40 100644 --- a/oap-server/generate-tool/src/test/resources/expectedFiles/ServiceDispatcherExpected.java +++ b/oap-server/generate-tool/src/test/resources/expectedFiles/ServiceDispatcherExpected.java @@ -19,8 +19,8 @@ package org.apache.skywalking.oap.server.core.analysis.generated.service; import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher; -import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess; -import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*; +import org.apache.skywalking.oap.server.core.analysis.worker.MetricsProcess; +import org.apache.skywalking.oap.server.core.analysis.metrics.expression.*; import org.apache.skywalking.oap.server.core.source.*; /** @@ -35,7 +35,7 @@ public class ServiceDispatcher implements SourceDispatcher { } private void doServiceAvg(Service source) { - ServiceAvgIndicator indicator = new ServiceAvgIndicator(); + ServiceAvgMetrics metrics = new ServiceAvgMetrics(); if (!new EqualMatch().setLeft(source.getName()).setRight("/service/prod/save").match()) { return; @@ -44,9 +44,9 @@ private void doServiceAvg(Service source) { return; } - indicator.setTimeBucket(source.getTimeBucket()); - indicator.setEntityId(source.getEntityId()); - indicator.combine(source.getLatency(), 1); - IndicatorProcess.INSTANCE.in(indicator); + metrics.setTimeBucket(source.getTimeBucket()); + metrics.setEntityId(source.getEntityId()); + metrics.combine(source.getLatency(), 1); + MetricsProcess.INSTANCE.in(metrics); } } diff --git a/oap-server/generate-tool/src/test/resources/oal_test.oal b/oap-server/generate-tool/src/test/resources/oal_test.oal index da37d26c23ed..bfdc5aa41470 100644 --- a/oap-server/generate-tool/src/test/resources/oal_test.oal +++ b/oap-server/generate-tool/src/test/resources/oal_test.oal @@ -16,7 +16,7 @@ * */ -// All scope metric +// All scope metrics all_p99 = from(All.latency).p99(10); all_p95 = from(All.latency).p95(10); all_p90 = from(All.latency).p90(10); @@ -24,7 +24,7 @@ all_p75 = from(All.latency).p75(10); all_p50 = from(All.latency).p50(10); all_heatmap = from(All.latency).thermodynamic(100, 20); -// Service scope metric +// Service scope metrics service_resp_time = from(Service.latency).longAvg(); service_sla = from(Service.*).percent(status == true); service_cpm = from(Service.*).cpm(); @@ -34,7 +34,7 @@ service_p90 = from(Service.latency).p90(10); service_p75 = from(Service.latency).p75(10); service_p50 = from(Service.latency).p50(10); -// Service relation scope metric for topology +// Service relation scope metrics for topology service_relation_client_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).cpm(); service_relation_server_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm(); service_relation_client_call_sla = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).percent(status == true); @@ -42,12 +42,12 @@ service_relation_server_call_sla = from(ServiceRelation.*).filter(detectPoint == service_relation_client_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.CLIENT).longAvg(); service_relation_server_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.SERVER).longAvg(); -// Service Instance Scope metric +// Service Instance Scope metrics service_instance_sla = from(ServiceInstance.*).percent(status == true); service_instance_resp_time= from(ServiceInstance.latency).longAvg(); service_instance_cpm = from(ServiceInstance.*).cpm(); -// Endpoint scope metric +// Endpoint scope metrics endpoint_cpm = from(Endpoint.*).cpm(); endpoint_avg = from(Endpoint.latency).longAvg(); endpoint_sla = from(Endpoint.*).percent(status == true); @@ -57,11 +57,11 @@ endpoint_p90 = from(Endpoint.latency).p90(10); endpoint_p75 = from(Endpoint.latency).p75(10); endpoint_p50 = from(Endpoint.latency).p50(10); -// Endpoint relation scope metric +// Endpoint relation scope metrics endpoint_relation_cpm = from(EndpointRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm(); endpoint_relation_resp_time = from(EndpointRelation.rpcLatency).filter(detectPoint == DetectPoint.SERVER).longAvg(); -// JVM instance metric +// JVM instance metrics instance_jvm_cpu = from(ServiceInstanceJVMCPU.usePercent).doubleAvg(); instance_jvm_memory_heap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == true).longAvg(); instance_jvm_memory_noheap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == false).longAvg(); diff --git a/oap-server/generated-analysis/src/main/resources/official_analysis.oal b/oap-server/generated-analysis/src/main/resources/official_analysis.oal index 66b664ab2a48..c720b5931e2f 100644 --- a/oap-server/generated-analysis/src/main/resources/official_analysis.oal +++ b/oap-server/generated-analysis/src/main/resources/official_analysis.oal @@ -16,7 +16,7 @@ * */ -// All scope metric +// All scope metrics all_p99 = from(All.latency).p99(10); all_p95 = from(All.latency).p95(10); all_p90 = from(All.latency).p90(10); @@ -24,7 +24,7 @@ all_p75 = from(All.latency).p75(10); all_p50 = from(All.latency).p50(10); all_heatmap = from(All.latency).thermodynamic(100, 20); -// Service scope metric +// Service scope metrics service_resp_time = from(Service.latency).longAvg(); service_sla = from(Service.*).percent(status == true); service_cpm = from(Service.*).cpm(); @@ -34,7 +34,7 @@ service_p90 = from(Service.latency).p90(10); service_p75 = from(Service.latency).p75(10); service_p50 = from(Service.latency).p50(10); -// Service relation scope metric for topology +// Service relation scope metrics for topology service_relation_client_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).cpm(); service_relation_server_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm(); service_relation_client_call_sla = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).percent(status == true); @@ -42,12 +42,12 @@ service_relation_server_call_sla = from(ServiceRelation.*).filter(detectPoint == service_relation_client_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.CLIENT).longAvg(); service_relation_server_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.SERVER).longAvg(); -// Service Instance Scope metric +// Service Instance Scope metrics service_instance_sla = from(ServiceInstance.*).percent(status == true); service_instance_resp_time= from(ServiceInstance.latency).longAvg(); service_instance_cpm = from(ServiceInstance.*).cpm(); -// Endpoint scope metric +// Endpoint scope metrics endpoint_cpm = from(Endpoint.*).cpm(); endpoint_avg = from(Endpoint.latency).longAvg(); endpoint_sla = from(Endpoint.*).percent(status == true); @@ -57,11 +57,11 @@ endpoint_p90 = from(Endpoint.latency).p90(10); endpoint_p75 = from(Endpoint.latency).p75(10); endpoint_p50 = from(Endpoint.latency).p50(10); -// Endpoint relation scope metric +// Endpoint relation scope metrics endpoint_relation_cpm = from(EndpointRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm(); endpoint_relation_resp_time = from(EndpointRelation.rpcLatency).filter(detectPoint == DetectPoint.SERVER).longAvg(); -// JVM instance metric +// JVM instance metrics instance_jvm_cpu = from(ServiceInstanceJVMCPU.usePercent).doubleAvg(); instance_jvm_memory_heap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == true).longAvg(); instance_jvm_memory_noheap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == false).longAvg(); @@ -81,7 +81,7 @@ database_access_p90 = from(DatabaseAccess.latency).p90(10); database_access_p75 = from(DatabaseAccess.latency).p75(10); database_access_p50 = from(DatabaseAccess.latency).p50(10); -// CLR instance metric +// CLR instance metrics instance_clr_cpu = from(ServiceInstanceCLRCPU.usePercent).doubleAvg(); instance_clr_gen0_collect_count = from(ServiceInstanceCLRGC.gen0CollectCount).sum(); instance_clr_gen1_collect_count = from(ServiceInstanceCLRGC.gen1CollectCount).sum(); @@ -92,7 +92,7 @@ instance_clr_available_worker_threads = from(ServiceInstanceCLRThread.availableW instance_clr_max_completion_port_threads = from(ServiceInstanceCLRThread.maxCompletionPortThreads).max(); instance_clr_max_worker_threads = from(ServiceInstanceCLRThread.maxWorkerThreads).max(); -// Envoy instance metric +// Envoy instance metrics envoy_heap_memory_max_used = from(EnvoyInstanceMetric.value).filter(metricName == "server.memory_heap_size").maxDouble(); envoy_total_connections_used = from(EnvoyInstanceMetric.value).filter(metricName == "server.total_connections").maxDouble(); envoy_parent_connections_used = from(EnvoyInstanceMetric.value).filter(metricName == "server.parent_connections").maxDouble(); diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmCore.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmCore.java index 1b83b07125a6..852629deda07 100644 --- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmCore.java +++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmCore.java @@ -18,22 +18,14 @@ package org.apache.skywalking.oap.server.core.alarm.provider; -import org.apache.skywalking.oap.server.core.alarm.AlarmCallback; -import org.apache.skywalking.oap.server.core.alarm.AlarmMessage; -import org.joda.time.LocalDateTime; -import org.joda.time.Minutes; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; +import java.util.*; +import java.util.concurrent.*; +import org.apache.skywalking.oap.server.core.alarm.*; +import org.joda.time.*; +import org.slf4j.*; /** - * Alarm core includes metric values in certain time windows based on alarm settings. By using its internal timer + * Alarm core includes metrics values in certain time windows based on alarm settings. By using its internal timer * trigger and the alarm rules to decides whether send the alarm to database and webhook(s) * * @author wusheng @@ -49,16 +41,16 @@ public class AlarmCore { rules.getRules().forEach(rule -> { RunningRule runningRule = new RunningRule(rule); - String indicatorName = rule.getIndicatorName(); + String metricsName = rule.getMetricsName(); - List runningRules = runningContext.computeIfAbsent(indicatorName, key -> new ArrayList<>()); + List runningRules = runningContext.computeIfAbsent(metricsName, key -> new ArrayList<>()); runningRules.add(runningRule); }); } - public List findRunningRule(String indicatorName) { - return runningContext.get(indicatorName); + public List findRunningRule(String metricsName) { + return runningContext.get(metricsName); } public void start(List allCallbacks) { @@ -69,7 +61,7 @@ public void start(List allCallbacks) { List alarmMessageList = new ArrayList<>(30); LocalDateTime checkTime = LocalDateTime.now(); int minutes = Minutes.minutesBetween(lastExecuteTime, checkTime).getMinutes(); - boolean[] hasExecute = new boolean[]{false}; + boolean[] hasExecute = new boolean[] {false}; runningContext.values().forEach(ruleList -> ruleList.forEach(runningRule -> { if (minutes > 0) { runningRule.moveTo(checkTime); diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java index 87fd321701c0..4c6dc6fc49bb 100644 --- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java +++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmModuleProvider.java @@ -50,7 +50,7 @@ public class AlarmModuleProvider extends ModuleProvider { Rules rules = reader.readRules(); notifyHandler = new NotifyHandler(rules); notifyHandler.init(new AlarmStandardPersistence()); - this.registerServiceImplementation(IndicatorNotify.class, notifyHandler); + this.registerServiceImplementation(MetricsNotify.class, notifyHandler); } @Override public void start() throws ServiceNotProvidedException, ModuleStartException { diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmRule.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmRule.java index 03f299f8d0be..8d55aadd4241 100644 --- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmRule.java +++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmRule.java @@ -31,7 +31,7 @@ public class AlarmRule { private String alarmRuleName; - private String indicatorName; + private String metricsName; private ArrayList includeNames; private String threshold; private String op; diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/IndicatorValueType.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/MetricsValueType.java similarity index 96% rename from oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/IndicatorValueType.java rename to oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/MetricsValueType.java index 51b7003f0c32..04e95648c621 100644 --- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/IndicatorValueType.java +++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/MetricsValueType.java @@ -18,6 +18,6 @@ package org.apache.skywalking.oap.server.core.alarm.provider; -public enum IndicatorValueType { +public enum MetricsValueType { LONG, INT, DOUBLE } diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java index 10a4a02ea654..3341cf8957b4 100644 --- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java +++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java @@ -21,13 +21,13 @@ import java.util.*; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.alarm.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; import org.apache.skywalking.oap.server.core.cache.*; import org.apache.skywalking.oap.server.core.register.*; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; import org.apache.skywalking.oap.server.library.module.ModuleManager; -public class NotifyHandler implements IndicatorNotify { +public class NotifyHandler implements MetricsNotify { private ServiceInventoryCache serviceInventoryCache; private ServiceInstanceInventoryCache serviceInstanceInventoryCache; private EndpointInventoryCache endpointInventoryCache; @@ -40,9 +40,9 @@ public NotifyHandler(Rules rules) { core = new AlarmCore(rules); } - @Override public void notify(Indicator indicator) { - WithMetadata withMetadata = (WithMetadata)indicator; - IndicatorMetaInfo meta = withMetadata.getMeta(); + @Override public void notify(Metrics metrics) { + WithMetadata withMetadata = (WithMetadata)metrics; + MetricsMetaInfo meta = withMetadata.getMeta(); int scope = meta.getScope(); if (!DefaultScopeDefine.inServiceCatalog(scope) @@ -56,7 +56,7 @@ public NotifyHandler(Rules rules) { int serviceId = Integer.parseInt(meta.getId()); ServiceInventory serviceInventory = serviceInventoryCache.get(serviceId); ServiceMetaInAlarm serviceMetaInAlarm = new ServiceMetaInAlarm(); - serviceMetaInAlarm.setIndicatorName(meta.getIndicatorName()); + serviceMetaInAlarm.setMetricsName(meta.getMetricsName()); serviceMetaInAlarm.setId(serviceId); serviceMetaInAlarm.setName(serviceInventory.getName()); metaInAlarm = serviceMetaInAlarm; @@ -64,7 +64,7 @@ public NotifyHandler(Rules rules) { int serviceInstanceId = Integer.parseInt(meta.getId()); ServiceInstanceInventory serviceInstanceInventory = serviceInstanceInventoryCache.get(serviceInstanceId); ServiceInstanceMetaInAlarm instanceMetaInAlarm = new ServiceInstanceMetaInAlarm(); - instanceMetaInAlarm.setIndicatorName(meta.getIndicatorName()); + instanceMetaInAlarm.setMetricsName(meta.getMetricsName()); instanceMetaInAlarm.setId(serviceInstanceId); instanceMetaInAlarm.setName(serviceInstanceInventory.getName()); metaInAlarm = instanceMetaInAlarm; @@ -72,7 +72,7 @@ public NotifyHandler(Rules rules) { int endpointId = Integer.parseInt(meta.getId()); EndpointInventory endpointInventory = endpointInventoryCache.get(endpointId); EndpointMetaInAlarm endpointMetaInAlarm = new EndpointMetaInAlarm(); - endpointMetaInAlarm.setIndicatorName(meta.getIndicatorName()); + endpointMetaInAlarm.setMetricsName(meta.getMetricsName()); endpointMetaInAlarm.setId(endpointId); int serviceId = endpointInventory.getServiceId(); @@ -86,12 +86,12 @@ public NotifyHandler(Rules rules) { return; } - List runningRules = core.findRunningRule(meta.getIndicatorName()); + List runningRules = core.findRunningRule(meta.getMetricsName()); if (runningRules == null) { return; } - runningRules.forEach(rule -> rule.in(metaInAlarm, indicator)); + runningRules.forEach(rule -> rule.in(metaInAlarm, metrics)); } public void init(AlarmCallback... callbacks) { diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RulesReader.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RulesReader.java index 3a511ada5cb2..8cc9785d0755 100644 --- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RulesReader.java +++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RulesReader.java @@ -52,12 +52,12 @@ public Rules readRules() { AlarmRule alarmRule = new AlarmRule(); alarmRule.setAlarmRuleName((String)k); Map settings = (Map)v; - Object indicatorName = settings.get("indicator-name"); - if (indicatorName == null) { - throw new IllegalArgumentException("indicator-name can't be null"); + Object metricsName = settings.get("metrics-name"); + if (metricsName == null) { + throw new IllegalArgumentException("metrics-name can't be null"); } - alarmRule.setIndicatorName((String)indicatorName); + alarmRule.setMetricsName((String)metricsName); alarmRule.setIncludeNames((ArrayList)settings.getOrDefault("include-names", new ArrayList(0))); alarmRule.setThreshold(settings.get("threshold").toString()); alarmRule.setOp((String)settings.get("op")); diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRule.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRule.java index bf8ac47525a6..d9873e3ace43 100644 --- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRule.java +++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRule.java @@ -26,10 +26,8 @@ import java.util.concurrent.locks.ReentrantLock; import org.apache.skywalking.oap.server.core.alarm.AlarmMessage; import org.apache.skywalking.oap.server.core.alarm.MetaInAlarm; -import org.apache.skywalking.oap.server.core.analysis.indicator.DoubleValueHolder; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.analysis.indicator.IntValueHolder; -import org.apache.skywalking.oap.server.core.analysis.indicator.LongValueHolder; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.library.util.CollectionUtils; import org.joda.time.LocalDateTime; import org.joda.time.Minutes; @@ -49,19 +47,19 @@ public class RunningRule { private String ruleName; private int period; - private String indicatorName; + private String metricsName; private final Threshold threshold; private final OP op; private final int countThreshold; private final int silencePeriod; private Map windows; - private volatile IndicatorValueType valueType; + private volatile MetricsValueType valueType; private int targetScopeId; private List includeNames; private AlarmMessageFormatter formatter; public RunningRule(AlarmRule alarmRule) { - indicatorName = alarmRule.getIndicatorName(); + metricsName = alarmRule.getMetricsName(); this.ruleName = alarmRule.getAlarmRuleName(); // Init the empty window for alarming rule. @@ -80,13 +78,13 @@ public RunningRule(AlarmRule alarmRule) { } /** - * Receive indicator result from persistence, after it is saved into storage. In alarm, only minute dimensionality - * indicators are expected to process. + * Receive metrics result from persistence, after it is saved into storage. In alarm, only minute dimensionality + * metrics are expected to process. * - * @param indicator + * @param metrics */ - public void in(MetaInAlarm meta, Indicator indicator) { - if (!meta.getIndicatorName().equals(indicatorName)) { + public void in(MetaInAlarm meta, Metrics metrics) { + if (!meta.getMetricsName().equals(metricsName)) { //Don't match rule, exit. return; } @@ -98,15 +96,15 @@ public void in(MetaInAlarm meta, Indicator indicator) { } if (valueType == null) { - if (indicator instanceof LongValueHolder) { - valueType = IndicatorValueType.LONG; - threshold.setType(IndicatorValueType.LONG); - } else if (indicator instanceof IntValueHolder) { - valueType = IndicatorValueType.INT; - threshold.setType(IndicatorValueType.INT); - } else if (indicator instanceof DoubleValueHolder) { - valueType = IndicatorValueType.DOUBLE; - threshold.setType(IndicatorValueType.DOUBLE); + if (metrics instanceof LongValueHolder) { + valueType = MetricsValueType.LONG; + threshold.setType(MetricsValueType.LONG); + } else if (metrics instanceof IntValueHolder) { + valueType = MetricsValueType.INT; + threshold.setType(MetricsValueType.INT); + } else if (metrics instanceof DoubleValueHolder) { + valueType = MetricsValueType.DOUBLE; + threshold.setType(MetricsValueType.DOUBLE); } else { return; } @@ -117,12 +115,12 @@ public void in(MetaInAlarm meta, Indicator indicator) { Window window = windows.get(meta); if (window == null) { window = new Window(period); - LocalDateTime timebucket = TIME_BUCKET_FORMATTER.parseLocalDateTime(indicator.getTimeBucket() + ""); + LocalDateTime timebucket = TIME_BUCKET_FORMATTER.parseLocalDateTime(metrics.getTimeBucket() + ""); window.moveTo(timebucket); windows.put(meta, window); } - window.add(indicator); + window.add(metrics); } } @@ -160,7 +158,7 @@ public List check() { } /** - * A indicator window, based on {@link AlarmRule#period}. This window slides with time, just keeps the recent + * A metrics window, based on {@link AlarmRule#period}. This window slides with time, just keeps the recent * N(period) buckets. * * @author wusheng @@ -171,7 +169,7 @@ public class Window { private int counter; private int silenceCountdown; - private LinkedList values; + private LinkedList values; private ReentrantLock lock = new ReentrantLock(); public Window(int period) { @@ -209,8 +207,8 @@ public void moveTo(LocalDateTime current) { } } - public void add(Indicator indicator) { - long bucket = indicator.getTimeBucket(); + public void add(Metrics metrics) { + long bucket = metrics.getTimeBucket(); LocalDateTime timebucket = TIME_BUCKET_FORMATTER.parseLocalDateTime(bucket + ""); @@ -233,7 +231,7 @@ public void add(Indicator indicator) { return; } - values.set(values.size() - minutes - 1, indicator); + values.set(values.size() - minutes - 1, metrics); } finally { lock.unlock(); } @@ -243,7 +241,7 @@ public AlarmMessage checkAlarm() { if (isMatch()) { /** * When - * 1. Metric value threshold triggers alarm by rule + * 1. Metrics value threshold triggers alarm by rule * 2. Counter reaches the count threshold; * 3. Isn't in silence stage, judged by SilenceCountdown(!=0). */ @@ -268,14 +266,14 @@ public AlarmMessage checkAlarm() { private boolean isMatch() { int matchCount = 0; - for (Indicator indicator : values) { - if (indicator == null) { + for (Metrics metrics : values) { + if (metrics == null) { continue; } switch (valueType) { case LONG: - long lvalue = ((LongValueHolder)indicator).getValue(); + long lvalue = ((LongValueHolder)metrics).getValue(); long lexpected = RunningRule.this.threshold.getLongThreshold(); switch (op) { case GREATER: @@ -293,7 +291,7 @@ private boolean isMatch() { } break; case INT: - int ivalue = ((IntValueHolder)indicator).getValue(); + int ivalue = ((IntValueHolder)metrics).getValue(); int iexpected = RunningRule.this.threshold.getIntThreshold(); switch (op) { case LESS: @@ -311,7 +309,7 @@ private boolean isMatch() { } break; case DOUBLE: - double dvalue = ((DoubleValueHolder)indicator).getValue(); + double dvalue = ((DoubleValueHolder)metrics).getValue(); double dexpected = RunningRule.this.threshold.getDoubleThreadhold(); switch (op) { case EQUAL: diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/Threshold.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/Threshold.java index c97f0e4a9cb2..aa67f3bf34bf 100644 --- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/Threshold.java +++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/Threshold.java @@ -50,7 +50,7 @@ public long getLongThreshold() { return longThreshold; } - public void setType(IndicatorValueType type) { + public void setType(MetricsValueType type) { try { switch (type) { case INT: @@ -64,7 +64,7 @@ public void setType(IndicatorValueType type) { break; } } catch (NumberFormatException e) { - logger.warn("Alarm rule {} threshold doesn't match the indicator type, expected type: {}", alarmRuleName, type); + logger.warn("Alarm rule {} threshold doesn't match the metrics type, expected type: {}", alarmRuleName, type); } } } diff --git a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmMessageFormatterTest.java b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmMessageFormatterTest.java index 5d96606179b5..f46d764243a4 100644 --- a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmMessageFormatterTest.java +++ b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmMessageFormatterTest.java @@ -35,7 +35,7 @@ public void testStringFormatWithNoArg() { return null; } - @Override public String getIndicatorName() { + @Override public String getMetricsName() { return null; } @@ -64,7 +64,7 @@ public void testStringFormatWithArg() { return "service"; } - @Override public String getIndicatorName() { + @Override public String getMetricsName() { return null; } diff --git a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandlerTest.java b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandlerTest.java index 2f578461b043..3e8b34b8bfa3 100644 --- a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandlerTest.java +++ b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandlerTest.java @@ -21,26 +21,16 @@ import com.google.common.collect.Lists; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.alarm.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.analysis.indicator.IndicatorMetaInfo; -import org.apache.skywalking.oap.server.core.analysis.indicator.WithMetadata; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; -import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; -import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; -import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; -import org.apache.skywalking.oap.server.core.register.ServiceInventory; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; +import org.apache.skywalking.oap.server.core.cache.*; +import org.apache.skywalking.oap.server.core.register.*; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; -import org.apache.skywalking.oap.server.library.module.ModuleManager; -import org.apache.skywalking.oap.server.library.module.ModuleProviderHolder; -import org.apache.skywalking.oap.server.library.module.ModuleServiceHolder; -import org.junit.Before; -import org.junit.Test; +import org.apache.skywalking.oap.server.library.module.*; +import org.junit.*; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.*; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.reflect.Whitebox; @@ -69,21 +59,20 @@ public class NotifyHandlerTest { private EndpointInventoryCache endpointInventoryCache; - private MockIndicator indicator; + private MockMetrics metrics; - private IndicatorMetaInfo metadata; + private MetricsMetaInfo metadata; private int mockId = 1; private RunningRule rule; - @Test public void testNotifyWithEndpointCatalog() { prepareNotify(); - String indicatorName = "endpoint-indicator"; - when(metadata.getIndicatorName()).thenReturn(indicatorName); + String metricsName = "endpoint-metrics"; + when(metadata.getMetricsName()).thenReturn(metricsName); when(DefaultScopeDefine.inEndpointCatalog(0)).thenReturn(true); @@ -101,14 +90,14 @@ public void testNotifyWithEndpointCatalog() { ArgumentCaptor metaCaptor = ArgumentCaptor.forClass(MetaInAlarm.class); - notifyHandler.notify(indicator); + notifyHandler.notify(metrics); verify(rule).in(metaCaptor.capture(), any()); MetaInAlarm metaInAlarm = metaCaptor.getValue(); assertTrue(metaInAlarm instanceof EndpointMetaInAlarm); assertEquals(mockId, metaInAlarm.getId0()); - assertEquals(indicatorName, metaInAlarm.getIndicatorName()); + assertEquals(metricsName, metaInAlarm.getMetricsName()); assertEquals(endpointInventoryName + " in " + serviceInventoryName, metaInAlarm.getName()); assertEquals(DefaultScopeDefine.ENDPOINT, metaInAlarm.getScopeId()); @@ -119,8 +108,8 @@ public void testNotifyWithServiceInstanceCatalog() { prepareNotify(); - String indicatorName = "service-instance-indicator"; - when(metadata.getIndicatorName()).thenReturn(indicatorName); + String metricsName = "service-instance-metrics"; + when(metadata.getMetricsName()).thenReturn(metricsName); when(DefaultScopeDefine.inServiceInstanceCatalog(0)).thenReturn(true); @@ -132,13 +121,13 @@ public void testNotifyWithServiceInstanceCatalog() { ArgumentCaptor metaCaptor = ArgumentCaptor.forClass(MetaInAlarm.class); - notifyHandler.notify(indicator); + notifyHandler.notify(metrics); verify(rule).in(metaCaptor.capture(), any()); MetaInAlarm metaInAlarm = metaCaptor.getValue(); assertTrue(metaInAlarm instanceof ServiceInstanceMetaInAlarm); - assertEquals(indicatorName, metaInAlarm.getIndicatorName()); + assertEquals(metricsName, metaInAlarm.getMetricsName()); assertEquals(mockId, metaInAlarm.getId0()); assertEquals(instanceInventoryName, metaInAlarm.getName()); assertEquals(DefaultScopeDefine.SERVICE_INSTANCE, metaInAlarm.getScopeId()); @@ -148,8 +137,8 @@ public void testNotifyWithServiceInstanceCatalog() { public void testNotifyWithServiceCatalog() { prepareNotify(); - String indicatorName = "service-indicator"; - when(metadata.getIndicatorName()).thenReturn(indicatorName); + String metricsName = "service-metrics"; + when(metadata.getMetricsName()).thenReturn(metricsName); when(DefaultScopeDefine.inServiceCatalog(0)).thenReturn(true); ServiceInventory serviceInventory = mock(ServiceInventory.class); @@ -160,13 +149,13 @@ public void testNotifyWithServiceCatalog() { ArgumentCaptor metaCaptor = ArgumentCaptor.forClass(MetaInAlarm.class); - notifyHandler.notify(indicator); + notifyHandler.notify(metrics); verify(rule).in(metaCaptor.capture(), any()); MetaInAlarm metaInAlarm = metaCaptor.getValue(); assertTrue(metaInAlarm instanceof ServiceMetaInAlarm); - assertEquals(indicatorName, metaInAlarm.getIndicatorName()); + assertEquals(metricsName, metaInAlarm.getMetricsName()); assertEquals(mockId, metaInAlarm.getId0()); assertEquals(serviceInventoryName, metaInAlarm.getName()); assertEquals(DefaultScopeDefine.SERVICE, metaInAlarm.getScopeId()); @@ -175,12 +164,12 @@ public void testNotifyWithServiceCatalog() { private void prepareNotify() { notifyHandler.initCache(moduleManager); - metadata = mock(IndicatorMetaInfo.class); + metadata = mock(MetricsMetaInfo.class); when(metadata.getScope()).thenReturn(DefaultScopeDefine.ALL); when(metadata.getId()).thenReturn(String.valueOf(mockId)); - indicator = mock(MockIndicator.class); - when(indicator.getMeta()).thenReturn(metadata); + metrics = mock(MockMetrics.class); + when(metrics.getMeta()).thenReturn(metadata); PowerMockito.mockStatic(DefaultScopeDefine.class); } @@ -188,13 +177,13 @@ private void prepareNotify() { @Test public void dontNotify() { - IndicatorMetaInfo metadata = mock(IndicatorMetaInfo.class); + MetricsMetaInfo metadata = mock(MetricsMetaInfo.class); when(metadata.getScope()).thenReturn(DefaultScopeDefine.ALL); - MockIndicator indicator = mock(MockIndicator.class); - when(indicator.getMeta()).thenReturn(metadata); + MockMetrics mockMetrics = mock(MockMetrics.class); + when(mockMetrics.getMeta()).thenReturn(metadata); - notifyHandler.notify(indicator); + notifyHandler.notify(mockMetrics); } @Test @@ -203,7 +192,6 @@ public void initCache() { notifyHandler.initCache(moduleManager); } - @Before public void setUp() throws Exception { @@ -217,12 +205,10 @@ public void setUp() throws Exception { } }); - moduleManager = mock(ModuleManager.class); moduleProviderHolder = mock(ModuleProviderHolder.class); - moduleServiceHolder = mock(ModuleServiceHolder.class); when(moduleManager.find(CoreModule.NAME)).thenReturn(moduleProviderHolder); @@ -240,14 +226,14 @@ public void setUp() throws Exception { rule = mock(RunningRule.class); - doNothing().when(rule).in(any(MetaInAlarm.class), any(Indicator.class)); + doNothing().when(rule).in(any(MetaInAlarm.class), any(Metrics.class)); when(core.findRunningRule(anyString())).thenReturn(Lists.newArrayList(rule)); Whitebox.setInternalState(notifyHandler, "core", core); } - private abstract class MockIndicator extends Indicator implements WithMetadata { + private abstract class MockMetrics extends Metrics implements WithMetadata { } } \ No newline at end of file diff --git a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRuleTest.java b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRuleTest.java index 371e6efe2c0f..72cea04eed28 100644 --- a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRuleTest.java +++ b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRuleTest.java @@ -20,7 +20,7 @@ import java.util.*; import org.apache.skywalking.oap.server.core.alarm.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; import org.joda.time.LocalDateTime; @@ -42,7 +42,7 @@ public class RunningRuleTest { public void testInitAndStart() { AlarmRule alarmRule = new AlarmRule(); alarmRule.setAlarmRuleName("endpoint_percent_rule"); - alarmRule.setIndicatorName("endpoint_percent"); + alarmRule.setMetricsName("endpoint_percent"); alarmRule.setOp("<"); alarmRule.setThreshold("75"); alarmRule.setCount(3); @@ -51,25 +51,25 @@ public void testInitAndStart() { RunningRule runningRule = new RunningRule(alarmRule); LocalDateTime startTime = TIME_BUCKET_FORMATTER.parseLocalDateTime("201808301434"); long timeInPeriod1 = 201808301434L; - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod1, 70)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod1, 70)); Map windows = Whitebox.getInternalState(runningRule, "windows"); RunningRule.Window window = windows.get(getMetaInAlarm(123)); LocalDateTime endTime = Whitebox.getInternalState(window, "endTime"); int period = Whitebox.getInternalState(window, "period"); - LinkedList indicatorBuffer = Whitebox.getInternalState(window, "values"); + LinkedList metricsBuffer = Whitebox.getInternalState(window, "values"); Assert.assertTrue(startTime.equals(endTime)); Assert.assertEquals(15, period); - Assert.assertEquals(15, indicatorBuffer.size()); + Assert.assertEquals(15, metricsBuffer.size()); } @Test public void testAlarm() { AlarmRule alarmRule = new AlarmRule(); alarmRule.setAlarmRuleName("endpoint_percent_rule"); - alarmRule.setIndicatorName("endpoint_percent"); + alarmRule.setMetricsName("endpoint_percent"); alarmRule.setOp("<"); alarmRule.setThreshold("75"); alarmRule.setCount(3); @@ -83,9 +83,9 @@ public void testAlarm() { long timeInPeriod2 = 201808301436L; long timeInPeriod3 = 201808301438L; - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod1, 70)); - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod2, 71)); - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod3, 74)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod1, 70)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod2, 71)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod3, 74)); // check at 201808301440 List alarmMessages = runningRule.check(); @@ -105,7 +105,7 @@ public void testAlarm() { public void testNoAlarm() { AlarmRule alarmRule = new AlarmRule(); alarmRule.setAlarmRuleName("endpoint_percent_rule"); - alarmRule.setIndicatorName("endpoint_percent"); + alarmRule.setMetricsName("endpoint_percent"); alarmRule.setOp(">"); alarmRule.setThreshold("75"); alarmRule.setCount(3); @@ -129,11 +129,11 @@ public void testNoAlarm() { long timeInPeriod3 = 201808301438L; long timeInPeriod4 = 201808301432L; long timeInPeriod5 = 201808301440L; - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod1, 70)); - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod2, 71)); - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod3, 74)); - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod4, 90)); - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod5, 95)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod1, 70)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod2, 71)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod3, 74)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod4, 90)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod5, 95)); // check at 201808301440 Assert.assertEquals(0, runningRule.check().size()); @@ -149,7 +149,7 @@ public void testNoAlarm() { public void testSilence() { AlarmRule alarmRule = new AlarmRule(); alarmRule.setAlarmRuleName("endpoint_percent_rule"); - alarmRule.setIndicatorName("endpoint_percent"); + alarmRule.setMetricsName("endpoint_percent"); alarmRule.setOp("<"); alarmRule.setThreshold("75"); alarmRule.setCount(3); @@ -161,9 +161,9 @@ public void testSilence() { long timeInPeriod1 = 201808301434L; long timeInPeriod2 = 201808301436L; long timeInPeriod3 = 201808301438L; - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod1, 70)); - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod2, 71)); - runningRule.in(getMetaInAlarm(123), getIndicator(timeInPeriod3, 74)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod1, 70)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod2, 71)); + runningRule.in(getMetaInAlarm(123), getMetrics(timeInPeriod3, 74)); // check at 201808301440 Assert.assertEquals(0, runningRule.check().size()); //check matches, no alarm @@ -191,7 +191,7 @@ private MetaInAlarm getMetaInAlarm(int id) { return "Service_" + id; } - @Override public String getIndicatorName() { + @Override public String getMetricsName() { return "endpoint_percent"; } @@ -214,21 +214,21 @@ private MetaInAlarm getMetaInAlarm(int id) { }; } - private Indicator getIndicator(long timebucket, int value) { - MockIndicator indicator = new MockIndicator(); - indicator.setValue(value); - indicator.setTimeBucket(timebucket); - return indicator; + private Metrics getMetrics(long timeBucket, int value) { + MockMetrics mockMetrics = new MockMetrics(); + mockMetrics.setValue(value); + mockMetrics.setTimeBucket(timeBucket); + return mockMetrics; } - private class MockIndicator extends Indicator implements IntValueHolder { + private class MockMetrics extends Metrics implements IntValueHolder { private int value; @Override public String id() { return null; } - @Override public void combine(Indicator indicator) { + @Override public void combine(Metrics metrics) { } @@ -236,15 +236,15 @@ private class MockIndicator extends Indicator implements IntValueHolder { } - @Override public Indicator toHour() { + @Override public Metrics toHour() { return null; } - @Override public Indicator toDay() { + @Override public Metrics toDay() { return null; } - @Override public Indicator toMonth() { + @Override public Metrics toMonth() { return null; } diff --git a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/ThresholdTest.java b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/ThresholdTest.java index 85f2bcd88345..0363b48ab667 100644 --- a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/ThresholdTest.java +++ b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/ThresholdTest.java @@ -30,20 +30,20 @@ public class ThresholdTest { @Test public void setType() { Threshold threshold = new Threshold("my-rule", "75"); - threshold.setType(IndicatorValueType.DOUBLE); + threshold.setType(MetricsValueType.DOUBLE); assertEquals(0, Double.compare(75, threshold.getDoubleThreadhold())); - threshold.setType(IndicatorValueType.INT); + threshold.setType(MetricsValueType.INT); assertEquals(75, threshold.getIntThreshold()); - threshold.setType(IndicatorValueType.LONG); + threshold.setType(MetricsValueType.LONG); assertEquals(75L, threshold.getLongThreshold()); } @Test public void setTypeWithWrong() { Threshold threshold = new Threshold("my-rule", "wrong"); - threshold.setType(IndicatorValueType.INT); + threshold.setType(MetricsValueType.INT); assertEquals(0, threshold.getIntThreshold()); } } \ No newline at end of file diff --git a/oap-server/server-alarm-plugin/src/test/resources/alarm-settings.yml b/oap-server/server-alarm-plugin/src/test/resources/alarm-settings.yml index a39264861f4b..4282a7f4eb2a 100644 --- a/oap-server/server-alarm-plugin/src/test/resources/alarm-settings.yml +++ b/oap-server/server-alarm-plugin/src/test/resources/alarm-settings.yml @@ -17,20 +17,20 @@ rules: # Rule unique name, must be ended with `_rule`. endpoint_percent_rule: - # Indicator value need to be long, double or int - indicator-name: endpoint_percent + # Metrics value need to be long, double or int + metrics-name: endpoint_percent threshold: 75 op: < - # The length of time to evaluate the metric + # The length of time to evaluate the metrics period: 10 - # How many times after the metric match the condition, will trigger alarm + # How many times after the metrics match the condition, will trigger alarm count: 3 # How many times of checks, the alarm keeps silence after alarm triggered, default as same as period. silence-period: 10 message: Successful rate of endpoint {name} is lower than 75% service_percent_rule: - indicator-name: service_percent - # [Optional] Default, match all services in this indicator + metrics-name: service_percent + # [Optional] Default, match all services in this metrics include-names: - service_a - service_b diff --git a/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/dependencies/NamespacedPodListWatchTest.java b/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/dependencies/NamespacedPodListWatchTest.java deleted file mode 100644 index 71d8b5d01853..000000000000 --- a/oap-server/server-cluster-plugin/cluster-kubernetes-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/kubernetes/dependencies/NamespacedPodListWatchTest.java +++ /dev/null @@ -1,166 +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.skywalking.oap.server.cluster.plugin.kubernetes.dependencies; - -import com.squareup.okhttp.Call; -import com.squareup.okhttp.OkHttpClient; -import com.squareup.okhttp.Request; -import io.kubernetes.client.ApiClient; -import io.kubernetes.client.models.V1ObjectMeta; -import io.kubernetes.client.models.V1Pod; -import io.kubernetes.client.models.V1PodStatus; -import io.kubernetes.client.util.Watch; -import org.apache.skywalking.oap.server.cluster.plugin.kubernetes.Event; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; - -import java.lang.reflect.Type; -import java.util.Iterator; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -/** - * Created by dengming, 2019.05.02 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({Watch.class, OkHttpClient.class}) -@PowerMockIgnore("javax.management.*") -public class NamespacedPodListWatchTest { - - private NamespacedPodListWatch namespacedPodListWatch; - - private Watch mockWatch = mock(Watch.class); - - private static final String NAME_SPACE = "my-namespace"; - private static final String LABEL_SELECTOR = "equality-based"; - private static final String RESPONSE_TYPE = "my-type"; - private static final int WATCH_TIMEOUT_SECONDS = 3; - - - @Before - public void setUp() throws Exception { - - namespacedPodListWatch = new NamespacedPodListWatch(NAME_SPACE, LABEL_SELECTOR, WATCH_TIMEOUT_SECONDS); - - PowerMockito.mockStatic(Watch.class); - when(Watch.createWatch(any(), any(), any())).thenReturn(mockWatch); - Call mockCall = mock(Call.class); - PowerMockito.whenNew(Call.class).withArguments(any(OkHttpClient.class), any(Request.class)).thenReturn(mockCall); - - namespacedPodListWatch.initOrReset(); - - ArgumentCaptor apiClientArgumentCaptor = ArgumentCaptor.forClass(ApiClient.class); - ArgumentCaptor callArgumentCaptor = ArgumentCaptor.forClass(Call.class); - ArgumentCaptor typeArgumentCaptor = ArgumentCaptor.forClass(Type.class); - - PowerMockito.verifyStatic(); - Watch.createWatch( - apiClientArgumentCaptor.capture(), - callArgumentCaptor.capture(), - typeArgumentCaptor.capture()); - - ApiClient apiClient = apiClientArgumentCaptor.getValue(); - Call call = callArgumentCaptor.getValue(); - Type type = typeArgumentCaptor.getValue(); - - assertEquals(mockCall, call); - assertNotNull(apiClient); - assertNotNull(type); - - } - - @Test - public void iterator() { - when(mockWatch.hasNext()).thenReturn(true, true, false); - Iterator mockIterator = mockIterator(); - when(mockWatch.iterator()).thenReturn(mockIterator); - Iterator iterator = namespacedPodListWatch.iterator(); - - assertNotNull(iterator); - assertTrue(iterator.hasNext()); - - Event event0 = iterator.next(); - assertNotNull(event0); - validateEvent(event0, 0); - - assertTrue(iterator.hasNext()); - Event event1 = iterator.next(); - assertNotNull(event1); - validateEvent(event1, 1); - - assertFalse(iterator.hasNext()); - - } - - @Test - public void iteratorWithEmpty() { - Iterator iterator = mock(Iterator.class); - when(iterator.hasNext()).thenReturn(false); - when(mockWatch.iterator()).thenReturn(iterator); - - Iterator eventIterator = namespacedPodListWatch.iterator(); - assertFalse(eventIterator.hasNext()); - } - - - private Iterator> mockIterator() { - Iterator> iterator = mock(Iterator.class); - - when(iterator.hasNext()).thenReturn(true, true, false); - Watch.Response response0 = mockResponse(0); - Watch.Response response1 = mockResponse(1); - - when(iterator.next()).thenReturn(response0, response1); - - return iterator; - } - - private Watch.Response mockResponse(int i) { - V1Pod v1Pod = new V1Pod(); - V1ObjectMeta meta = new V1ObjectMeta(); - V1PodStatus status = new V1PodStatus(); - status.setPodIP("PodIp" + i); - meta.setUid("uid" + i); - v1Pod.setMetadata(meta); - v1Pod.setStatus(status); - Watch.Response response = mock(Watch.Response.class); - response.object = v1Pod; - response.type = RESPONSE_TYPE; - return response; - } - - private void validateEvent(Event event, int i) { - String type = Whitebox.getInternalState(event, "type"); - assertEquals(RESPONSE_TYPE, type); - - String uid = Whitebox.getInternalState(event, "uid"); - assertEquals("uid" + i, uid); - - String host = Whitebox.getInternalState(event, "host"); - assertEquals("PodIp" + i, host); - } - -} \ No newline at end of file diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java index 9b677ec4b054..364fd7ec5f88 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java @@ -20,7 +20,7 @@ import java.io.IOException; import org.apache.skywalking.oap.server.core.analysis.DisableRegister; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorTypeListener; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsTypeListener; import org.apache.skywalking.oap.server.core.analysis.record.annotation.RecordTypeListener; import org.apache.skywalking.oap.server.core.analysis.topn.annotation.TopNTypeListener; import org.apache.skywalking.oap.server.core.annotation.AnnotationScan; @@ -153,7 +153,7 @@ public CoreModuleProvider() { annotationScan.registerListener(storageAnnotationListener); annotationScan.registerListener(streamAnnotationListener); - annotationScan.registerListener(new IndicatorTypeListener(getManager())); + annotationScan.registerListener(new MetricsTypeListener(getManager())); annotationScan.registerListener(new InventoryTypeListener(getManager())); annotationScan.registerListener(new RecordTypeListener(getManager())); annotationScan.registerListener(new TopNTypeListener(getManager())); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmEntrance.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmEntrance.java index 902fff6486a5..e71ce7a37342 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmEntrance.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmEntrance.java @@ -18,7 +18,7 @@ package org.apache.skywalking.oap.server.core.alarm; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder; /** @@ -26,25 +26,25 @@ */ public class AlarmEntrance { private ModuleDefineHolder moduleDefineHolder; - private IndicatorNotify indicatorNotify; + private MetricsNotify metricsNotify; public AlarmEntrance(ModuleDefineHolder moduleDefineHolder) { this.moduleDefineHolder = moduleDefineHolder; } - public void forward(Indicator indicator) { + public void forward(Metrics metrics) { if (!moduleDefineHolder.has(AlarmModule.NAME)) { return; } init(); - indicatorNotify.notify(indicator); + metricsNotify.notify(metrics); } private void init() { - if (indicatorNotify == null) { - indicatorNotify = moduleDefineHolder.find(AlarmModule.NAME).provider().getService(IndicatorNotify.class); + if (metricsNotify == null) { + metricsNotify = moduleDefineHolder.find(AlarmModule.NAME).provider().getService(MetricsNotify.class); } } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmModule.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmModule.java index 8357727232e5..793e58822839 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmModule.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmModule.java @@ -35,6 +35,6 @@ public AlarmModule() { } @Override public Class[] services() { - return new Class[] {IndicatorNotify.class}; + return new Class[] {MetricsNotify.class}; } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/EndpointMetaInAlarm.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/EndpointMetaInAlarm.java index 6438c68e7274..27c483340735 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/EndpointMetaInAlarm.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/EndpointMetaInAlarm.java @@ -26,7 +26,7 @@ @Getter(AccessLevel.PUBLIC) @Setter(AccessLevel.PUBLIC) public class EndpointMetaInAlarm extends MetaInAlarm { - private String indicatorName; + private String metricsName; private int id; private String name; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetaInAlarm.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetaInAlarm.java index 0d55f07b6743..811128476d45 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetaInAlarm.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetaInAlarm.java @@ -25,7 +25,7 @@ public abstract class MetaInAlarm { public abstract String getName(); - public abstract String getIndicatorName(); + public abstract String getMetricsName(); /** * In most scopes, there is only id0, as primary id. Such as Service, Endpoint. But in relation, the ID includes diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/IndicatorNotify.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetricsNotify.java similarity index 81% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/IndicatorNotify.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetricsNotify.java index 59bb0372809f..86a0cbe0e41e 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/IndicatorNotify.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetricsNotify.java @@ -18,11 +18,11 @@ package org.apache.skywalking.oap.server.core.alarm; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.library.module.Service; /** - * Indicator notify service should be provided by Alarm Module provider, which can receive the indicator value, driven + * Metrics notify service should be provided by Alarm Module provider, which can receive the metrics value, driven * by storage core. * * The alarm module provider could choose whether or how to do the alarm. Meanwhile, the storage core will provide the @@ -31,6 +31,6 @@ * * @author wusheng */ -public interface IndicatorNotify extends Service { - void notify(Indicator indicator); +public interface MetricsNotify extends Service { + void notify(Metrics metrics); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceInstanceMetaInAlarm.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceInstanceMetaInAlarm.java index 09fca3195688..1a4c8ee994eb 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceInstanceMetaInAlarm.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceInstanceMetaInAlarm.java @@ -18,15 +18,13 @@ package org.apache.skywalking.oap.server.core.alarm; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.Setter; +import lombok.*; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; @Getter(AccessLevel.PUBLIC) @Setter(AccessLevel.PUBLIC) public class ServiceInstanceMetaInAlarm extends MetaInAlarm { - private String indicatorName; + private String metricsName; private int id; private String name; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceMetaInAlarm.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceMetaInAlarm.java index 192b118faef1..d143e97457c4 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceMetaInAlarm.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceMetaInAlarm.java @@ -18,15 +18,13 @@ package org.apache.skywalking.oap.server.core.alarm; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.Setter; +import lombok.*; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; @Getter(AccessLevel.PUBLIC) @Setter(AccessLevel.PUBLIC) public class ServiceMetaInAlarm extends MetaInAlarm { - private String indicatorName; + private String metricsName; private int id; private String name; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/data/MergeDataCache.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/data/MergeDataCache.java index 778de6bb2062..5419607b0822 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/data/MergeDataCache.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/data/MergeDataCache.java @@ -18,28 +18,28 @@ package org.apache.skywalking.oap.server.core.analysis.data; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; /** * @author peng-yongsheng */ -public class MergeDataCache extends Window implements DataCache { +public class MergeDataCache extends Window implements DataCache { - private SWCollection lockedMergeDataCollection; + private SWCollection lockedMergeDataCollection; - @Override public SWCollection collectionInstance() { + @Override public SWCollection collectionInstance() { return new MergeDataCollection<>(); } - public boolean containsKey(INDICATOR key) { + public boolean containsKey(METRICS key) { return lockedMergeDataCollection.containsKey(key); } - public Indicator get(INDICATOR key) { + public Metrics get(METRICS key) { return lockedMergeDataCollection.get(key); } - public void put(INDICATOR data) { + public void put(METRICS data) { lockedMergeDataCollection.put(data); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointCallRelationDispatcher.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointCallRelationDispatcher.java index cd0749840555..027bbc08aa86 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointCallRelationDispatcher.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointCallRelationDispatcher.java @@ -19,7 +19,7 @@ package org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation; import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher; -import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess; +import org.apache.skywalking.oap.server.core.analysis.worker.MetricsProcess; import org.apache.skywalking.oap.server.core.source.EndpointRelation; /** @@ -36,12 +36,12 @@ public void dispatch(EndpointRelation source) { } private void serverSide(EndpointRelation source) { - EndpointRelationServerSideIndicator indicator = new EndpointRelationServerSideIndicator(); - indicator.setTimeBucket(source.getTimeBucket()); - indicator.setSourceEndpointId(source.getEndpointId()); - indicator.setDestEndpointId(source.getChildEndpointId()); - indicator.setComponentId(source.getComponentId()); - indicator.setEntityId(source.getEntityId()); - IndicatorProcess.INSTANCE.in(indicator); + EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics(); + metrics.setTimeBucket(source.getTimeBucket()); + metrics.setSourceEndpointId(source.getEndpointId()); + metrics.setDestEndpointId(source.getChildEndpointId()); + metrics.setComponentId(source.getComponentId()); + metrics.setEntityId(source.getEntityId()); + MetricsProcess.INSTANCE.in(metrics); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointRelationServerSideIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointRelationServerSideMetrics.java similarity index 62% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointRelationServerSideIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointRelationServerSideMetrics.java index 3e6a1e3ac3f6..4732f43801f0 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointRelationServerSideIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointRelationServerSideMetrics.java @@ -21,18 +21,18 @@ import java.util.*; import lombok.*; import org.apache.skywalking.oap.server.core.Const; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsType; import org.apache.skywalking.oap.server.core.remote.annotation.StreamData; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; import org.apache.skywalking.oap.server.core.storage.StorageBuilder; import org.apache.skywalking.oap.server.core.storage.annotation.*; -@IndicatorType +@MetricsType @StreamData -@StorageEntity(name = EndpointRelationServerSideIndicator.INDEX_NAME, builder = EndpointRelationServerSideIndicator.Builder.class, sourceScopeId = DefaultScopeDefine.ENDPOINT_RELATION) -public class EndpointRelationServerSideIndicator extends Indicator { +@StorageEntity(name = EndpointRelationServerSideMetrics.INDEX_NAME, builder = EndpointRelationServerSideMetrics.Builder.class, sourceScopeId = DefaultScopeDefine.ENDPOINT_RELATION) +public class EndpointRelationServerSideMetrics extends Metrics { public static final String INDEX_NAME = "endpoint_relation_server_side"; public static final String SOURCE_ENDPOINT_ID = "source_endpoint_id"; @@ -52,7 +52,7 @@ public class EndpointRelationServerSideIndicator extends Indicator { return splitJointId; } - @Override public void combine(Indicator indicator) { + @Override public void combine(Metrics metrics) { } @@ -60,34 +60,34 @@ public class EndpointRelationServerSideIndicator extends Indicator { } - @Override public Indicator toHour() { - EndpointRelationServerSideIndicator indicator = new EndpointRelationServerSideIndicator(); - indicator.setTimeBucket(toTimeBucketInHour()); - indicator.setSourceEndpointId(getSourceEndpointId()); - indicator.setDestEndpointId(getDestEndpointId()); - indicator.setComponentId(getComponentId()); - indicator.setEntityId(getEntityId()); - return indicator; + @Override public Metrics toHour() { + EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics(); + metrics.setTimeBucket(toTimeBucketInHour()); + metrics.setSourceEndpointId(getSourceEndpointId()); + metrics.setDestEndpointId(getDestEndpointId()); + metrics.setComponentId(getComponentId()); + metrics.setEntityId(getEntityId()); + return metrics; } - @Override public Indicator toDay() { - EndpointRelationServerSideIndicator indicator = new EndpointRelationServerSideIndicator(); - indicator.setTimeBucket(toTimeBucketInDay()); - indicator.setSourceEndpointId(getSourceEndpointId()); - indicator.setDestEndpointId(getDestEndpointId()); - indicator.setComponentId(getComponentId()); - indicator.setEntityId(getEntityId()); - return indicator; + @Override public Metrics toDay() { + EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics(); + metrics.setTimeBucket(toTimeBucketInDay()); + metrics.setSourceEndpointId(getSourceEndpointId()); + metrics.setDestEndpointId(getDestEndpointId()); + metrics.setComponentId(getComponentId()); + metrics.setEntityId(getEntityId()); + return metrics; } - @Override public Indicator toMonth() { - EndpointRelationServerSideIndicator indicator = new EndpointRelationServerSideIndicator(); - indicator.setTimeBucket(toTimeBucketInMonth()); - indicator.setSourceEndpointId(getSourceEndpointId()); - indicator.setDestEndpointId(getDestEndpointId()); - indicator.setComponentId(getComponentId()); - indicator.setEntityId(getEntityId()); - return indicator; + @Override public Metrics toMonth() { + EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics(); + metrics.setTimeBucket(toTimeBucketInMonth()); + metrics.setSourceEndpointId(getSourceEndpointId()); + metrics.setDestEndpointId(getDestEndpointId()); + metrics.setComponentId(getComponentId()); + metrics.setEntityId(getEntityId()); + return metrics; } @Override public int remoteHashCode() { @@ -138,33 +138,33 @@ public class EndpointRelationServerSideIndicator extends Indicator { if (getClass() != obj.getClass()) return false; - EndpointRelationServerSideIndicator indicator = (EndpointRelationServerSideIndicator)obj; - if (sourceEndpointId != indicator.sourceEndpointId) + EndpointRelationServerSideMetrics metrics = (EndpointRelationServerSideMetrics)obj; + if (sourceEndpointId != metrics.sourceEndpointId) return false; - if (destEndpointId != indicator.destEndpointId) + if (destEndpointId != metrics.destEndpointId) return false; - if (componentId != indicator.componentId) + if (componentId != metrics.componentId) return false; - if (getTimeBucket() != indicator.getTimeBucket()) + if (getTimeBucket() != metrics.getTimeBucket()) return false; return true; } - public static class Builder implements StorageBuilder { + public static class Builder implements StorageBuilder { - @Override public EndpointRelationServerSideIndicator map2Data(Map dbMap) { - EndpointRelationServerSideIndicator indicator = new EndpointRelationServerSideIndicator(); - indicator.setSourceEndpointId(((Number)dbMap.get(SOURCE_ENDPOINT_ID)).intValue()); - indicator.setDestEndpointId(((Number)dbMap.get(DEST_ENDPOINT_ID)).intValue()); - indicator.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue()); - indicator.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue()); - indicator.setEntityId((String)dbMap.get(ENTITY_ID)); - return indicator; + @Override public EndpointRelationServerSideMetrics map2Data(Map dbMap) { + EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics(); + metrics.setSourceEndpointId(((Number)dbMap.get(SOURCE_ENDPOINT_ID)).intValue()); + metrics.setDestEndpointId(((Number)dbMap.get(DEST_ENDPOINT_ID)).intValue()); + metrics.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue()); + metrics.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue()); + metrics.setEntityId((String)dbMap.get(ENTITY_ID)); + return metrics; } - @Override public Map data2Map(EndpointRelationServerSideIndicator storageData) { + @Override public Map data2Map(EndpointRelationServerSideMetrics storageData) { Map map = new HashMap<>(); map.put(SOURCE_ENDPOINT_ID, storageData.getSourceEndpointId()); map.put(DEST_ENDPOINT_ID, storageData.getDestEndpointId()); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceCallRelationDispatcher.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceCallRelationDispatcher.java index 596f1310c546..58b68c805236 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceCallRelationDispatcher.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceCallRelationDispatcher.java @@ -19,7 +19,7 @@ package org.apache.skywalking.oap.server.core.analysis.manual.servicerelation; import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher; -import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess; +import org.apache.skywalking.oap.server.core.analysis.worker.MetricsProcess; import org.apache.skywalking.oap.server.core.source.ServiceRelation; /** @@ -39,22 +39,22 @@ public void dispatch(ServiceRelation source) { } private void serverSide(ServiceRelation source) { - ServiceRelationServerSideIndicator indicator = new ServiceRelationServerSideIndicator(); - indicator.setTimeBucket(source.getTimeBucket()); - indicator.setSourceServiceId(source.getSourceServiceId()); - indicator.setDestServiceId(source.getDestServiceId()); - indicator.setComponentId(source.getComponentId()); - indicator.setEntityId(source.getEntityId()); - IndicatorProcess.INSTANCE.in(indicator); + ServiceRelationServerSideMetrics metrics = new ServiceRelationServerSideMetrics(); + metrics.setTimeBucket(source.getTimeBucket()); + metrics.setSourceServiceId(source.getSourceServiceId()); + metrics.setDestServiceId(source.getDestServiceId()); + metrics.setComponentId(source.getComponentId()); + metrics.setEntityId(source.getEntityId()); + MetricsProcess.INSTANCE.in(metrics); } private void clientSide(ServiceRelation source) { - ServiceRelationClientSideIndicator indicator = new ServiceRelationClientSideIndicator(); - indicator.setTimeBucket(source.getTimeBucket()); - indicator.setSourceServiceId(source.getSourceServiceId()); - indicator.setDestServiceId(source.getDestServiceId()); - indicator.setComponentId(source.getComponentId()); - indicator.setEntityId(source.getEntityId()); - IndicatorProcess.INSTANCE.in(indicator); + ServiceRelationClientSideMetrics metrics = new ServiceRelationClientSideMetrics(); + metrics.setTimeBucket(source.getTimeBucket()); + metrics.setSourceServiceId(source.getSourceServiceId()); + metrics.setDestServiceId(source.getDestServiceId()); + metrics.setComponentId(source.getComponentId()); + metrics.setEntityId(source.getEntityId()); + MetricsProcess.INSTANCE.in(metrics); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationClientSideIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationClientSideMetrics.java similarity index 62% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationClientSideIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationClientSideMetrics.java index 7e740dae3306..6b815c5b46f6 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationClientSideIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationClientSideMetrics.java @@ -21,18 +21,18 @@ import java.util.*; import lombok.*; import org.apache.skywalking.oap.server.core.Const; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsType; import org.apache.skywalking.oap.server.core.remote.annotation.StreamData; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; import org.apache.skywalking.oap.server.core.storage.StorageBuilder; import org.apache.skywalking.oap.server.core.storage.annotation.*; -@IndicatorType +@MetricsType @StreamData -@StorageEntity(name = ServiceRelationClientSideIndicator.INDEX_NAME, builder = ServiceRelationClientSideIndicator.Builder.class, sourceScopeId = DefaultScopeDefine.SERVICE_RELATION) -public class ServiceRelationClientSideIndicator extends Indicator { +@StorageEntity(name = ServiceRelationClientSideMetrics.INDEX_NAME, builder = ServiceRelationClientSideMetrics.Builder.class, sourceScopeId = DefaultScopeDefine.SERVICE_RELATION) +public class ServiceRelationClientSideMetrics extends Metrics { public static final String INDEX_NAME = "service_relation_client_side"; public static final String SOURCE_SERVICE_ID = "source_service_id"; @@ -52,7 +52,7 @@ public class ServiceRelationClientSideIndicator extends Indicator { return splitJointId; } - @Override public void combine(Indicator indicator) { + @Override public void combine(Metrics metrics) { } @@ -60,34 +60,34 @@ public class ServiceRelationClientSideIndicator extends Indicator { } - @Override public Indicator toHour() { - ServiceRelationClientSideIndicator indicator = new ServiceRelationClientSideIndicator(); - indicator.setEntityId(getEntityId()); - indicator.setTimeBucket(toTimeBucketInHour()); - indicator.setSourceServiceId(getSourceServiceId()); - indicator.setDestServiceId(getDestServiceId()); - indicator.setComponentId(getComponentId()); - return indicator; + @Override public Metrics toHour() { + ServiceRelationClientSideMetrics metrics = new ServiceRelationClientSideMetrics(); + metrics.setEntityId(getEntityId()); + metrics.setTimeBucket(toTimeBucketInHour()); + metrics.setSourceServiceId(getSourceServiceId()); + metrics.setDestServiceId(getDestServiceId()); + metrics.setComponentId(getComponentId()); + return metrics; } - @Override public Indicator toDay() { - ServiceRelationClientSideIndicator indicator = new ServiceRelationClientSideIndicator(); - indicator.setEntityId(getEntityId()); - indicator.setTimeBucket(toTimeBucketInDay()); - indicator.setSourceServiceId(getSourceServiceId()); - indicator.setDestServiceId(getDestServiceId()); - indicator.setComponentId(getComponentId()); - return indicator; + @Override public Metrics toDay() { + ServiceRelationClientSideMetrics metrics = new ServiceRelationClientSideMetrics(); + metrics.setEntityId(getEntityId()); + metrics.setTimeBucket(toTimeBucketInDay()); + metrics.setSourceServiceId(getSourceServiceId()); + metrics.setDestServiceId(getDestServiceId()); + metrics.setComponentId(getComponentId()); + return metrics; } - @Override public Indicator toMonth() { - ServiceRelationClientSideIndicator indicator = new ServiceRelationClientSideIndicator(); - indicator.setEntityId(getEntityId()); - indicator.setTimeBucket(toTimeBucketInMonth()); - indicator.setSourceServiceId(getSourceServiceId()); - indicator.setDestServiceId(getDestServiceId()); - indicator.setComponentId(getComponentId()); - return indicator; + @Override public Metrics toMonth() { + ServiceRelationClientSideMetrics metrics = new ServiceRelationClientSideMetrics(); + metrics.setEntityId(getEntityId()); + metrics.setTimeBucket(toTimeBucketInMonth()); + metrics.setSourceServiceId(getSourceServiceId()); + metrics.setDestServiceId(getDestServiceId()); + metrics.setComponentId(getComponentId()); + return metrics; } @Override public int remoteHashCode() { @@ -138,33 +138,33 @@ public class ServiceRelationClientSideIndicator extends Indicator { if (getClass() != obj.getClass()) return false; - ServiceRelationClientSideIndicator indicator = (ServiceRelationClientSideIndicator)obj; - if (sourceServiceId != indicator.sourceServiceId) + ServiceRelationClientSideMetrics metrics = (ServiceRelationClientSideMetrics)obj; + if (sourceServiceId != metrics.sourceServiceId) return false; - if (destServiceId != indicator.destServiceId) + if (destServiceId != metrics.destServiceId) return false; - if (componentId != indicator.componentId) + if (componentId != metrics.componentId) return false; - if (getTimeBucket() != indicator.getTimeBucket()) + if (getTimeBucket() != metrics.getTimeBucket()) return false; return true; } - public static class Builder implements StorageBuilder { + public static class Builder implements StorageBuilder { - @Override public ServiceRelationClientSideIndicator map2Data(Map dbMap) { - ServiceRelationClientSideIndicator indicator = new ServiceRelationClientSideIndicator(); - indicator.setSourceServiceId(((Number)dbMap.get(SOURCE_SERVICE_ID)).intValue()); - indicator.setDestServiceId(((Number)dbMap.get(DEST_SERVICE_ID)).intValue()); - indicator.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue()); - indicator.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue()); - indicator.setEntityId((String)dbMap.get(ENTITY_ID)); - return indicator; + @Override public ServiceRelationClientSideMetrics map2Data(Map dbMap) { + ServiceRelationClientSideMetrics metrics = new ServiceRelationClientSideMetrics(); + metrics.setSourceServiceId(((Number)dbMap.get(SOURCE_SERVICE_ID)).intValue()); + metrics.setDestServiceId(((Number)dbMap.get(DEST_SERVICE_ID)).intValue()); + metrics.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue()); + metrics.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue()); + metrics.setEntityId((String)dbMap.get(ENTITY_ID)); + return metrics; } - @Override public Map data2Map(ServiceRelationClientSideIndicator storageData) { + @Override public Map data2Map(ServiceRelationClientSideMetrics storageData) { Map map = new HashMap<>(); map.put(TIME_BUCKET, storageData.getTimeBucket()); map.put(SOURCE_SERVICE_ID, storageData.getSourceServiceId()); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationServerSideIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationServerSideMetrics.java similarity index 63% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationServerSideIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationServerSideMetrics.java index 3dea78023d42..22576538ce8a 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationServerSideIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/servicerelation/ServiceRelationServerSideMetrics.java @@ -21,19 +21,19 @@ import java.util.*; import lombok.*; import org.apache.skywalking.oap.server.core.Const; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsType; import org.apache.skywalking.oap.server.core.remote.annotation.StreamData; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; import org.apache.skywalking.oap.server.core.storage.StorageBuilder; import org.apache.skywalking.oap.server.core.storage.annotation.*; -@IndicatorType +@MetricsType @StreamData -@StorageEntity(name = ServiceRelationServerSideIndicator.INDEX_NAME, builder = ServiceRelationServerSideIndicator.Builder.class, +@StorageEntity(name = ServiceRelationServerSideMetrics.INDEX_NAME, builder = ServiceRelationServerSideMetrics.Builder.class, sourceScopeId = DefaultScopeDefine.SERVICE_RELATION) -public class ServiceRelationServerSideIndicator extends Indicator { +public class ServiceRelationServerSideMetrics extends Metrics { public static final String INDEX_NAME = "service_relation_server_side"; public static final String SOURCE_SERVICE_ID = "source_service_id"; @@ -53,7 +53,7 @@ public class ServiceRelationServerSideIndicator extends Indicator { return splitJointId; } - @Override public void combine(Indicator indicator) { + @Override public void combine(Metrics metrics) { } @@ -61,34 +61,34 @@ public class ServiceRelationServerSideIndicator extends Indicator { } - @Override public Indicator toHour() { - ServiceRelationServerSideIndicator indicator = new ServiceRelationServerSideIndicator(); - indicator.setTimeBucket(toTimeBucketInHour()); - indicator.setSourceServiceId(getSourceServiceId()); - indicator.setDestServiceId(getDestServiceId()); - indicator.setComponentId(getComponentId()); - indicator.setEntityId(getEntityId()); - return indicator; + @Override public Metrics toHour() { + ServiceRelationServerSideMetrics metrics = new ServiceRelationServerSideMetrics(); + metrics.setTimeBucket(toTimeBucketInHour()); + metrics.setSourceServiceId(getSourceServiceId()); + metrics.setDestServiceId(getDestServiceId()); + metrics.setComponentId(getComponentId()); + metrics.setEntityId(getEntityId()); + return metrics; } - @Override public Indicator toDay() { - ServiceRelationServerSideIndicator indicator = new ServiceRelationServerSideIndicator(); - indicator.setTimeBucket(toTimeBucketInDay()); - indicator.setSourceServiceId(getSourceServiceId()); - indicator.setDestServiceId(getDestServiceId()); - indicator.setComponentId(getComponentId()); - indicator.setEntityId(getEntityId()); - return indicator; + @Override public Metrics toDay() { + ServiceRelationServerSideMetrics metrics = new ServiceRelationServerSideMetrics(); + metrics.setTimeBucket(toTimeBucketInDay()); + metrics.setSourceServiceId(getSourceServiceId()); + metrics.setDestServiceId(getDestServiceId()); + metrics.setComponentId(getComponentId()); + metrics.setEntityId(getEntityId()); + return metrics; } - @Override public Indicator toMonth() { - ServiceRelationServerSideIndicator indicator = new ServiceRelationServerSideIndicator(); - indicator.setTimeBucket(toTimeBucketInMonth()); - indicator.setSourceServiceId(getSourceServiceId()); - indicator.setDestServiceId(getDestServiceId()); - indicator.setComponentId(getComponentId()); - indicator.setEntityId(getEntityId()); - return indicator; + @Override public Metrics toMonth() { + ServiceRelationServerSideMetrics metrics = new ServiceRelationServerSideMetrics(); + metrics.setTimeBucket(toTimeBucketInMonth()); + metrics.setSourceServiceId(getSourceServiceId()); + metrics.setDestServiceId(getDestServiceId()); + metrics.setComponentId(getComponentId()); + metrics.setEntityId(getEntityId()); + return metrics; } @Override public int remoteHashCode() { @@ -139,33 +139,33 @@ public class ServiceRelationServerSideIndicator extends Indicator { if (getClass() != obj.getClass()) return false; - ServiceRelationServerSideIndicator indicator = (ServiceRelationServerSideIndicator)obj; - if (sourceServiceId != indicator.sourceServiceId) + ServiceRelationServerSideMetrics metrics = (ServiceRelationServerSideMetrics)obj; + if (sourceServiceId != metrics.sourceServiceId) return false; - if (destServiceId != indicator.destServiceId) + if (destServiceId != metrics.destServiceId) return false; - if (componentId != indicator.componentId) + if (componentId != metrics.componentId) return false; - if (getTimeBucket() != indicator.getTimeBucket()) + if (getTimeBucket() != metrics.getTimeBucket()) return false; return true; } - public static class Builder implements StorageBuilder { + public static class Builder implements StorageBuilder { - @Override public ServiceRelationServerSideIndicator map2Data(Map dbMap) { - ServiceRelationServerSideIndicator indicator = new ServiceRelationServerSideIndicator(); - indicator.setEntityId((String)dbMap.get(ENTITY_ID)); - indicator.setSourceServiceId(((Number)dbMap.get(SOURCE_SERVICE_ID)).intValue()); - indicator.setDestServiceId(((Number)dbMap.get(DEST_SERVICE_ID)).intValue()); - indicator.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue()); - indicator.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue()); - return indicator; + @Override public ServiceRelationServerSideMetrics map2Data(Map dbMap) { + ServiceRelationServerSideMetrics metrics = new ServiceRelationServerSideMetrics(); + metrics.setEntityId((String)dbMap.get(ENTITY_ID)); + metrics.setSourceServiceId(((Number)dbMap.get(SOURCE_SERVICE_ID)).intValue()); + metrics.setDestServiceId(((Number)dbMap.get(DEST_SERVICE_ID)).intValue()); + metrics.setComponentId(((Number)dbMap.get(COMPONENT_ID)).intValue()); + metrics.setTimeBucket(((Number)dbMap.get(TIME_BUCKET)).longValue()); + return metrics; } - @Override public Map data2Map(ServiceRelationServerSideIndicator storageData) { + @Override public Map data2Map(ServiceRelationServerSideMetrics storageData) { Map map = new HashMap<>(); map.put(ENTITY_ID, storageData.getEntityId()); map.put(SOURCE_SERVICE_ID, storageData.getSourceServiceId()); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/CPMIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/CPMMetrics.java similarity index 77% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/CPMIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/CPMMetrics.java index 023c2cf9054e..a7ed5a9a6dca 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/CPMIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/CPMMetrics.java @@ -16,18 +16,18 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; import org.apache.skywalking.oap.server.core.query.sql.Function; import org.apache.skywalking.oap.server.core.storage.annotation.Column; /** * @author wusheng */ -@IndicatorFunction(functionName = "cpm") -public abstract class CPMIndicator extends Indicator implements LongValueHolder { +@MetricsFunction(functionName = "cpm") +public abstract class CPMMetrics extends Metrics implements LongValueHolder { protected static final String VALUE = "value"; protected static final String TOTAL = "total"; @@ -40,9 +40,9 @@ public final void combine(@ConstOne long count) { this.total += count; } - @Override public final void combine(Indicator indicator) { - CPMIndicator countIndicator = (CPMIndicator)indicator; - combine(countIndicator.total); + @Override public final void combine(Metrics metrics) { + CPMMetrics cpmMetrics = (CPMMetrics)metrics; + combine(cpmMetrics.total); } @Override public void calculate() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/CountIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/CountMetrics.java similarity index 74% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/CountIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/CountMetrics.java index ea99d42c9aa7..7aab20cc403e 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/CountIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/CountMetrics.java @@ -16,18 +16,18 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; import org.apache.skywalking.oap.server.core.query.sql.Function; import org.apache.skywalking.oap.server.core.storage.annotation.Column; /** * @author peng-yongsheng */ -@IndicatorFunction(functionName = "count") -public abstract class CountIndicator extends Indicator implements LongValueHolder { +@MetricsFunction(functionName = "count") +public abstract class CountMetrics extends Metrics implements LongValueHolder { protected static final String VALUE = "value"; @@ -38,9 +38,9 @@ public final void combine(@ConstOne long count) { this.value += count; } - @Override public final void combine(Indicator indicator) { - CountIndicator countIndicator = (CountIndicator)indicator; - combine(countIndicator.value); + @Override public final void combine(Metrics metrics) { + CountMetrics countMetrics = (CountMetrics)metrics; + combine(countMetrics.value); } @Override public void calculate() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/DoubleAvgIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/DoubleAvgMetrics.java similarity index 78% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/DoubleAvgIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/DoubleAvgMetrics.java index 9b7f9dccfe51..9e708008292e 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/DoubleAvgIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/DoubleAvgMetrics.java @@ -16,18 +16,18 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; import org.apache.skywalking.oap.server.core.query.sql.Function; import org.apache.skywalking.oap.server.core.storage.annotation.Column; /** * @author peng-yongsheng */ -@IndicatorFunction(functionName = "doubleAvg") -public abstract class DoubleAvgIndicator extends Indicator implements DoubleValueHolder { +@MetricsFunction(functionName = "doubleAvg") +public abstract class DoubleAvgMetrics extends Metrics implements DoubleValueHolder { protected static final String SUMMATION = "summation"; protected static final String COUNT = "count"; @@ -43,9 +43,9 @@ public final void combine(@SourceFrom double summation, @ConstOne int count) { this.count += count; } - @Override public final void combine(Indicator indicator) { - DoubleAvgIndicator avgIndicator = (DoubleAvgIndicator)indicator; - combine(avgIndicator.summation, avgIndicator.count); + @Override public final void combine(Metrics metrics) { + DoubleAvgMetrics doubleAvgMetrics = (DoubleAvgMetrics)metrics; + combine(doubleAvgMetrics.summation, doubleAvgMetrics.count); } @Override public final void calculate() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/DoubleValueHolder.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/DoubleValueHolder.java similarity index 93% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/DoubleValueHolder.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/DoubleValueHolder.java index 645ed76ce695..f42406eab3a8 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/DoubleValueHolder.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/DoubleValueHolder.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; /** * DoubleValueHolder always holds a value of double. diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntKeyLongValue.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/IntKeyLongValue.java similarity index 97% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntKeyLongValue.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/IntKeyLongValue.java index cd7d179d5056..bcfde3929e44 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntKeyLongValue.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/IntKeyLongValue.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import java.util.Objects; import lombok.*; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntKeyLongValueArray.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/IntKeyLongValueArray.java similarity index 97% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntKeyLongValueArray.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/IntKeyLongValueArray.java index 8f8c7c05e2f7..e8adbe3c9977 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntKeyLongValueArray.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/IntKeyLongValueArray.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import java.util.ArrayList; import org.apache.skywalking.oap.server.core.Const; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntValueHolder.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/IntValueHolder.java similarity index 93% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntValueHolder.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/IntValueHolder.java index 44f46b2baf5b..52c40770e17f 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntValueHolder.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/IntValueHolder.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; /** * IntValueHolder always holds a value of int. diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongAvgIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/LongAvgMetrics.java similarity index 78% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongAvgIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/LongAvgMetrics.java index 3d4fce88e9e7..fce1e58b903a 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongAvgIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/LongAvgMetrics.java @@ -16,18 +16,18 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; import org.apache.skywalking.oap.server.core.query.sql.Function; import org.apache.skywalking.oap.server.core.storage.annotation.Column; /** * @author peng-yongsheng */ -@IndicatorFunction(functionName = "longAvg") -public abstract class LongAvgIndicator extends Indicator implements LongValueHolder { +@MetricsFunction(functionName = "longAvg") +public abstract class LongAvgMetrics extends Metrics implements LongValueHolder { protected static final String SUMMATION = "summation"; protected static final String COUNT = "count"; @@ -43,9 +43,9 @@ public final void combine(@SourceFrom long summation, @ConstOne int count) { this.count += count; } - @Override public final void combine(Indicator indicator) { - LongAvgIndicator avgIndicator = (LongAvgIndicator)indicator; - combine(avgIndicator.summation, avgIndicator.count); + @Override public final void combine(Metrics metrics) { + LongAvgMetrics longAvgMetrics = (LongAvgMetrics)metrics; + combine(longAvgMetrics.summation, longAvgMetrics.count); } @Override public final void calculate() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongValueHolder.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/LongValueHolder.java similarity index 93% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongValueHolder.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/LongValueHolder.java index 59b58084538c..904325d13927 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongValueHolder.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/LongValueHolder.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; /** * LongValueHolder always holds a value of long. diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/MaxDoubleIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/MaxDoubleMetrics.java similarity index 73% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/MaxDoubleIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/MaxDoubleMetrics.java index fb5f03fc835d..c953710e002c 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/MaxDoubleIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/MaxDoubleMetrics.java @@ -16,17 +16,17 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; import org.apache.skywalking.oap.server.core.storage.annotation.Column; /** * @author wusheng */ -@IndicatorFunction(functionName = "maxDouble") -public abstract class MaxDoubleIndicator extends Indicator implements DoubleValueHolder { +@MetricsFunction(functionName = "maxDouble") +public abstract class MaxDoubleMetrics extends Metrics implements DoubleValueHolder { protected static final String VALUE = "value"; @@ -39,9 +39,9 @@ public final void combine(@SourceFrom double count) { } } - @Override public final void combine(Indicator indicator) { - MaxDoubleIndicator countIndicator = (MaxDoubleIndicator)indicator; - combine(countIndicator.value); + @Override public final void combine(Metrics metrics) { + MaxDoubleMetrics maxDoubleMetrics = (MaxDoubleMetrics)metrics; + combine(maxDoubleMetrics.value); } @Override public void calculate() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/MaxLongIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/MaxLongMetrics.java similarity index 74% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/MaxLongIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/MaxLongMetrics.java index 48dc5b42bb0e..f336aaaf3302 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/MaxLongIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/MaxLongMetrics.java @@ -16,17 +16,17 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; import org.apache.skywalking.oap.server.core.storage.annotation.Column; /** * @author liuhaoyang **/ -@IndicatorFunction(functionName = "max") -public abstract class MaxLongIndicator extends Indicator implements LongValueHolder { +@MetricsFunction(functionName = "max") +public abstract class MaxLongMetrics extends Metrics implements LongValueHolder { protected static final String VALUE = "value"; @@ -39,9 +39,9 @@ public final void combine(@SourceFrom long count) { } } - @Override public final void combine(Indicator indicator) { - MaxLongIndicator countIndicator = (MaxLongIndicator)indicator; - combine(countIndicator.value); + @Override public final void combine(Metrics metrics) { + MaxLongMetrics maxLongMetrics = (MaxLongMetrics)metrics; + combine(maxLongMetrics.value); } @Override public void calculate() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/Metrics.java similarity index 91% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/Indicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/Metrics.java index 42d4af1a5f01..96b59da302c3 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/Indicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/Metrics.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import lombok.*; import org.apache.skywalking.oap.server.core.remote.data.StreamData; @@ -27,7 +27,7 @@ /** * @author peng-yongsheng */ -public abstract class Indicator extends StreamData implements StorageData { +public abstract class Metrics extends StreamData implements StorageData { private static DateTimeFormatter TIME_BUCKET_MONTH_FORMATTER = DateTimeFormat.forPattern("yyyyMM"); @@ -38,15 +38,15 @@ public abstract class Indicator extends StreamData implements StorageData { public abstract String id(); - public abstract void combine(Indicator indicator); + public abstract void combine(Metrics metrics); public abstract void calculate(); - public abstract Indicator toHour(); + public abstract Metrics toHour(); - public abstract Indicator toDay(); + public abstract Metrics toDay(); - public abstract Indicator toMonth(); + public abstract Metrics toMonth(); public long toTimeBucketInHour() { if (isMinuteBucket()) { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IndicatorMetaInfo.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/MetricsMetaInfo.java similarity index 72% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IndicatorMetaInfo.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/MetricsMetaInfo.java index aa157871270f..59a547bccd26 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IndicatorMetaInfo.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/MetricsMetaInfo.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import lombok.*; import org.apache.skywalking.oap.server.core.Const; @@ -24,26 +24,26 @@ /** * @author wusheng */ -public class IndicatorMetaInfo { - @Setter @Getter private String indicatorName; +public class MetricsMetaInfo { + @Setter @Getter private String metricsName; @Setter @Getter private int scope; @Setter @Getter private String id; - public IndicatorMetaInfo(String indicatorName, int scope) { - this.indicatorName = indicatorName; + public MetricsMetaInfo(String metricsName, int scope) { + this.metricsName = metricsName; this.scope = scope; this.id = Const.EMPTY_STRING; } - public IndicatorMetaInfo(String indicatorName, int scope, String id) { - this.indicatorName = indicatorName; + public MetricsMetaInfo(String metricsName, int scope, String id) { + this.metricsName = metricsName; this.scope = scope; this.id = id; } @Override public String toString() { - return "IndicatorMetaInfo{" + - "indicatorName='" + indicatorName + '\'' + + return "MetricsMetaInfo{" + + "metricsName='" + metricsName + '\'' + ", scope=" + scope + ", id='" + id + '\'' + '}'; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P50Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P50Metrics.java similarity index 75% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P50Indicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P50Metrics.java index fa841ef504aa..238eac1e19a7 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P50Indicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P50Metrics.java @@ -16,18 +16,18 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorFunction; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsFunction; /** * P50 * * @author wusheng */ -@IndicatorFunction(functionName = "p50") -public abstract class P50Indicator extends PxxIndicator { - public P50Indicator() { +@MetricsFunction(functionName = "p50") +public abstract class P50Metrics extends PxxMetrics { + public P50Metrics() { super(50); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P75Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P75Metrics.java similarity index 75% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P75Indicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P75Metrics.java index 81569fe3e438..208eb8670b87 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P75Indicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P75Metrics.java @@ -16,18 +16,18 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorFunction; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsFunction; /** * P75 * * @author wusheng */ -@IndicatorFunction(functionName = "p75") -public abstract class P75Indicator extends PxxIndicator { - public P75Indicator() { +@MetricsFunction(functionName = "p75") +public abstract class P75Metrics extends PxxMetrics { + public P75Metrics() { super(75); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P90Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P90Metrics.java similarity index 75% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P90Indicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P90Metrics.java index 034341b72504..9e5464e5b2d1 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P90Indicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P90Metrics.java @@ -16,18 +16,18 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorFunction; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsFunction; /** * P90 * * @author wusheng */ -@IndicatorFunction(functionName = "p90") -public abstract class P90Indicator extends PxxIndicator { - public P90Indicator() { +@MetricsFunction(functionName = "p90") +public abstract class P90Metrics extends PxxMetrics { + public P90Metrics() { super(90); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P95Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P95Metrics.java similarity index 75% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P95Indicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P95Metrics.java index 82bee47a90d6..8e5384285e56 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P95Indicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P95Metrics.java @@ -16,18 +16,18 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorFunction; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsFunction; /** * P95 * * @author wusheng */ -@IndicatorFunction(functionName = "p95") -public abstract class P95Indicator extends PxxIndicator { - public P95Indicator() { +@MetricsFunction(functionName = "p95") +public abstract class P95Metrics extends PxxMetrics { + public P95Metrics() { super(95); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P99Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P99Metrics.java similarity index 75% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P99Indicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P99Metrics.java index c17971789bfb..376d5bf97daa 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P99Indicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/P99Metrics.java @@ -16,18 +16,18 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorFunction; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsFunction; /** * P99 * * @author wusheng */ -@IndicatorFunction(functionName = "p99") -public abstract class P99Indicator extends PxxIndicator { - public P99Indicator() { +@MetricsFunction(functionName = "p99") +public abstract class P99Metrics extends PxxMetrics { + public P99Metrics() { super(99); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/PercentIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentMetrics.java similarity index 78% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/PercentIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentMetrics.java index 9c238f80095d..1224d92acbdd 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/PercentIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentMetrics.java @@ -16,19 +16,19 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.expression.EqualMatch; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.expression.EqualMatch; import org.apache.skywalking.oap.server.core.query.sql.Function; import org.apache.skywalking.oap.server.core.storage.annotation.Column; /** * @author wusheng */ -@IndicatorFunction(functionName = "percent") -public abstract class PercentIndicator extends Indicator implements IntValueHolder { +@MetricsFunction(functionName = "percent") +public abstract class PercentMetrics extends Metrics implements IntValueHolder { protected static final String TOTAL = "total"; protected static final String MATCH = "match"; protected static final String PERCENTAGE = "percentage"; @@ -48,9 +48,9 @@ public final void combine(@Expression EqualMatch expression, @ExpressionArg0 Obj total++; } - @Override public final void combine(Indicator indicator) { - total += ((PercentIndicator)indicator).total; - match += ((PercentIndicator)indicator).match; + @Override public final void combine(Metrics metrics) { + total += ((PercentMetrics)metrics).total; + match += ((PercentMetrics)metrics).match; } @Override public void calculate() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/PxxMetrics.java similarity index 86% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/PxxMetrics.java index d70af2a7abad..1cc88c2a0d17 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/PxxMetrics.java @@ -16,16 +16,16 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import java.util.*; import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; import org.apache.skywalking.oap.server.core.query.sql.Function; import org.apache.skywalking.oap.server.core.storage.annotation.Column; /** - * PxxIndicator is a parent indicator for p99/p95/p90/p75/p50 indicators. P(xx) indicator is also for P(xx) percentile. + * PxxMetrics is a parent metrics for p99/p95/p90/p75/p50 metrics. P(xx) metrics is also for P(xx) percentile. * * A percentile (or a centile) is a measure used in statistics indicating the value below which a given percentage of * observations in a group of observations fall. For example, the 20th percentile is the value (or score) below which @@ -33,7 +33,7 @@ * * @author wusheng, peng-yongsheng */ -public abstract class PxxIndicator extends Indicator implements IntValueHolder { +public abstract class PxxMetrics extends Metrics implements IntValueHolder { protected static final String DETAIL_GROUP = "detail_group"; protected static final String VALUE = "value"; protected static final String PRECISION = "precision"; @@ -45,7 +45,7 @@ public abstract class PxxIndicator extends Indicator implements IntValueHolder { private final int percentileRank; private Map detailIndex; - public PxxIndicator(int percentileRank) { + public PxxMetrics(int percentileRank) { this.percentileRank = percentileRank; detailGroup = new IntKeyLongValueArray(30); } @@ -69,12 +69,12 @@ public final void combine(@SourceFrom int value, @Arg int precision) { } @Override - public void combine(Indicator indicator) { - PxxIndicator pxxIndicator = (PxxIndicator)indicator; + public void combine(Metrics metrics) { + PxxMetrics pxxMetrics = (PxxMetrics)metrics; this.indexCheckAndInit(); - pxxIndicator.indexCheckAndInit(); + pxxMetrics.indexCheckAndInit(); - pxxIndicator.detailIndex.forEach((key, element) -> { + pxxMetrics.detailIndex.forEach((key, element) -> { IntKeyLongValue existingElement = this.detailIndex.get(key); if (existingElement == null) { existingElement = new IntKeyLongValue(); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/SumIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/SumMetrics.java similarity index 75% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/SumIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/SumMetrics.java index 89710dfef030..8a83844e58fc 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/SumIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/SumMetrics.java @@ -16,18 +16,18 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; import org.apache.skywalking.oap.server.core.query.sql.Function; import org.apache.skywalking.oap.server.core.storage.annotation.Column; /** * @author wusheng */ -@IndicatorFunction(functionName = "sum") -public abstract class SumIndicator extends Indicator implements LongValueHolder { +@MetricsFunction(functionName = "sum") +public abstract class SumMetrics extends Metrics implements LongValueHolder { protected static final String VALUE = "value"; @@ -38,9 +38,9 @@ public final void combine(@SourceFrom long count) { this.value += count; } - @Override public final void combine(Indicator indicator) { - SumIndicator countIndicator = (SumIndicator)indicator; - combine(countIndicator.value); + @Override public final void combine(Metrics metrics) { + SumMetrics sumMetrics = (SumMetrics)metrics; + combine(sumMetrics.value); } @Override public void calculate() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/ThermodynamicIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/ThermodynamicMetrics.java similarity index 81% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/ThermodynamicIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/ThermodynamicMetrics.java index 708c0053d754..a6ee4758e196 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/ThermodynamicIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/ThermodynamicMetrics.java @@ -16,17 +16,15 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; -import lombok.Setter; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*; +import java.util.*; +import lombok.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.*; import org.apache.skywalking.oap.server.core.storage.annotation.Column; /** - * Thermodynamic indicator represents the calculator for heat map. + * Thermodynamic metrics represents the calculator for heat map. * * It groups the given collection of values by the given step and number of steps. * @@ -35,8 +33,8 @@ * * @author wusheng, peng-yongsheng */ -@IndicatorFunction(functionName = "thermodynamic") -public abstract class ThermodynamicIndicator extends Indicator { +@MetricsFunction(functionName = "thermodynamic") +public abstract class ThermodynamicMetrics extends Metrics { public static final String DETAIL_GROUP = "detail_group"; public static final String STEP = "step"; public static final String NUM_OF_STEPS = "num_of_steps"; @@ -84,13 +82,13 @@ public final void combine(@SourceFrom int value, @Arg int step, @Arg int maxNumO } @Override - public void combine(Indicator indicator) { - ThermodynamicIndicator thermodynamicIndicator = (ThermodynamicIndicator)indicator; + public void combine(Metrics metrics) { + ThermodynamicMetrics thermodynamicMetrics = (ThermodynamicMetrics)metrics; this.indexCheckAndInit(); - thermodynamicIndicator.indexCheckAndInit(); - final ThermodynamicIndicator self = this; + thermodynamicMetrics.indexCheckAndInit(); + final ThermodynamicMetrics self = this; - thermodynamicIndicator.detailIndex.forEach((key, element) -> { + thermodynamicMetrics.detailIndex.forEach((key, element) -> { IntKeyLongValue existingElement = self.detailIndex.get(key); if (existingElement == null) { existingElement = new IntKeyLongValue(); @@ -104,7 +102,7 @@ public void combine(Indicator indicator) { } /** - * For Thermodynamic indicator, no single value field. Need to do nothing here. + * For Thermodynamic metrics, no single value field. Need to do nothing here. */ @Override public final void calculate() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/WithMetadata.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/WithMetadata.java similarity index 82% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/WithMetadata.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/WithMetadata.java index c3a2cc3a1f4c..1ada004d89fd 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/WithMetadata.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/WithMetadata.java @@ -16,13 +16,13 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; /** - * Indicator, which implement this interface, could provide {@link IndicatorMetaInfo}. + * Metrics, which implement this interface, could provide {@link MetricsMetaInfo}. * * @author wusheng */ public interface WithMetadata { - IndicatorMetaInfo getMeta(); + MetricsMetaInfo getMeta(); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Arg.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/Arg.java similarity index 93% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Arg.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/Arg.java index fd212f2fd0f0..9a4a271dc5bf 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Arg.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/Arg.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/ConstOne.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/ConstOne.java similarity index 92% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/ConstOne.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/ConstOne.java index 475e573dc691..693c9573b06b 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/ConstOne.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/ConstOne.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; import java.lang.annotation.*; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Entrance.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/Entrance.java similarity index 92% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Entrance.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/Entrance.java index b2709ccb5bb7..5ebf15706bb7 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Entrance.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/Entrance.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; import java.lang.annotation.*; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Expression.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/Expression.java similarity index 93% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Expression.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/Expression.java index e763bc0d2a2a..8909990b6f95 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Expression.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/Expression.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/ExpressionArg0.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/ExpressionArg0.java similarity index 93% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/ExpressionArg0.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/ExpressionArg0.java index 8bde31a24e48..1e4384f3b1e7 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/ExpressionArg0.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/ExpressionArg0.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/ExpressionArg1.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/ExpressionArg1.java similarity index 93% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/ExpressionArg1.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/ExpressionArg1.java index 70dfc9a49e72..364ac7e1ceb5 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/ExpressionArg1.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/ExpressionArg1.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorAnnotationUtils.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsAnnotationUtils.java similarity index 78% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorAnnotationUtils.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsAnnotationUtils.java index c3ee5163924d..39f5b4686b57 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorAnnotationUtils.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsAnnotationUtils.java @@ -16,14 +16,14 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; /** * @author peng-yongsheng */ -public class IndicatorAnnotationUtils { +public class MetricsAnnotationUtils { - public static boolean isIndicator(Class aClass) { - return aClass.isAnnotationPresent(IndicatorType.class); + public static boolean isMetrics(Class aClass) { + return aClass.isAnnotationPresent(MetricsType.class); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorFunction.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsFunction.java similarity index 83% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorFunction.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsFunction.java index 8f19731337b0..6adaf5869a00 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorFunction.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsFunction.java @@ -16,17 +16,17 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; import java.lang.annotation.*; /** - * IndicatorFunction annotation represent this a function in OAL script. + * MetricsFunction annotation represent this a function in OAL script. * * @author wusheng */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface IndicatorFunction { +public @interface MetricsFunction { String functionName(); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorType.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsType.java similarity index 89% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorType.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsType.java index 554325768009..a1c5fca76ed8 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorType.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsType.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; import java.lang.annotation.*; @@ -25,5 +25,5 @@ */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface IndicatorType { +public @interface MetricsType { } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorTypeListener.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsTypeListener.java similarity index 76% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorTypeListener.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsTypeListener.java index bffcbbfae36e..9b32c33984da 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/IndicatorTypeListener.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/MetricsTypeListener.java @@ -16,29 +16,29 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; import java.lang.annotation.Annotation; -import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess; +import org.apache.skywalking.oap.server.core.analysis.worker.MetricsProcess; import org.apache.skywalking.oap.server.core.annotation.AnnotationListener; import org.apache.skywalking.oap.server.library.module.ModuleManager; /** * @author peng-yongsheng */ -public class IndicatorTypeListener implements AnnotationListener { +public class MetricsTypeListener implements AnnotationListener { private final ModuleManager moduleManager; - public IndicatorTypeListener(ModuleManager moduleManager) { + public MetricsTypeListener(ModuleManager moduleManager) { this.moduleManager = moduleManager; } @Override public Class annotation() { - return IndicatorType.class; + return MetricsType.class; } @Override public void notify(Class aClass) { - IndicatorProcess.INSTANCE.create(moduleManager, aClass); + MetricsProcess.INSTANCE.create(moduleManager, aClass); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/SourceFrom.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/SourceFrom.java similarity index 92% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/SourceFrom.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/SourceFrom.java index 935cb222cd8b..1d2ca66adc73 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/SourceFrom.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/annotation/SourceFrom.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.annotation; +package org.apache.skywalking.oap.server.core.analysis.metrics.annotation; import java.lang.annotation.*; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/BinaryMatchExpression.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/BinaryMatchExpression.java similarity index 94% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/BinaryMatchExpression.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/BinaryMatchExpression.java index 8fd5dbc02328..db7422a1434e 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/BinaryMatchExpression.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/BinaryMatchExpression.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.expression; +package org.apache.skywalking.oap.server.core.analysis.metrics.expression; /** * BinaryMatchExpression accepts two calculate factors, diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/EqualMatch.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/EqualMatch.java similarity index 92% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/EqualMatch.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/EqualMatch.java index 60597480e25c..f5916f6b7da1 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/EqualMatch.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/EqualMatch.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.expression; +package org.apache.skywalking.oap.server.core.analysis.metrics.expression; /** * diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/GreaterEqualMatch.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/GreaterEqualMatch.java similarity index 94% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/GreaterEqualMatch.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/GreaterEqualMatch.java index a0de184d5641..f26aac78c63c 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/GreaterEqualMatch.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/GreaterEqualMatch.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.expression; +package org.apache.skywalking.oap.server.core.analysis.metrics.expression; /** * @author peng-yongsheng diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/GreaterMatch.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/GreaterMatch.java similarity index 94% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/GreaterMatch.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/GreaterMatch.java index ac14097eb26a..87b06c54b5b2 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/GreaterMatch.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/GreaterMatch.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.expression; +package org.apache.skywalking.oap.server.core.analysis.metrics.expression; /** * @author peng-yongsheng diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/LessEqualMatch.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/LessEqualMatch.java similarity index 94% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/LessEqualMatch.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/LessEqualMatch.java index a07260d46af6..00f64f1f917c 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/LessEqualMatch.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/LessEqualMatch.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.expression; +package org.apache.skywalking.oap.server.core.analysis.metrics.expression; /** * @author peng-yongsheng diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/LessMatch.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/LessMatch.java similarity index 94% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/LessMatch.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/LessMatch.java index 3d78ca17e211..5583def7832f 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/expression/LessMatch.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/expression/LessMatch.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.expression; +package org.apache.skywalking.oap.server.core.analysis.metrics.expression; /** * @author peng-yongsheng diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/AlarmNotifyWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/AlarmNotifyWorker.java index 3812355e8c5d..be827756ce89 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/AlarmNotifyWorker.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/AlarmNotifyWorker.java @@ -19,7 +19,7 @@ package org.apache.skywalking.oap.server.core.analysis.worker; import org.apache.skywalking.oap.server.core.alarm.AlarmEntrance; -import org.apache.skywalking.oap.server.core.analysis.indicator.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; import org.apache.skywalking.oap.server.core.worker.AbstractWorker; import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder; @@ -28,7 +28,7 @@ * * @author wusheng */ -public class AlarmNotifyWorker extends AbstractWorker { +public class AlarmNotifyWorker extends AbstractWorker { private AlarmEntrance entrance; public AlarmNotifyWorker(ModuleDefineHolder moduleDefineHolder) { @@ -36,9 +36,9 @@ public AlarmNotifyWorker(ModuleDefineHolder moduleDefineHolder) { this.entrance = new AlarmEntrance(moduleDefineHolder); } - @Override public void in(Indicator indicator) { - if (indicator instanceof WithMetadata) { - entrance.forward(indicator); + @Override public void in(Metrics metrics) { + if (metrics instanceof WithMetadata) { + entrance.forward(metrics); } } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/ExportWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/ExportWorker.java index 940323a393d9..6f1edc02aedf 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/ExportWorker.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/ExportWorker.java @@ -18,7 +18,7 @@ package org.apache.skywalking.oap.server.core.analysis.worker; -import org.apache.skywalking.oap.server.core.analysis.indicator.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; import org.apache.skywalking.oap.server.core.exporter.*; import org.apache.skywalking.oap.server.core.worker.AbstractWorker; import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder; @@ -26,20 +26,20 @@ /** * @author wusheng */ -public class ExportWorker extends AbstractWorker { +public class ExportWorker extends AbstractWorker { private MetricValuesExportService exportService; public ExportWorker(ModuleDefineHolder moduleDefineHolder) { super(moduleDefineHolder); } - @Override public void in(Indicator indicator) { + @Override public void in(Metrics metrics) { if (exportService != null || getModuleDefineHolder().has(ExporterModule.NAME)) { - if (indicator instanceof WithMetadata) { + if (metrics instanceof WithMetadata) { if (exportService == null) { exportService = getModuleDefineHolder().find(ExporterModule.NAME).provider().getService(MetricValuesExportService.class); } - exportService.export(((WithMetadata)indicator).getMeta(), indicator); + exportService.export(((WithMetadata)metrics).getMeta(), metrics); } } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorProcess.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorProcess.java deleted file mode 100644 index de9f6be4476e..000000000000 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorProcess.java +++ /dev/null @@ -1,95 +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.skywalking.oap.server.core.analysis.worker; - -import java.util.*; -import lombok.Getter; -import org.apache.skywalking.oap.server.core.*; -import org.apache.skywalking.oap.server.core.analysis.DisableRegister; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.storage.*; -import org.apache.skywalking.oap.server.core.storage.annotation.StorageEntityAnnotationUtils; -import org.apache.skywalking.oap.server.library.module.ModuleManager; - -/** - * @author peng-yongsheng - */ -public enum IndicatorProcess { - INSTANCE; - - private Map, IndicatorAggregateWorker> entryWorkers = new HashMap<>(); - @Getter private List persistentWorkers = new ArrayList<>(); - - public void in(Indicator indicator) { - IndicatorAggregateWorker worker = entryWorkers.get(indicator.getClass()); - if (worker != null) { - worker.in(indicator); - } - } - - public void create(ModuleManager moduleManager, Class indicatorClass) { - String modelName = StorageEntityAnnotationUtils.getModelName(indicatorClass); - - if (DisableRegister.INSTANCE.include(modelName)) { - return; - } - - Class builderClass = StorageEntityAnnotationUtils.getBuilder(indicatorClass); - - StorageDAO storageDAO = moduleManager.find(StorageModule.NAME).provider().getService(StorageDAO.class); - IIndicatorDAO indicatorDAO; - try { - indicatorDAO = storageDAO.newIndicatorDao(builderClass.newInstance()); - } catch (InstantiationException | IllegalAccessException e) { - throw new UnexpectedException("Create " + builderClass.getSimpleName() + " indicator DAO failure.", e); - } - - IndicatorPersistentWorker minutePersistentWorker = minutePersistentWorker(moduleManager, indicatorDAO, modelName); - IndicatorPersistentWorker hourPersistentWorker = worker(moduleManager, indicatorDAO, modelName + Const.ID_SPLIT + Downsampling.Hour.getName()); - IndicatorPersistentWorker dayPersistentWorker = worker(moduleManager, indicatorDAO, modelName + Const.ID_SPLIT + Downsampling.Day.getName()); - IndicatorPersistentWorker monthPersistentWorker = worker(moduleManager, indicatorDAO, modelName + Const.ID_SPLIT + Downsampling.Month.getName()); - - IndicatorTransWorker transWorker = new IndicatorTransWorker(moduleManager, modelName, minutePersistentWorker, hourPersistentWorker, dayPersistentWorker, monthPersistentWorker); - IndicatorRemoteWorker remoteWorker = new IndicatorRemoteWorker(moduleManager, transWorker, modelName); - IndicatorAggregateWorker aggregateWorker = new IndicatorAggregateWorker(moduleManager, remoteWorker, modelName); - - entryWorkers.put(indicatorClass, aggregateWorker); - } - - private IndicatorPersistentWorker minutePersistentWorker(ModuleManager moduleManager, - IIndicatorDAO indicatorDAO, String modelName) { - AlarmNotifyWorker alarmNotifyWorker = new AlarmNotifyWorker(moduleManager); - ExportWorker exportWorker = new ExportWorker(moduleManager); - - IndicatorPersistentWorker minutePersistentWorker = new IndicatorPersistentWorker(moduleManager, modelName, - 1000, indicatorDAO, alarmNotifyWorker, exportWorker); - persistentWorkers.add(minutePersistentWorker); - - return minutePersistentWorker; - } - - private IndicatorPersistentWorker worker(ModuleManager moduleManager, - IIndicatorDAO indicatorDAO, String modelName) { - IndicatorPersistentWorker persistentWorker = new IndicatorPersistentWorker(moduleManager, modelName, - 1000, indicatorDAO, null, null); - persistentWorkers.add(persistentWorker); - - return persistentWorker; - } -} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorTransWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorTransWorker.java deleted file mode 100644 index 1c6bc4280b6c..000000000000 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorTransWorker.java +++ /dev/null @@ -1,91 +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.skywalking.oap.server.core.analysis.worker; - -import java.util.Objects; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.worker.AbstractWorker; -import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder; -import org.apache.skywalking.oap.server.telemetry.TelemetryModule; -import org.apache.skywalking.oap.server.telemetry.api.*; -import org.slf4j.*; - -/** - * @author peng-yongsheng - */ -public class IndicatorTransWorker extends AbstractWorker { - - private static final Logger logger = LoggerFactory.getLogger(IndicatorTransWorker.class); - - private final IndicatorPersistentWorker minutePersistenceWorker; - private final IndicatorPersistentWorker hourPersistenceWorker; - private final IndicatorPersistentWorker dayPersistenceWorker; - private final IndicatorPersistentWorker monthPersistenceWorker; - - private CounterMetric aggregationMinCounter; - private CounterMetric aggregationHourCounter; - private CounterMetric aggregationDayCounter; - private CounterMetric aggregationMonthCounter; - - public IndicatorTransWorker(ModuleDefineHolder moduleDefineHolder, String modelName, - IndicatorPersistentWorker minutePersistenceWorker, - IndicatorPersistentWorker hourPersistenceWorker, - IndicatorPersistentWorker dayPersistenceWorker, - IndicatorPersistentWorker monthPersistenceWorker) { - super(moduleDefineHolder); - this.minutePersistenceWorker = minutePersistenceWorker; - this.hourPersistenceWorker = hourPersistenceWorker; - this.dayPersistenceWorker = dayPersistenceWorker; - this.monthPersistenceWorker = monthPersistenceWorker; - - MetricCreator metricCreator = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); - aggregationMinCounter = metricCreator.createCounter("indicator_aggregation", "The number of rows in aggregation", - new MetricTag.Keys("metricName", "level", "dimensionality"), new MetricTag.Values(modelName, "2", "min")); - aggregationHourCounter = metricCreator.createCounter("indicator_aggregation", "The number of rows in aggregation", - new MetricTag.Keys("metricName", "level", "dimensionality"), new MetricTag.Values(modelName, "2", "hour")); - aggregationDayCounter = metricCreator.createCounter("indicator_aggregation", "The number of rows in aggregation", - new MetricTag.Keys("metricName", "level", "dimensionality"), new MetricTag.Values(modelName, "2", "day")); - aggregationMonthCounter = metricCreator.createCounter("indicator_aggregation", "The number of rows in aggregation", - new MetricTag.Keys("metricName", "level", "dimensionality"), new MetricTag.Values(modelName, "2", "month")); - } - - @Override public void in(Indicator indicator) { - if (Objects.nonNull(hourPersistenceWorker)) { - aggregationMonthCounter.inc(); - hourPersistenceWorker.in(indicator.toHour()); - } - if (Objects.nonNull(dayPersistenceWorker)) { - aggregationDayCounter.inc(); - dayPersistenceWorker.in(indicator.toDay()); - } - if (Objects.nonNull(monthPersistenceWorker)) { - aggregationHourCounter.inc(); - monthPersistenceWorker.in(indicator.toMonth()); - } - - /* - * Minute persistent must be at the end of all time dimensionalities - * Because #toHour, #toDay, #toMonth include clone inside, which could avoid concurrency situation. - */ - if (Objects.nonNull(minutePersistenceWorker)) { - aggregationMinCounter.inc(); - minutePersistenceWorker.in(indicator); - } - } -} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorAggregateWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsAggregateWorker.java similarity index 63% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorAggregateWorker.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsAggregateWorker.java index 66380fd6b560..7dffea3e4c55 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorAggregateWorker.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsAggregateWorker.java @@ -23,7 +23,7 @@ import org.apache.skywalking.apm.commons.datacarrier.consumer.*; import org.apache.skywalking.oap.server.core.UnexpectedException; import org.apache.skywalking.oap.server.core.analysis.data.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.worker.AbstractWorker; import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder; import org.apache.skywalking.oap.server.telemetry.TelemetryModule; @@ -33,26 +33,26 @@ /** * @author peng-yongsheng */ -public class IndicatorAggregateWorker extends AbstractWorker { +public class MetricsAggregateWorker extends AbstractWorker { - private static final Logger logger = LoggerFactory.getLogger(IndicatorAggregateWorker.class); + private static final Logger logger = LoggerFactory.getLogger(MetricsAggregateWorker.class); - private AbstractWorker nextWorker; - private final DataCarrier dataCarrier; - private final MergeDataCache mergeDataCache; + private AbstractWorker nextWorker; + private final DataCarrier dataCarrier; + private final MergeDataCache mergeDataCache; private final String modelName; - private CounterMetric aggregationCounter; + private CounterMetrics aggregationCounter; private final long l2AggregationSendCycle; private long lastSendTimestamp; - IndicatorAggregateWorker(ModuleDefineHolder moduleDefineHolder, AbstractWorker nextWorker, + MetricsAggregateWorker(ModuleDefineHolder moduleDefineHolder, AbstractWorker nextWorker, String modelName) { super(moduleDefineHolder); this.modelName = modelName; this.nextWorker = nextWorker; this.mergeDataCache = new MergeDataCache<>(); - String name = "INDICATOR_L1_AGGREGATION"; - this.dataCarrier = new DataCarrier<>("IndicatorAggregateWorker." + modelName, name, 2, 10000); + String name = "METRICS_L1_AGGREGATION"; + this.dataCarrier = new DataCarrier<>("MetricsAggregateWorker." + modelName, name, 2, 10000); BulkConsumePool.Creator creator = new BulkConsumePool.Creator(name, BulkConsumePool.Creator.recommendMaxSize() * 2, 20); try { @@ -62,24 +62,24 @@ public class IndicatorAggregateWorker extends AbstractWorker { } this.dataCarrier.consume(ConsumerPoolFactory.INSTANCE.get(name), new AggregatorConsumer(this)); - MetricCreator metricCreator = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); - aggregationCounter = metricCreator.createCounter("indicator_aggregation", "The number of rows in aggregation", - new MetricTag.Keys("metricName", "level", "dimensionality"), new MetricTag.Values(modelName, "1", "min")); + MetricsCreator metricsCreator = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); + aggregationCounter = metricsCreator.createCounter("metrics_aggregation", "The number of rows in aggregation", + new MetricsTag.Keys("metricName", "level", "dimensionality"), new MetricsTag.Values(modelName, "1", "min")); lastSendTimestamp = System.currentTimeMillis(); - l2AggregationSendCycle = EnvUtil.getLong("INDICATOR_L1_AGGREGATION_SEND_CYCLE", 1000); + l2AggregationSendCycle = EnvUtil.getLong("METRICS_L1_AGGREGATION_SEND_CYCLE", 1000); } - @Override public final void in(Indicator indicator) { - indicator.setEndOfBatchContext(new EndOfBatchContext(false)); - dataCarrier.produce(indicator); + @Override public final void in(Metrics metrics) { + metrics.setEndOfBatchContext(new EndOfBatchContext(false)); + dataCarrier.produce(metrics); } - private void onWork(Indicator indicator) { + private void onWork(Metrics metrics) { aggregationCounter.inc(); - aggregate(indicator); + aggregate(metrics); - if (indicator.getEndOfBatchContext().isEndOfBatch()) { + if (metrics.getEndOfBatchContext().isEndOfBatch()) { if (shouldSend()) { sendToNext(); } @@ -116,22 +116,22 @@ private void sendToNext() { mergeDataCache.finishReadingLast(); } - private void aggregate(Indicator indicator) { + private void aggregate(Metrics metrics) { mergeDataCache.writing(); - if (mergeDataCache.containsKey(indicator)) { - mergeDataCache.get(indicator).combine(indicator); + if (mergeDataCache.containsKey(metrics)) { + mergeDataCache.get(metrics).combine(metrics); } else { - mergeDataCache.put(indicator); + mergeDataCache.put(metrics); } mergeDataCache.finishWriting(); } - private class AggregatorConsumer implements IConsumer { + private class AggregatorConsumer implements IConsumer { - private final IndicatorAggregateWorker aggregator; + private final MetricsAggregateWorker aggregator; - private AggregatorConsumer(IndicatorAggregateWorker aggregator) { + private AggregatorConsumer(MetricsAggregateWorker aggregator) { this.aggregator = aggregator; } @@ -139,21 +139,21 @@ private AggregatorConsumer(IndicatorAggregateWorker aggregator) { } - @Override public void consume(List data) { - Iterator inputIterator = data.iterator(); + @Override public void consume(List data) { + Iterator inputIterator = data.iterator(); int i = 0; while (inputIterator.hasNext()) { - Indicator indicator = inputIterator.next(); + Metrics metrics = inputIterator.next(); i++; if (i == data.size()) { - indicator.getEndOfBatchContext().setEndOfBatch(true); + metrics.getEndOfBatchContext().setEndOfBatch(true); } - aggregator.onWork(indicator); + aggregator.onWork(metrics); } } - @Override public void onError(List data, Throwable t) { + @Override public void onError(List data, Throwable t) { logger.error(t.getMessage(), t); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorPersistentWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java similarity index 62% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorPersistentWorker.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java index 416c5b600511..f094bd60eb11 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorPersistentWorker.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java @@ -23,8 +23,8 @@ import org.apache.skywalking.apm.commons.datacarrier.consumer.*; import org.apache.skywalking.oap.server.core.UnexpectedException; import org.apache.skywalking.oap.server.core.analysis.data.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.storage.IIndicatorDAO; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.storage.IMetricsDAO; import org.apache.skywalking.oap.server.core.worker.AbstractWorker; import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder; import org.slf4j.*; @@ -34,28 +34,28 @@ /** * @author peng-yongsheng */ -public class IndicatorPersistentWorker extends PersistenceWorker> { +public class MetricsPersistentWorker extends PersistenceWorker> { - private static final Logger logger = LoggerFactory.getLogger(IndicatorPersistentWorker.class); + private static final Logger logger = LoggerFactory.getLogger(MetricsPersistentWorker.class); private final String modelName; - private final MergeDataCache mergeDataCache; - private final IIndicatorDAO indicatorDAO; - private final AbstractWorker nextAlarmWorker; - private final AbstractWorker nextExportWorker; - private final DataCarrier dataCarrier; - - IndicatorPersistentWorker(ModuleDefineHolder moduleDefineHolder, String modelName, int batchSize, - IIndicatorDAO indicatorDAO, AbstractWorker nextAlarmWorker, - AbstractWorker nextExportWorker) { + private final MergeDataCache mergeDataCache; + private final IMetricsDAO metricsDAO; + private final AbstractWorker nextAlarmWorker; + private final AbstractWorker nextExportWorker; + private final DataCarrier dataCarrier; + + MetricsPersistentWorker(ModuleDefineHolder moduleDefineHolder, String modelName, int batchSize, + IMetricsDAO metricsDAO, AbstractWorker nextAlarmWorker, + AbstractWorker nextExportWorker) { super(moduleDefineHolder, batchSize); this.modelName = modelName; this.mergeDataCache = new MergeDataCache<>(); - this.indicatorDAO = indicatorDAO; + this.metricsDAO = metricsDAO; this.nextAlarmWorker = nextAlarmWorker; this.nextExportWorker = nextExportWorker; - String name = "INDICATOR_L2_AGGREGATION"; + String name = "METRICS_L2_AGGREGATION"; int size = BulkConsumePool.Creator.recommendMaxSize() / 8; if (size == 0) { size = 1; @@ -67,20 +67,20 @@ public class IndicatorPersistentWorker extends PersistenceWorker("IndicatorPersistentWorker." + modelName, name, 1, 2000); + this.dataCarrier = new DataCarrier<>("MetricsPersistentWorker." + modelName, name, 1, 2000); this.dataCarrier.consume(ConsumerPoolFactory.INSTANCE.get(name), new PersistentConsumer(this)); } - @Override void onWork(Indicator indicator) { - super.onWork(indicator); + @Override void onWork(Metrics metrics) { + super.onWork(metrics); } - @Override public void in(Indicator indicator) { - indicator.setEndOfBatchContext(new EndOfBatchContext(false)); - dataCarrier.produce(indicator); + @Override public void in(Metrics metrics) { + metrics.setEndOfBatchContext(new EndOfBatchContext(false)); + dataCarrier.produce(metrics); } - @Override public MergeDataCache getCache() { + @Override public MergeDataCache getCache() { return mergeDataCache; } @@ -96,12 +96,12 @@ public boolean flushAndSwitch() { return isSwitch; } - @Override public List prepareBatch(MergeDataCache cache) { + @Override public List prepareBatch(MergeDataCache cache) { List batchCollection = new LinkedList<>(); cache.getLast().collection().forEach(data -> { - Indicator dbData = null; + Metrics dbData = null; try { - dbData = indicatorDAO.get(modelName, data); + dbData = metricsDAO.get(modelName, data); } catch (Throwable t) { logger.error(t.getMessage(), t); } @@ -110,9 +110,9 @@ public boolean flushAndSwitch() { data.combine(dbData); data.calculate(); - batchCollection.add(indicatorDAO.prepareBatchUpdate(modelName, data)); + batchCollection.add(metricsDAO.prepareBatchUpdate(modelName, data)); } else { - batchCollection.add(indicatorDAO.prepareBatchInsert(modelName, data)); + batchCollection.add(metricsDAO.prepareBatchInsert(modelName, data)); } if (Objects.nonNull(nextAlarmWorker)) { @@ -129,12 +129,12 @@ public boolean flushAndSwitch() { return batchCollection; } - @Override public void cacheData(Indicator input) { + @Override public void cacheData(Metrics input) { mergeDataCache.writing(); if (mergeDataCache.containsKey(input)) { - Indicator indicator = mergeDataCache.get(input); - indicator.combine(input); - indicator.calculate(); + Metrics metrics = mergeDataCache.get(input); + metrics.combine(input); + metrics.calculate(); } else { input.calculate(); mergeDataCache.put(input); @@ -143,11 +143,11 @@ public boolean flushAndSwitch() { mergeDataCache.finishWriting(); } - private class PersistentConsumer implements IConsumer { + private class PersistentConsumer implements IConsumer { - private final IndicatorPersistentWorker persistent; + private final MetricsPersistentWorker persistent; - private PersistentConsumer(IndicatorPersistentWorker persistent) { + private PersistentConsumer(MetricsPersistentWorker persistent) { this.persistent = persistent; } @@ -155,21 +155,21 @@ private PersistentConsumer(IndicatorPersistentWorker persistent) { } - @Override public void consume(List data) { - Iterator inputIterator = data.iterator(); + @Override public void consume(List data) { + Iterator inputIterator = data.iterator(); int i = 0; while (inputIterator.hasNext()) { - Indicator indicator = inputIterator.next(); + Metrics metrics = inputIterator.next(); i++; if (i == data.size()) { - indicator.getEndOfBatchContext().setEndOfBatch(true); + metrics.getEndOfBatchContext().setEndOfBatch(true); } - persistent.onWork(indicator); + persistent.onWork(metrics); } } - @Override public void onError(List data, Throwable t) { + @Override public void onError(List data, Throwable t) { logger.error(t.getMessage(), t); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsProcess.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsProcess.java new file mode 100644 index 000000000000..11f849c2429b --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsProcess.java @@ -0,0 +1,95 @@ +/* + * 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.worker; + +import java.util.*; +import lombok.Getter; +import org.apache.skywalking.oap.server.core.*; +import org.apache.skywalking.oap.server.core.analysis.DisableRegister; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.storage.*; +import org.apache.skywalking.oap.server.core.storage.annotation.StorageEntityAnnotationUtils; +import org.apache.skywalking.oap.server.library.module.ModuleManager; + +/** + * @author peng-yongsheng + */ +public enum MetricsProcess { + INSTANCE; + + private Map, MetricsAggregateWorker> entryWorkers = new HashMap<>(); + @Getter private List persistentWorkers = new ArrayList<>(); + + public void in(Metrics metrics) { + MetricsAggregateWorker worker = entryWorkers.get(metrics.getClass()); + if (worker != null) { + worker.in(metrics); + } + } + + public void create(ModuleManager moduleManager, Class metricsClass) { + String modelName = StorageEntityAnnotationUtils.getModelName(metricsClass); + + if (DisableRegister.INSTANCE.include(modelName)) { + return; + } + + Class builderClass = StorageEntityAnnotationUtils.getBuilder(metricsClass); + + StorageDAO storageDAO = moduleManager.find(StorageModule.NAME).provider().getService(StorageDAO.class); + IMetricsDAO metricsDAO; + try { + metricsDAO = storageDAO.newMetricsDao(builderClass.newInstance()); + } catch (InstantiationException | IllegalAccessException e) { + throw new UnexpectedException("Create " + builderClass.getSimpleName() + " metrics DAO failure.", e); + } + + MetricsPersistentWorker minutePersistentWorker = minutePersistentWorker(moduleManager, metricsDAO, modelName); + MetricsPersistentWorker hourPersistentWorker = worker(moduleManager, metricsDAO, modelName + Const.ID_SPLIT + Downsampling.Hour.getName()); + MetricsPersistentWorker dayPersistentWorker = worker(moduleManager, metricsDAO, modelName + Const.ID_SPLIT + Downsampling.Day.getName()); + MetricsPersistentWorker monthPersistentWorker = worker(moduleManager, metricsDAO, modelName + Const.ID_SPLIT + Downsampling.Month.getName()); + + MetricsTransWorker transWorker = new MetricsTransWorker(moduleManager, modelName, minutePersistentWorker, hourPersistentWorker, dayPersistentWorker, monthPersistentWorker); + MetricsRemoteWorker remoteWorker = new MetricsRemoteWorker(moduleManager, transWorker, modelName); + MetricsAggregateWorker aggregateWorker = new MetricsAggregateWorker(moduleManager, remoteWorker, modelName); + + entryWorkers.put(metricsClass, aggregateWorker); + } + + private MetricsPersistentWorker minutePersistentWorker(ModuleManager moduleManager, + IMetricsDAO metricsDAO, String modelName) { + AlarmNotifyWorker alarmNotifyWorker = new AlarmNotifyWorker(moduleManager); + ExportWorker exportWorker = new ExportWorker(moduleManager); + + MetricsPersistentWorker minutePersistentWorker = new MetricsPersistentWorker(moduleManager, modelName, + 1000, metricsDAO, alarmNotifyWorker, exportWorker); + persistentWorkers.add(minutePersistentWorker); + + return minutePersistentWorker; + } + + private MetricsPersistentWorker worker(ModuleManager moduleManager, + IMetricsDAO metricsDAO, String modelName) { + MetricsPersistentWorker persistentWorker = new MetricsPersistentWorker(moduleManager, modelName, + 1000, metricsDAO, null, null); + persistentWorkers.add(persistentWorker); + + return persistentWorker; + } +} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorRemoteWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsRemoteWorker.java similarity index 78% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorRemoteWorker.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsRemoteWorker.java index 7f631002a54b..7ce93110d76f 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/IndicatorRemoteWorker.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsRemoteWorker.java @@ -19,7 +19,7 @@ package org.apache.skywalking.oap.server.core.analysis.worker; import org.apache.skywalking.oap.server.core.CoreModule; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.remote.RemoteSenderService; import org.apache.skywalking.oap.server.core.remote.selector.Selector; import org.apache.skywalking.oap.server.core.worker.AbstractWorker; @@ -29,15 +29,15 @@ /** * @author peng-yongsheng */ -public class IndicatorRemoteWorker extends AbstractWorker { +public class MetricsRemoteWorker extends AbstractWorker { - private static final Logger logger = LoggerFactory.getLogger(IndicatorRemoteWorker.class); + private static final Logger logger = LoggerFactory.getLogger(MetricsRemoteWorker.class); - private final AbstractWorker nextWorker; + private final AbstractWorker nextWorker; private final RemoteSenderService remoteSender; private final String modelName; - IndicatorRemoteWorker(ModuleDefineHolder moduleDefineHolder, AbstractWorker nextWorker, + MetricsRemoteWorker(ModuleDefineHolder moduleDefineHolder, AbstractWorker nextWorker, String modelName) { super(moduleDefineHolder); this.remoteSender = moduleDefineHolder.find(CoreModule.NAME).provider().getService(RemoteSenderService.class); @@ -45,9 +45,9 @@ public class IndicatorRemoteWorker extends AbstractWorker { this.modelName = modelName; } - @Override public final void in(Indicator indicator) { + @Override public final void in(Metrics metrics) { try { - remoteSender.send(nextWorker.getWorkerId(), indicator, Selector.HashCode); + remoteSender.send(nextWorker.getWorkerId(), metrics, Selector.HashCode); } catch (Throwable e) { logger.error(e.getMessage(), e); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsTransWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsTransWorker.java new file mode 100644 index 000000000000..e4d252092f1e --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsTransWorker.java @@ -0,0 +1,91 @@ +/* + * 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.worker; + +import java.util.Objects; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.worker.AbstractWorker; +import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder; +import org.apache.skywalking.oap.server.telemetry.TelemetryModule; +import org.apache.skywalking.oap.server.telemetry.api.*; +import org.slf4j.*; + +/** + * @author peng-yongsheng + */ +public class MetricsTransWorker extends AbstractWorker { + + private static final Logger logger = LoggerFactory.getLogger(MetricsTransWorker.class); + + private final MetricsPersistentWorker minutePersistenceWorker; + private final MetricsPersistentWorker hourPersistenceWorker; + private final MetricsPersistentWorker dayPersistenceWorker; + private final MetricsPersistentWorker monthPersistenceWorker; + + private CounterMetrics aggregationMinCounter; + private CounterMetrics aggregationHourCounter; + private CounterMetrics aggregationDayCounter; + private CounterMetrics aggregationMonthCounter; + + public MetricsTransWorker(ModuleDefineHolder moduleDefineHolder, String modelName, + MetricsPersistentWorker minutePersistenceWorker, + MetricsPersistentWorker hourPersistenceWorker, + MetricsPersistentWorker dayPersistenceWorker, + MetricsPersistentWorker monthPersistenceWorker) { + super(moduleDefineHolder); + this.minutePersistenceWorker = minutePersistenceWorker; + this.hourPersistenceWorker = hourPersistenceWorker; + this.dayPersistenceWorker = dayPersistenceWorker; + this.monthPersistenceWorker = monthPersistenceWorker; + + MetricsCreator metricsCreator = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); + aggregationMinCounter = metricsCreator.createCounter("metrics_aggregation", "The number of rows in aggregation", + new MetricsTag.Keys("metricName", "level", "dimensionality"), new MetricsTag.Values(modelName, "2", "min")); + aggregationHourCounter = metricsCreator.createCounter("metrics_aggregation", "The number of rows in aggregation", + new MetricsTag.Keys("metricName", "level", "dimensionality"), new MetricsTag.Values(modelName, "2", "hour")); + aggregationDayCounter = metricsCreator.createCounter("metrics_aggregation", "The number of rows in aggregation", + new MetricsTag.Keys("metricName", "level", "dimensionality"), new MetricsTag.Values(modelName, "2", "day")); + aggregationMonthCounter = metricsCreator.createCounter("metrics_aggregation", "The number of rows in aggregation", + new MetricsTag.Keys("metricName", "level", "dimensionality"), new MetricsTag.Values(modelName, "2", "month")); + } + + @Override public void in(Metrics metrics) { + if (Objects.nonNull(hourPersistenceWorker)) { + aggregationMonthCounter.inc(); + hourPersistenceWorker.in(metrics.toHour()); + } + if (Objects.nonNull(dayPersistenceWorker)) { + aggregationDayCounter.inc(); + dayPersistenceWorker.in(metrics.toDay()); + } + if (Objects.nonNull(monthPersistenceWorker)) { + aggregationHourCounter.inc(); + monthPersistenceWorker.in(metrics.toMonth()); + } + + /* + * Minute persistent must be at the end of all time dimensionalities + * Because #toHour, #toDay, #toMonth include clone inside, which could avoid concurrency situation. + */ + if (Objects.nonNull(minutePersistenceWorker)) { + aggregationMinCounter.inc(); + minutePersistenceWorker.in(metrics); + } + } +} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/exporter/MetricValuesExportService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/exporter/MetricValuesExportService.java index d8f2886b1190..8e66f881941a 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/exporter/MetricValuesExportService.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/exporter/MetricValuesExportService.java @@ -18,14 +18,14 @@ package org.apache.skywalking.oap.server.core.exporter; -import org.apache.skywalking.oap.server.core.analysis.indicator.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; import org.apache.skywalking.oap.server.library.module.Service; /** - * Export the metric value from indicators through this service, if provider exists. + * Export the metrics value from metrics through this service, if provider exists. * * @author wusheng */ public interface MetricValuesExportService extends Service { - void export(IndicatorMetaInfo meta, Indicator indicator); + void export(MetricsMetaInfo meta, Metrics metrics); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricQueryService.java index 0d62c4e5e28d..2f7552e87567 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricQueryService.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricQueryService.java @@ -23,12 +23,12 @@ import java.util.*; import org.apache.skywalking.apm.util.StringUtil; import org.apache.skywalking.oap.server.core.Const; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.query.entity.*; import org.apache.skywalking.oap.server.core.query.sql.*; import org.apache.skywalking.oap.server.core.storage.StorageModule; import org.apache.skywalking.oap.server.core.storage.annotation.ValueColumnIds; -import org.apache.skywalking.oap.server.core.storage.query.IMetricQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.IMetricsQueryDAO; import org.apache.skywalking.oap.server.library.module.*; import org.apache.skywalking.oap.server.library.module.Service; import org.apache.skywalking.oap.server.library.util.CollectionUtils; @@ -42,15 +42,15 @@ public class MetricQueryService implements Service { private static final Logger logger = LoggerFactory.getLogger(MetricQueryService.class); private final ModuleManager moduleManager; - private IMetricQueryDAO metricQueryDAO; + private IMetricsQueryDAO metricQueryDAO; public MetricQueryService(ModuleManager moduleManager) { this.moduleManager = moduleManager; } - private IMetricQueryDAO getMetricQueryDAO() { + private IMetricsQueryDAO getMetricQueryDAO() { if (metricQueryDAO == null) { - metricQueryDAO = moduleManager.find(StorageModule.NAME).provider().getService(IMetricQueryDAO.class); + metricQueryDAO = moduleManager.find(StorageModule.NAME).provider().getService(IMetricsQueryDAO.class); } return metricQueryDAO; } @@ -63,7 +63,7 @@ public IntValues getValues(final String indName, final List ids, final S Where where = new Where(); KeyValues intKeyValues = new KeyValues(); - intKeyValues.setKey(Indicator.ENTITY_ID); + intKeyValues.setKey(Metrics.ENTITY_ID); where.getKeyValues().add(intKeyValues); ids.forEach(intKeyValues.getValues()::add); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterPersistentWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterPersistentWorker.java index ed2b9eae8936..5cd5079071bf 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterPersistentWorker.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterPersistentWorker.java @@ -52,7 +52,7 @@ public class RegisterPersistentWorker extends AbstractWorker { this.registerDAO = registerDAO; this.registerLockDAO = moduleDefineHolder.find(StorageModule.NAME).provider().getService(IRegisterLockDAO.class); this.scopeId = scopeId; - this.dataCarrier = new DataCarrier<>("IndicatorPersistentWorker." + modelName, 1, 1000); + this.dataCarrier = new DataCarrier<>("MetricsPersistentWorker." + modelName, 1, 1000); String name = "REGISTER_L2"; int size = BulkConsumePool.Creator.recommendMaxSize() / 8; @@ -134,12 +134,12 @@ private PersistentConsumer(RegisterPersistentWorker persistent) { int i = 0; while (sourceIterator.hasNext()) { - RegisterSource indicator = sourceIterator.next(); + RegisterSource registerSource = sourceIterator.next(); i++; if (i == data.size()) { - indicator.getEndOfBatchContext().setEndOfBatch(true); + registerSource.getEndOfBatchContext().setEndOfBatch(true); } - persistent.onWork(indicator); + persistent.onWork(registerSource); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterRemoteWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterRemoteWorker.java index 4d4cc0f30188..513a3767ecfb 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterRemoteWorker.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterRemoteWorker.java @@ -42,9 +42,9 @@ public class RegisterRemoteWorker extends AbstractWorker { this.nextWorker = nextWorker; } - @Override public final void in(RegisterSource indicator) { + @Override public final void in(RegisterSource registerSource) { try { - remoteSender.send(nextWorker.getWorkerId(), indicator, Selector.ForeverFirst); + remoteSender.send(nextWorker.getWorkerId(), registerSource, Selector.ForeverFirst); } catch (Throwable e) { logger.error(e.getMessage(), e); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/RemoteServiceHandler.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/RemoteServiceHandler.java index dffa5f850836..7f857996a5f5 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/RemoteServiceHandler.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/RemoteServiceHandler.java @@ -45,22 +45,22 @@ public class RemoteServiceHandler extends RemoteServiceGrpc.RemoteServiceImplBas private final ModuleDefineHolder moduleDefineHolder; private StreamDataClassGetter streamDataClassGetter; private IWorkerInstanceGetter workerInstanceGetter; - private CounterMetric remoteInCounter; - private CounterMetric remoteInErrorCounter; - private HistogramMetric remoteInHistogram; + private CounterMetrics remoteInCounter; + private CounterMetrics remoteInErrorCounter; + private HistogramMetrics remoteInHistogram; public RemoteServiceHandler(ModuleDefineHolder moduleDefineHolder) { this.moduleDefineHolder = moduleDefineHolder; - remoteInCounter = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricCreator.class) + remoteInCounter = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class) .createCounter("remote_in_count", "The number(server side) of inside remote inside aggregate rpc.", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - remoteInErrorCounter = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricCreator.class) + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + remoteInErrorCounter = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class) .createCounter("remote_in_error_count", "The error number(server side) of inside remote inside aggregate rpc.", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - remoteInHistogram = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricCreator.class) + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + remoteInHistogram = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class) .createHistogramMetric("remote_in_latency", "The latency(server side) of inside remote inside aggregate rpc.", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); } @Override public StreamObserver call(StreamObserver responseObserver) { @@ -83,7 +83,7 @@ public RemoteServiceHandler(ModuleDefineHolder moduleDefineHolder) { return new StreamObserver() { @Override public void onNext(RemoteMessage message) { remoteInCounter.inc(); - HistogramMetric.Timer timer = remoteInHistogram.createTimer(); + HistogramMetrics.Timer timer = remoteInHistogram.createTimer(); try { int streamDataId = message.getStreamDataId(); int nextWorkerId = message.getNextWorkerId(); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClient.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClient.java index 6b3cf4f1fcac..d273fa1bce6b 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClient.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClient.java @@ -52,8 +52,8 @@ public class GRPCRemoteClient implements RemoteClient { private GRPCClient client; private DataCarrier carrier; private boolean isConnect; - private CounterMetric remoteOutCounter; - private CounterMetric remoteOutErrorCounter; + private CounterMetrics remoteOutCounter; + private CounterMetrics remoteOutErrorCounter; public GRPCRemoteClient(ModuleDefineHolder moduleDefineHolder, StreamDataClassGetter streamDataClassGetter, Address address, int channelSize, @@ -63,12 +63,12 @@ public GRPCRemoteClient(ModuleDefineHolder moduleDefineHolder, StreamDataClassGe this.channelSize = channelSize; this.bufferSize = bufferSize; - remoteOutCounter = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricCreator.class) + remoteOutCounter = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class) .createCounter("remote_out_count", "The number(client side) of inside remote inside aggregate rpc.", - new MetricTag.Keys("dest", "self"), new MetricTag.Values(address.toString(), "N")); - remoteOutErrorCounter = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricCreator.class) + new MetricsTag.Keys("dest", "self"), new MetricsTag.Values(address.toString(), "N")); + remoteOutErrorCounter = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class) .createCounter("remote_out_error_count", "The error number(client side) of inside remote inside aggregate rpc.", - new MetricTag.Keys("dest", "self"), new MetricTag.Values(address.toString(), "N")); + new MetricsTag.Keys("dest", "self"), new MetricsTag.Values(address.toString(), "N")); } @Override public void connect() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/RemoteClientManager.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/RemoteClientManager.java index 07f7ec562a6b..8de702905f18 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/RemoteClientManager.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/RemoteClientManager.java @@ -44,7 +44,7 @@ public class RemoteClientManager implements Service { private final List clientsA; private final List clientsB; private volatile List usingClients; - private GaugeMetric gauge; + private GaugeMetrics gauge; public RemoteClientManager(ModuleDefineHolder moduleDefineHolder) { this.moduleDefineHolder = moduleDefineHolder; @@ -63,9 +63,9 @@ public void start() { */ void refresh() { if (gauge == null) { - gauge = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricCreator.class) + gauge = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class) .createGauge("cluster_size", "Cluster size of current oap node", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); } try { if (Objects.isNull(clusterNodesQuery)) { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/SelfRemoteClient.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/SelfRemoteClient.java index abb7aaed5651..67827a99dd51 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/SelfRemoteClient.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/remote/client/SelfRemoteClient.java @@ -31,15 +31,15 @@ public class SelfRemoteClient implements RemoteClient { private final Address address; - private CounterMetric remoteOutCounter; + private CounterMetrics remoteOutCounter; private final IWorkerInstanceGetter workerInstanceGetter; public SelfRemoteClient(ModuleDefineHolder moduleDefineHolder, Address address) { this.address = address; workerInstanceGetter = moduleDefineHolder.find(CoreModule.NAME).provider().getService(IWorkerInstanceGetter.class); - remoteOutCounter = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricCreator.class) + remoteOutCounter = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class) .createCounter("remote_out_count", "The number(client side) of inside remote inside aggregate rpc.", - new MetricTag.Keys("dest", "self"), new MetricTag.Values(address.toString(), "Y")); + new MetricsTag.Keys("dest", "self"), new MetricsTag.Values(address.toString(), "Y")); } @Override public Address getAddress() { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java index 4508868a18e6..e5d5cb1f2e5e 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java @@ -32,7 +32,7 @@ public class DefaultScopeDefine { private static final Map ID_2_NAME = new HashMap<>(); /** - * All metric IDs in [0, 10,000) are reserved in Apache SkyWalking. + * All metrics IDs in [0, 10,000) are reserved in Apache SkyWalking. * * If you want to extend the scope, recommend to start with 10,000. */ @@ -64,7 +64,7 @@ public class DefaultScopeDefine { public static final int HTTP_ACCESS_LOG = 25; /** - * Catalog of scope, the indicator processor could use this to group all generated indicators by oal tool. + * Catalog of scope, the metrics processor could use this to group all generated metrics by oal tool. */ public static final String SERVICE_CATALOG_NAME = "SERVICE"; public static final String SERVICE_INSTANCE_CATALOG_NAME = "SERVICE_INSTANCE"; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EnvoyInstanceMetric.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EnvoyInstanceMetric.java index 3877dbe6cc64..d6e2c6c4a5eb 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EnvoyInstanceMetric.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EnvoyInstanceMetric.java @@ -24,9 +24,9 @@ import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_INSTANCE_CATALOG_NAME; /** - * The envoy metrics. This group of metrics are in Prometheus metric format family. + * The envoy metrics. This group of metrics are in Prometheus metrics format family. * - * This metric source supports Counter and Gauge types. + * This metrics source supports Counter and Gauge types. * * @author wusheng */ diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/IIndicatorDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/IMetricsDAO.java similarity index 70% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/IIndicatorDAO.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/IMetricsDAO.java index 146ac0af0184..d256175b0044 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/IIndicatorDAO.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/IMetricsDAO.java @@ -19,16 +19,16 @@ package org.apache.skywalking.oap.server.core.storage; import java.io.IOException; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; /** * @author peng-yongsheng */ -public interface IIndicatorDAO extends DAO { +public interface IMetricsDAO extends DAO { - Indicator get(String modelName, Indicator indicator) throws IOException; + Metrics get(String modelName, Metrics metrics) throws IOException; - INSERT prepareBatchInsert(String modelName, Indicator indicator) throws IOException; + INSERT prepareBatchInsert(String modelName, Metrics metrics) throws IOException; - UPDATE prepareBatchUpdate(String modelName, Indicator indicator) throws IOException; + UPDATE prepareBatchUpdate(String modelName, Metrics metrics) throws IOException; } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/PersistenceTimer.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/PersistenceTimer.java index 9bdbfd19d664..215381a8cc25 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/PersistenceTimer.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/PersistenceTimer.java @@ -37,9 +37,9 @@ public enum PersistenceTimer { private Boolean isStarted = false; private final Boolean debug; - private CounterMetric errorCounter; - private HistogramMetric prepareLatency; - private HistogramMetric executeLatency; + private CounterMetrics errorCounter; + private HistogramMetrics prepareLatency; + private HistogramMetrics executeLatency; PersistenceTimer() { this.debug = System.getProperty("debug") != null; @@ -52,13 +52,13 @@ public void start(ModuleManager moduleManager) { final long timeInterval = 3; IBatchDAO batchDAO = moduleManager.find(StorageModule.NAME).provider().getService(IBatchDAO.class); - MetricCreator metricCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); - errorCounter = metricCreator.createCounter("persistence_timer_bulk_error_count", "Error execution of the prepare stage in persistence timer", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - prepareLatency = metricCreator.createHistogramMetric("persistence_timer_bulk_prepare_latency", "Latency of the prepare stage in persistence timer", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - executeLatency = metricCreator.createHistogramMetric("persistence_timer_bulk_execute_latency", "Latency of the execute stage in persistence timer", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + MetricsCreator metricsCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); + errorCounter = metricsCreator.createCounter("persistence_timer_bulk_error_count", "Error execution of the prepare stage in persistence timer", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + prepareLatency = metricsCreator.createHistogramMetric("persistence_timer_bulk_prepare_latency", "Latency of the prepare stage in persistence timer", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + executeLatency = metricsCreator.createHistogramMetric("persistence_timer_bulk_execute_latency", "Latency of the execute stage in persistence timer", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); if (!isStarted) { Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate( @@ -77,12 +77,12 @@ private void extractDataAndSave(IBatchDAO batchDAO) { long startTime = System.currentTimeMillis(); try { - HistogramMetric.Timer timer = prepareLatency.createTimer(); + HistogramMetrics.Timer timer = prepareLatency.createTimer(); List batchAllCollection = new LinkedList(); try { List persistenceWorkers = new ArrayList<>(); - persistenceWorkers.addAll(IndicatorProcess.INSTANCE.getPersistentWorkers()); + persistenceWorkers.addAll(MetricsProcess.INSTANCE.getPersistentWorkers()); persistenceWorkers.addAll(RecordProcess.INSTANCE.getPersistentWorkers()); persistenceWorkers.addAll(TopNProcess.INSTANCE.getPersistentWorkers()); @@ -108,7 +108,7 @@ private void extractDataAndSave(IBatchDAO batchDAO) { timer.finish(); } - HistogramMetric.Timer executeLatencyTimer = executeLatency.createTimer(); + HistogramMetrics.Timer executeLatencyTimer = executeLatency.createTimer(); try { batchDAO.batchPersistence(batchAllCollection); } finally { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageDAO.java index ddb348e389d9..4d3f26d60dc2 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageDAO.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageDAO.java @@ -18,7 +18,7 @@ package org.apache.skywalking.oap.server.core.storage; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.analysis.record.Record; import org.apache.skywalking.oap.server.core.register.RegisterSource; import org.apache.skywalking.oap.server.library.module.Service; @@ -28,7 +28,7 @@ */ public interface StorageDAO extends Service { - IIndicatorDAO newIndicatorDao(StorageBuilder storageBuilder); + IMetricsDAO newMetricsDao(StorageBuilder storageBuilder); IRegisterDAO newRegisterDao(StorageBuilder storageBuilder); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java index eef5c124a21f..9e42d9b10148 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java @@ -39,7 +39,7 @@ public StorageModule() { IHistoryDeleteDAO.class, IServiceInventoryCacheDAO.class, IServiceInstanceInventoryCacheDAO.class, IEndpointInventoryCacheDAO.class, INetworkAddressInventoryCacheDAO.class, - ITopologyQueryDAO.class, IMetricQueryDAO.class, ITraceQueryDAO.class, IMetadataQueryDAO.class, IAggregationQueryDAO.class, IAlarmQueryDAO.class, + ITopologyQueryDAO.class, IMetricsQueryDAO.class, ITraceQueryDAO.class, IMetadataQueryDAO.class, IAggregationQueryDAO.class, IAlarmQueryDAO.class, ITopNRecordsQueryDAO.class, ILogQueryDAO.class}; } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/StorageAnnotationListener.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/StorageAnnotationListener.java index 5fd5533d358c..2c7b5493f399 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/StorageAnnotationListener.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/StorageAnnotationListener.java @@ -22,7 +22,7 @@ import java.lang.reflect.Field; import java.util.*; import lombok.Getter; -import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorAnnotationUtils; +import org.apache.skywalking.oap.server.core.analysis.metrics.annotation.MetricsAnnotationUtils; import org.apache.skywalking.oap.server.core.annotation.AnnotationListener; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; import org.apache.skywalking.oap.server.core.storage.model.*; @@ -54,10 +54,10 @@ public StorageAnnotationListener() { // Check this scope id is valid. DefaultScopeDefine.nameOf(sourceScopeId); List modelColumns = new LinkedList<>(); - boolean isIndicator = IndicatorAnnotationUtils.isIndicator(aClass); + boolean isMetrics = MetricsAnnotationUtils.isMetrics(aClass); retrieval(aClass, modelName, modelColumns); - models.add(new Model(modelName, modelColumns, isIndicator, deleteHistory, sourceScopeId)); + models.add(new Model(modelName, modelColumns, isMetrics, deleteHistory, sourceScopeId)); } private void retrieval(Class clazz, String modelName, List modelColumns) { diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/Model.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/Model.java index f847db73e241..43ce38dbd0a4 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/Model.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/Model.java @@ -27,21 +27,21 @@ @Getter public class Model { private final String name; - private final boolean isIndicator; + private final boolean isMetrics; private final boolean deleteHistory; private final List columns; private final int sourceScopeId; - public Model(String name, List columns, boolean isIndicator, boolean deleteHistory, + public Model(String name, List columns, boolean isMetrics, boolean deleteHistory, int sourceScopeId) { this.name = name; this.columns = columns; - this.isIndicator = isIndicator; + this.isMetrics = isMetrics; this.deleteHistory = deleteHistory; this.sourceScopeId = sourceScopeId; } public Model copy(String name) { - return new Model(name, columns, isIndicator, deleteHistory, sourceScopeId); + return new Model(name, columns, isMetrics, deleteHistory, sourceScopeId); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelInstaller.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelInstaller.java index b37c9cab32f0..e50e66ef2ad9 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelInstaller.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelInstaller.java @@ -46,7 +46,7 @@ public final void install(Client client) throws StorageException { List models = modelGetter.getModels(); List allModels = new ArrayList<>(); models.forEach(model -> { - if (model.isIndicator()) { + if (model.isMetrics()) { if (downsamplingConfigService.shouldToHour()) { allModels.add(model.copy(model.getName() + Const.ID_SPLIT + Downsampling.Hour.getName())); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetricQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetricsQueryDAO.java similarity index 96% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetricQueryDAO.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetricsQueryDAO.java index 1ea0ca19e45e..ca8640d3b5b1 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetricQueryDAO.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetricsQueryDAO.java @@ -27,7 +27,7 @@ /** * @author peng-yongsheng */ -public interface IMetricQueryDAO extends DAO { +public interface IMetricsQueryDAO extends DAO { IntValues getValues(String indName, Step step, long startTB, long endTB, Where where, String valueCName, Function function) throws IOException; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/ttl/DataTTLKeeperTimer.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/ttl/DataTTLKeeperTimer.java index 575953a77722..ca0eca67e894 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/ttl/DataTTLKeeperTimer.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/ttl/DataTTLKeeperTimer.java @@ -27,7 +27,7 @@ import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.DataTTL; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.analysis.record.Record; import org.apache.skywalking.oap.server.core.cluster.ClusterModule; import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery; @@ -83,17 +83,17 @@ private void delete() { DownsamplingConfigService downsamplingConfigService = moduleManager.find(CoreModule.NAME).provider().getService(DownsamplingConfigService.class); List models = modelGetter.getModels(); models.forEach(model -> { - if (model.isIndicator()) { - execute(model, model.getName(), timeBuckets.minuteTimeBucketBefore, Indicator.TIME_BUCKET); + if (model.isMetrics()) { + execute(model, model.getName(), timeBuckets.minuteTimeBucketBefore, Metrics.TIME_BUCKET); if (downsamplingConfigService.shouldToHour()) { - execute(model, model.getName() + Const.ID_SPLIT + Downsampling.Hour.getName(), timeBuckets.hourTimeBucketBefore, Indicator.TIME_BUCKET); + execute(model, model.getName() + Const.ID_SPLIT + Downsampling.Hour.getName(), timeBuckets.hourTimeBucketBefore, Metrics.TIME_BUCKET); } if (downsamplingConfigService.shouldToDay()) { - execute(model, model.getName() + Const.ID_SPLIT + Downsampling.Day.getName(), timeBuckets.dayTimeBucketBefore, Indicator.TIME_BUCKET); + execute(model, model.getName() + Const.ID_SPLIT + Downsampling.Day.getName(), timeBuckets.dayTimeBucketBefore, Metrics.TIME_BUCKET); } if (downsamplingConfigService.shouldToMonth()) { - execute(model, model.getName() + Const.ID_SPLIT + Downsampling.Month.getName(), timeBuckets.monthTimeBucketBefore, Indicator.TIME_BUCKET); + execute(model, model.getName() + Const.ID_SPLIT + Downsampling.Month.getName(), timeBuckets.monthTimeBucketBefore, Metrics.TIME_BUCKET); } } else { execute(model, model.getName(), timeBuckets.recordDataTTL, Record.TIME_BUCKET); diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicatorTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicatorTest.java deleted file mode 100644 index 7e2c5d39998d..000000000000 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicatorTest.java +++ /dev/null @@ -1,130 +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.skywalking.oap.server.core.analysis.indicator; - -import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author wusheng - */ -public class PxxIndicatorTest { - private int precision = 10;//ms - - @Test - public void p99Test() { - PxxIndicatorMocker indicatorMocker = new PxxIndicatorMocker(99); - - indicatorMocker.combine(110, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(50, precision); - indicatorMocker.combine(50, precision); - indicatorMocker.combine(50, precision); - indicatorMocker.combine(61, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(100, precision); - - indicatorMocker.calculate(); - - Assert.assertEquals(110, indicatorMocker.getValue()); - } - - @Test - public void p75Test() { - PxxIndicatorMocker indicatorMocker = new PxxIndicatorMocker(75); - - indicatorMocker.combine(110, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(50, precision); - indicatorMocker.combine(50, precision); - indicatorMocker.combine(50, precision); - indicatorMocker.combine(61, precision); - indicatorMocker.combine(61, precision); - indicatorMocker.combine(71, precision); - indicatorMocker.combine(100, precision); - - indicatorMocker.calculate(); - - // precision = 10, 71 ~= 70 - Assert.assertEquals(100, indicatorMocker.getValue()); - } - - @Test - public void p50Test() { - PxxIndicatorMocker indicatorMocker = new PxxIndicatorMocker(50); - - indicatorMocker.combine(110, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(100, precision); - indicatorMocker.combine(50, precision); - indicatorMocker.combine(50, precision); - indicatorMocker.combine(50, precision); - indicatorMocker.combine(61, precision); - indicatorMocker.combine(61, precision); - indicatorMocker.combine(71, precision); - indicatorMocker.combine(100, precision); - - indicatorMocker.calculate(); - - // precision = 10, 71 ~= 70 - Assert.assertEquals(70, indicatorMocker.getValue()); - } - - public class PxxIndicatorMocker extends PxxIndicator { - - public PxxIndicatorMocker(int percentileRank) { - super(percentileRank); - } - - @Override public String id() { - return null; - } - - @Override public Indicator toHour() { - return null; - } - - @Override public Indicator toDay() { - return null; - } - - @Override public Indicator toMonth() { - return null; - } - - @Override public void deserialize(RemoteData remoteData) { - - } - - @Override public RemoteData.Builder serialize() { - return null; - } - - @Override public int remoteHashCode() { - return 0; - } - } -} diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/ThermodynamicIndicatorTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/ThermodynamicIndicatorTest.java deleted file mode 100644 index 4433692ff70f..000000000000 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/ThermodynamicIndicatorTest.java +++ /dev/null @@ -1,123 +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.skywalking.oap.server.core.analysis.indicator; - -import java.util.Map; -import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; -import org.junit.Assert; -import org.junit.Test; -import org.powermock.reflect.Whitebox; - -/** - * @author wusheng - */ -public class ThermodynamicIndicatorTest { - private int step = 10;//ms - private int maxNumOfSteps = 10;//count - - @Test - public void testEntrance() { - ThermodynamicIndicatorTest.ThermodynamicIndicatorMocker indicatorMocker = new ThermodynamicIndicatorTest.ThermodynamicIndicatorMocker(); - - indicatorMocker.combine(2000, step, maxNumOfSteps); - indicatorMocker.combine(110, step, maxNumOfSteps); - indicatorMocker.combine(100, step, maxNumOfSteps); - indicatorMocker.combine(100, step, maxNumOfSteps); - indicatorMocker.combine(100, step, maxNumOfSteps); - indicatorMocker.combine(50, step, maxNumOfSteps); - indicatorMocker.combine(50, step, maxNumOfSteps); - indicatorMocker.combine(28, step, maxNumOfSteps); - indicatorMocker.combine(50, step, maxNumOfSteps); - indicatorMocker.combine(61, step, maxNumOfSteps); - indicatorMocker.combine(100, step, maxNumOfSteps); - indicatorMocker.combine(100, step, maxNumOfSteps); - indicatorMocker.combine(100, step, maxNumOfSteps); - - Map index = Whitebox.getInternalState(indicatorMocker, "detailIndex"); - Assert.assertEquals(4, index.size()); - - Assert.assertEquals(1, index.get(2).getValue()); - Assert.assertEquals(3, index.get(5).getValue()); - Assert.assertEquals(1, index.get(6).getValue()); - Assert.assertEquals(8, index.get(10).getValue()); - } - - @Test - public void testMerge() { - ThermodynamicIndicatorTest.ThermodynamicIndicatorMocker indicatorMocker = new ThermodynamicIndicatorTest.ThermodynamicIndicatorMocker(); - - indicatorMocker.combine(2000, step, maxNumOfSteps); - indicatorMocker.combine(110, step, maxNumOfSteps); - indicatorMocker.combine(100, step, maxNumOfSteps); - indicatorMocker.combine(100, step, maxNumOfSteps); - indicatorMocker.combine(100, step, maxNumOfSteps); - indicatorMocker.combine(50, step, maxNumOfSteps); - indicatorMocker.combine(50, step, maxNumOfSteps); - - ThermodynamicIndicatorTest.ThermodynamicIndicatorMocker indicatorMocker2 = new ThermodynamicIndicatorTest.ThermodynamicIndicatorMocker(); - - indicatorMocker2.combine(28, step, maxNumOfSteps); - indicatorMocker2.combine(50, step, maxNumOfSteps); - indicatorMocker2.combine(61, step, maxNumOfSteps); - indicatorMocker2.combine(100, step, maxNumOfSteps); - indicatorMocker2.combine(100, step, maxNumOfSteps); - indicatorMocker2.combine(100, step, maxNumOfSteps); - - indicatorMocker.combine(indicatorMocker2); - - Map index = Whitebox.getInternalState(indicatorMocker, "detailIndex"); - Assert.assertEquals(4, index.size()); - - Assert.assertEquals(1, index.get(2).getValue()); - Assert.assertEquals(3, index.get(5).getValue()); - Assert.assertEquals(1, index.get(6).getValue()); - Assert.assertEquals(8, index.get(10).getValue()); - } - - public class ThermodynamicIndicatorMocker extends ThermodynamicIndicator { - - @Override public String id() { - return null; - } - - @Override public Indicator toHour() { - return null; - } - - @Override public Indicator toDay() { - return null; - } - - @Override public Indicator toMonth() { - return null; - } - - @Override public void deserialize(RemoteData remoteData) { - - } - - @Override public RemoteData.Builder serialize() { - return null; - } - - @Override public int remoteHashCode() { - return 0; - } - } -} diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/CountIndicatorTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/CountMetricsTest.java similarity index 80% rename from oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/CountIndicatorTest.java rename to oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/CountMetricsTest.java index 2c43342cc70d..b9f33f2e19c6 100644 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/CountIndicatorTest.java +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/CountMetricsTest.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.junit.Assert; @@ -25,10 +25,10 @@ /** * @author wusheng */ -public class CountIndicatorTest { +public class CountMetricsTest { @Test public void testEntranceCombine() { - CountIndicatorImpl impl = new CountIndicatorImpl(); + CountMetricsImpl impl = new CountMetricsImpl(); impl.combine(5); impl.combine(6); impl.combine(7); @@ -40,12 +40,12 @@ public void testEntranceCombine() { @Test public void testSelfCombine() { - CountIndicatorImpl impl = new CountIndicatorImpl(); + CountMetricsImpl impl = new CountMetricsImpl(); impl.combine(5); impl.combine(6); impl.combine(7); - CountIndicatorImpl impl2 = new CountIndicatorImpl(); + CountMetricsImpl impl2 = new CountMetricsImpl(); impl2.combine(5); impl2.combine(6); impl2.combine(7); @@ -57,20 +57,20 @@ public void testSelfCombine() { Assert.assertEquals(36, impl.getValue()); } - public class CountIndicatorImpl extends CountIndicator { + public class CountMetricsImpl extends CountMetrics { @Override public String id() { return null; } - @Override public Indicator toHour() { + @Override public Metrics toHour() { return null; } - @Override public Indicator toDay() { + @Override public Metrics toDay() { return null; } - @Override public Indicator toMonth() { + @Override public Metrics toMonth() { return null; } diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongAvgIndicatorTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/LongAvgMetricsTest.java similarity index 79% rename from oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongAvgIndicatorTest.java rename to oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/LongAvgMetricsTest.java index e236fdf5079d..91fdc0d57bc5 100644 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongAvgIndicatorTest.java +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/LongAvgMetricsTest.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.junit.Assert; @@ -25,10 +25,10 @@ /** * @author wusheng */ -public class LongAvgIndicatorTest { +public class LongAvgMetricsTest { @Test public void testEntranceCombine() { - LongAvgIndicatorImpl impl = new LongAvgIndicatorImpl(); + LongAvgMetricsImpl impl = new LongAvgMetricsImpl(); impl.combine(12, 1); impl.combine(24, 2); impl.combine(36, 3); @@ -38,11 +38,11 @@ public void testEntranceCombine() { @Test public void testSelfCombine() { - LongAvgIndicatorImpl impl = new LongAvgIndicatorImpl(); + LongAvgMetricsImpl impl = new LongAvgMetricsImpl(); impl.combine(12, 1); impl.combine(24, 2); - LongAvgIndicatorImpl impl2 = new LongAvgIndicatorImpl(); + LongAvgMetricsImpl impl2 = new LongAvgMetricsImpl(); impl2.combine(24, 1); impl2.combine(48, 2); @@ -52,21 +52,21 @@ public void testSelfCombine() { Assert.assertEquals(18, impl.getValue()); } - public class LongAvgIndicatorImpl extends LongAvgIndicator { + public class LongAvgMetricsImpl extends LongAvgMetrics { @Override public String id() { return null; } - @Override public Indicator toHour() { + @Override public Metrics toHour() { return null; } - @Override public Indicator toDay() { + @Override public Metrics toDay() { return null; } - @Override public Indicator toMonth() { + @Override public Metrics toMonth() { return null; } diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/MaxLongIndicatorTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/MaxLongMetricsTest.java similarity index 78% rename from oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/MaxLongIndicatorTest.java rename to oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/MaxLongMetricsTest.java index b7d9355ed5eb..aa7d467d99c3 100644 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/MaxLongIndicatorTest.java +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/MaxLongMetricsTest.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.junit.Assert; @@ -25,11 +25,11 @@ /** * @author liuhaoyang **/ -public class MaxLongIndicatorTest { +public class MaxLongMetricsTest { @Test public void testEntranceCombine() { - MaxLongIndicatorImpl impl = new MaxLongIndicatorImpl(); + MaxLongMetricsImpl impl = new MaxLongMetricsImpl(); impl.combine(10); impl.combine(5); impl.combine(20); @@ -39,11 +39,11 @@ public void testEntranceCombine() { @Test public void testSelfCombine() { - MaxLongIndicatorImpl impl = new MaxLongIndicatorImpl(); + MaxLongMetricsImpl impl = new MaxLongMetricsImpl(); impl.combine(10); impl.combine(5); - MaxLongIndicatorImpl impl2 = new MaxLongIndicatorImpl(); + MaxLongMetricsImpl impl2 = new MaxLongMetricsImpl(); impl.combine(2); impl.combine(6); @@ -51,21 +51,21 @@ public void testSelfCombine() { Assert.assertEquals(10, impl.getValue()); } - public class MaxLongIndicatorImpl extends MaxLongIndicator { + public class MaxLongMetricsImpl extends MaxLongMetrics { @Override public String id() { return null; } - @Override public Indicator toHour() { + @Override public Metrics toHour() { return null; } - @Override public Indicator toDay() { + @Override public Metrics toDay() { return null; } - @Override public Indicator toMonth() { + @Override public Metrics toMonth() { return null; } diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/IndicatorTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/MetricsTest.java similarity index 83% rename from oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/IndicatorTest.java rename to oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/MetricsTest.java index 35fd52fc5c42..1986f01b4899 100644 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/IndicatorTest.java +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/MetricsTest.java @@ -16,7 +16,7 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.junit.Assert; @@ -25,23 +25,23 @@ /** * @author wusheng */ -public class IndicatorTest { +public class MetricsTest { @Test public void testTransferToTimeBucket() { - IndicatorMocker mocker = new IndicatorMocker(); + MetricsMocker mocker = new MetricsMocker(); mocker.setTimeBucket(201809120511L); Assert.assertEquals(2018091205L, mocker.toTimeBucketInHour()); Assert.assertEquals(20180912L, mocker.toTimeBucketInDay()); Assert.assertEquals(201809L, mocker.toTimeBucketInMonth()); - mocker = new IndicatorMocker(); + mocker = new MetricsMocker(); mocker.setTimeBucket(2018091205L); Assert.assertEquals(20180912L, mocker.toTimeBucketInDay()); Assert.assertEquals(201809L, mocker.toTimeBucketInMonth()); - mocker = new IndicatorMocker(); + mocker = new MetricsMocker(); mocker.setTimeBucket(20180912L); Assert.assertEquals(201809L, mocker.toTimeBucketInMonth()); @@ -49,7 +49,7 @@ public void testTransferToTimeBucket() { @Test public void testIllegalTransferToTimeBucket() { - IndicatorMocker mocker = new IndicatorMocker(); + MetricsMocker mocker = new MetricsMocker(); mocker.setTimeBucket(2018091205L); boolean status = true; @@ -60,7 +60,7 @@ public void testIllegalTransferToTimeBucket() { } Assert.assertFalse(status); - mocker = new IndicatorMocker(); + mocker = new MetricsMocker(); mocker.setTimeBucket(20180912L); status = true; @@ -80,13 +80,13 @@ public void testIllegalTransferToTimeBucket() { Assert.assertFalse(status); } - public class IndicatorMocker extends Indicator { + public class MetricsMocker extends Metrics { @Override public String id() { return null; } - @Override public void combine(Indicator indicator) { + @Override public void combine(Metrics metrics) { } @@ -94,15 +94,15 @@ public class IndicatorMocker extends Indicator { } - @Override public Indicator toHour() { + @Override public Metrics toHour() { return null; } - @Override public Indicator toDay() { + @Override public Metrics toDay() { return null; } - @Override public Indicator toMonth() { + @Override public Metrics toMonth() { return null; } diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PercentIndicatorTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentMetricsTest.java similarity index 79% rename from oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PercentIndicatorTest.java rename to oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentMetricsTest.java index 0a1c2c4d48d2..b5bb0f086a35 100644 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PercentIndicatorTest.java +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PercentMetricsTest.java @@ -16,9 +16,9 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator; +package org.apache.skywalking.oap.server.core.analysis.metrics; -import org.apache.skywalking.oap.server.core.analysis.indicator.expression.EqualMatch; +import org.apache.skywalking.oap.server.core.analysis.metrics.expression.EqualMatch; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.junit.Assert; import org.junit.Test; @@ -26,10 +26,10 @@ /** * @author wusheng */ -public class PercentIndicatorTest { +public class PercentMetricsTest { @Test public void testEntranceCombine() { - PercentIndicatorImpl impl = new PercentIndicatorImpl(); + PercentMetricsImpl impl = new PercentMetricsImpl(); impl.combine(new EqualMatch(), true, true); impl.combine(new EqualMatch(), true, false); impl.combine(new EqualMatch(), true, false); @@ -38,7 +38,7 @@ public void testEntranceCombine() { Assert.assertEquals(3333, impl.getValue()); - impl = new PercentIndicatorImpl(); + impl = new PercentMetricsImpl(); impl.combine(new EqualMatch(), true, true); impl.combine(new EqualMatch(), true, true); impl.combine(new EqualMatch(), true, false); @@ -50,12 +50,12 @@ public void testEntranceCombine() { @Test public void testSelfCombine() { - PercentIndicatorImpl impl = new PercentIndicatorImpl(); + PercentMetricsImpl impl = new PercentMetricsImpl(); impl.combine(new EqualMatch(), true, true); impl.combine(new EqualMatch(), true, false); impl.combine(new EqualMatch(), true, false); - PercentIndicatorImpl impl2 = new PercentIndicatorImpl(); + PercentMetricsImpl impl2 = new PercentMetricsImpl(); impl2.combine(new EqualMatch(), true, true); impl2.combine(new EqualMatch(), true, true); impl2.combine(new EqualMatch(), true, false); @@ -67,21 +67,21 @@ public void testSelfCombine() { Assert.assertEquals(5000, impl.getValue()); } - public class PercentIndicatorImpl extends PercentIndicator { + public class PercentMetricsImpl extends PercentMetrics { @Override public String id() { return null; } - @Override public Indicator toHour() { + @Override public Metrics toHour() { return null; } - @Override public Indicator toDay() { + @Override public Metrics toDay() { return null; } - @Override public Indicator toMonth() { + @Override public Metrics toMonth() { return null; } diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PxxMetricsTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PxxMetricsTest.java new file mode 100644 index 000000000000..8fb44bb0410f --- /dev/null +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/PxxMetricsTest.java @@ -0,0 +1,129 @@ +/* + * 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.*; + +/** + * @author wusheng + */ +public class PxxMetricsTest { + private int precision = 10;//ms + + @Test + public void p99Test() { + PxxMetricsMocker metricsMocker = new PxxMetricsMocker(99); + + metricsMocker.combine(110, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(50, precision); + metricsMocker.combine(50, precision); + metricsMocker.combine(50, precision); + metricsMocker.combine(61, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(100, precision); + + metricsMocker.calculate(); + + Assert.assertEquals(110, metricsMocker.getValue()); + } + + @Test + public void p75Test() { + PxxMetricsMocker metricsMocker = new PxxMetricsMocker(75); + + metricsMocker.combine(110, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(50, precision); + metricsMocker.combine(50, precision); + metricsMocker.combine(50, precision); + metricsMocker.combine(61, precision); + metricsMocker.combine(61, precision); + metricsMocker.combine(71, precision); + metricsMocker.combine(100, precision); + + metricsMocker.calculate(); + + // precision = 10, 71 ~= 70 + Assert.assertEquals(100, metricsMocker.getValue()); + } + + @Test + public void p50Test() { + PxxMetricsMocker metricsMocker = new PxxMetricsMocker(50); + + metricsMocker.combine(110, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(100, precision); + metricsMocker.combine(50, precision); + metricsMocker.combine(50, precision); + metricsMocker.combine(50, precision); + metricsMocker.combine(61, precision); + metricsMocker.combine(61, precision); + metricsMocker.combine(71, precision); + metricsMocker.combine(100, precision); + + metricsMocker.calculate(); + + // precision = 10, 71 ~= 70 + Assert.assertEquals(70, metricsMocker.getValue()); + } + + public class PxxMetricsMocker extends PxxMetrics { + + public PxxMetricsMocker(int percentileRank) { + super(percentileRank); + } + + @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 void deserialize(RemoteData remoteData) { + + } + + @Override public RemoteData.Builder serialize() { + return null; + } + + @Override public int remoteHashCode() { + return 0; + } + } +} diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/ThermodynamicMetricsTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/ThermodynamicMetricsTest.java new file mode 100644 index 000000000000..b7ca227364c5 --- /dev/null +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/metrics/ThermodynamicMetricsTest.java @@ -0,0 +1,123 @@ +/* + * 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 java.util.Map; +import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; +import org.junit.Assert; +import org.junit.Test; +import org.powermock.reflect.Whitebox; + +/** + * @author wusheng + */ +public class ThermodynamicMetricsTest { + private int step = 10;//ms + private int maxNumOfSteps = 10;//count + + @Test + public void testEntrance() { + ThermodynamicMetricsMocker metricsMocker = new ThermodynamicMetricsMocker(); + + metricsMocker.combine(2000, step, maxNumOfSteps); + metricsMocker.combine(110, step, maxNumOfSteps); + metricsMocker.combine(100, step, maxNumOfSteps); + metricsMocker.combine(100, step, maxNumOfSteps); + metricsMocker.combine(100, step, maxNumOfSteps); + metricsMocker.combine(50, step, maxNumOfSteps); + metricsMocker.combine(50, step, maxNumOfSteps); + metricsMocker.combine(28, step, maxNumOfSteps); + metricsMocker.combine(50, step, maxNumOfSteps); + metricsMocker.combine(61, step, maxNumOfSteps); + metricsMocker.combine(100, step, maxNumOfSteps); + metricsMocker.combine(100, step, maxNumOfSteps); + metricsMocker.combine(100, step, maxNumOfSteps); + + Map index = Whitebox.getInternalState(metricsMocker, "detailIndex"); + Assert.assertEquals(4, index.size()); + + Assert.assertEquals(1, index.get(2).getValue()); + Assert.assertEquals(3, index.get(5).getValue()); + Assert.assertEquals(1, index.get(6).getValue()); + Assert.assertEquals(8, index.get(10).getValue()); + } + + @Test + public void testMerge() { + ThermodynamicMetricsMocker metricsMocker = new ThermodynamicMetricsMocker(); + + metricsMocker.combine(2000, step, maxNumOfSteps); + metricsMocker.combine(110, step, maxNumOfSteps); + metricsMocker.combine(100, step, maxNumOfSteps); + metricsMocker.combine(100, step, maxNumOfSteps); + metricsMocker.combine(100, step, maxNumOfSteps); + metricsMocker.combine(50, step, maxNumOfSteps); + metricsMocker.combine(50, step, maxNumOfSteps); + + ThermodynamicMetricsMocker metricsMocker1 = new ThermodynamicMetricsMocker(); + + metricsMocker1.combine(28, step, maxNumOfSteps); + metricsMocker1.combine(50, step, maxNumOfSteps); + metricsMocker1.combine(61, step, maxNumOfSteps); + metricsMocker1.combine(100, step, maxNumOfSteps); + metricsMocker1.combine(100, step, maxNumOfSteps); + metricsMocker1.combine(100, step, maxNumOfSteps); + + metricsMocker.combine(metricsMocker1); + + Map index = Whitebox.getInternalState(metricsMocker, "detailIndex"); + Assert.assertEquals(4, index.size()); + + Assert.assertEquals(1, index.get(2).getValue()); + Assert.assertEquals(3, index.get(5).getValue()); + Assert.assertEquals(1, index.get(6).getValue()); + Assert.assertEquals(8, index.get(10).getValue()); + } + + public class ThermodynamicMetricsMocker extends ThermodynamicMetrics { + + @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 void deserialize(RemoteData remoteData) { + + } + + @Override public RemoteData.Builder serialize() { + return null; + } + + @Override public int remoteHashCode() { + return 0; + } + } +} diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/RemoteServiceHandlerTestCase.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/RemoteServiceHandlerTestCase.java index f28436903566..2d5774948e8d 100644 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/RemoteServiceHandlerTestCase.java +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/RemoteServiceHandlerTestCase.java @@ -59,8 +59,8 @@ public void callTest() throws DuplicateProviderException, ProviderNotFoundExcept moduleDefine.provider().registerServiceImplementation(StreamDataClassGetter.class, classGetter); String serverName = InProcessServerBuilder.generateName(); - MetricCreator metricCreator = mock(MetricCreator.class); - when(metricCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetric() { + MetricsCreator metricsCreator = mock(MetricsCreator.class); + when(metricsCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetrics() { @Override public void inc() { } @@ -69,8 +69,8 @@ public void callTest() throws DuplicateProviderException, ProviderNotFoundExcept } }); - when(metricCreator.createHistogramMetric(any(), any(), any(), any(), any())).thenReturn( - new HistogramMetric() { + when(metricsCreator.createHistogramMetric(any(), any(), any(), any(), any())).thenReturn( + new HistogramMetrics() { @Override public void observe(double value) { } @@ -78,7 +78,7 @@ public void callTest() throws DuplicateProviderException, ProviderNotFoundExcept ); ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting(); moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine); - telemetryModuleDefine.provider().registerServiceImplementation(MetricCreator.class, metricCreator); + telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator); gRPCCleanup.register(InProcessServerBuilder .forName(serverName).directExecutor().addService(new RemoteServiceHandler(moduleManager)).build().start()); diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClientRealClient.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClientRealClient.java index fd2a804660a5..79a3c8e52f9f 100644 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClientRealClient.java +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClientRealClient.java @@ -39,8 +39,8 @@ public class GRPCRemoteClientRealClient { public static void main(String[] args) throws InterruptedException { Address address = new Address("localhost", 10000, false); ModuleManagerTesting moduleManager = new ModuleManagerTesting(); - MetricCreator metricCreator = mock(MetricCreator.class); - when(metricCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetric() { + MetricsCreator metricsCreator = mock(MetricsCreator.class); + when(metricsCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetrics() { @Override public void inc() { } @@ -51,7 +51,7 @@ public static void main(String[] args) throws InterruptedException { }); ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting(); moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine); - telemetryModuleDefine.provider().registerServiceImplementation(MetricCreator.class, metricCreator); + telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator); GRPCRemoteClient remoteClient = spy(new GRPCRemoteClient(moduleManager, new TestClassGetter(), address, 1, 10)); remoteClient.connect(); diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClientTestCase.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClientTestCase.java index b28c64485772..86b25c3c774c 100644 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClientTestCase.java +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/GRPCRemoteClientTestCase.java @@ -62,8 +62,8 @@ public void before() { @Test public void testPush() throws InterruptedException { - MetricCreator metricCreator = mock(MetricCreator.class); - when(metricCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetric() { + MetricsCreator metricsCreator = mock(MetricsCreator.class); + when(metricsCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetrics() { @Override public void inc() { } @@ -74,7 +74,7 @@ public void testPush() throws InterruptedException { }); ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting(); moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine); - telemetryModuleDefine.provider().registerServiceImplementation(MetricCreator.class, metricCreator); + telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator); grpcServerRule.getServiceRegistry().addService(new RemoteServiceHandler(moduleManager)); diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/RemoteClientManagerTestCase.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/RemoteClientManagerTestCase.java index 4b6317b49954..f68c0308e671 100644 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/RemoteClientManagerTestCase.java +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/remote/client/RemoteClientManagerTestCase.java @@ -49,8 +49,8 @@ public void refresh() { StreamDataClassGetter streamDataClassGetter = mock(StreamDataClassGetter.class); coreModuleDefine.provider().registerServiceImplementation(StreamDataClassGetter.class, streamDataClassGetter); - MetricCreator metricCreator = mock(MetricCreator.class); - when(metricCreator.createGauge(any(), any(), any(), any())).thenReturn(new GaugeMetric() { + MetricsCreator metricsCreator = mock(MetricsCreator.class); + when(metricsCreator.createGauge(any(), any(), any(), any())).thenReturn(new GaugeMetrics() { @Override public void inc() { } @@ -73,7 +73,7 @@ public void refresh() { }); ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting(); moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine); - telemetryModuleDefine.provider().registerServiceImplementation(MetricCreator.class, metricCreator); + telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator); RemoteClientManager clientManager = new RemoteClientManager(moduleManager); diff --git a/oap-server/server-library/library-util/src/test/resources/application.yml b/oap-server/server-library/library-util/src/test/resources/application.yml index 96c0de81a76e..c2b1c0d08a08 100644 --- a/oap-server/server-library/library-util/src/test/resources/application.yml +++ b/oap-server/server-library/library-util/src/test/resources/application.yml @@ -37,7 +37,7 @@ core: - Hour - Day - Month - # Set a timeout on metric data. After the timeout has expired, the metric data will automatically be deleted. + # Set a timeout on metrics data. After the timeout has expired, the metrics data will automatically be deleted. recordDataTTL: ${RECORD_DATA_TTL:90} # Unit is minute minuteMetricsDataTTL: ${MINUTE_METRIC_DATA_TTL:90} # Unit is minute hourMetricsDataTTL: ${HOUR_METRIC_DATA_TTL:36} # Unit is hour diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricQuery.java index 498b62e32c24..32d35b152836 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricQuery.java +++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricQuery.java @@ -46,26 +46,24 @@ private MetricQueryService getMetricQueryService() { return metricQueryService; } - public IntValues getValues(final BatchMetricConditions metric, final Duration duration) throws IOException { + public IntValues getValues(final BatchMetricConditions metrics, final Duration duration) throws IOException { long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); - return getMetricQueryService().getValues(metric.getName(), metric.getIds(), duration.getStep(), startTimeBucket, endTimeBucket); + return getMetricQueryService().getValues(metrics.getName(), metrics.getIds(), duration.getStep(), startTimeBucket, endTimeBucket); } - public IntValues getLinearIntValues(final MetricCondition metric, - final Duration duration) throws IOException, ParseException { + public IntValues getLinearIntValues(final MetricCondition metrics, final Duration duration) throws IOException, ParseException { long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); - return getMetricQueryService().getLinearIntValues(metric.getName(), metric.getId(), duration.getStep(), startTimeBucket, endTimeBucket); + return getMetricQueryService().getLinearIntValues(metrics.getName(), metrics.getId(), duration.getStep(), startTimeBucket, endTimeBucket); } - public Thermodynamic getThermodynamic(final MetricCondition metric, - final Duration duration) throws IOException, ParseException { + public Thermodynamic getThermodynamic(final MetricCondition metrics, final Duration duration) throws IOException, ParseException { long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); - return getMetricQueryService().getThermodynamic(metric.getName(), metric.getId(), duration.getStep(), startTimeBucket, endTimeBucket); + return getMetricQueryService().getThermodynamic(metrics.getName(), metrics.getId(), duration.getStep(), startTimeBucket, endTimeBucket); } } diff --git a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/EnvoyMetricReceiverModule.java b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/EnvoyMetricReceiverModule.java index 686f923fd9c7..449518f081c2 100644 --- a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/EnvoyMetricReceiverModule.java +++ b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/EnvoyMetricReceiverModule.java @@ -21,12 +21,12 @@ import org.apache.skywalking.oap.server.library.module.ModuleDefine; /** - * Envoy metric receiver module + * Envoy metrics receiver module * * @author wusheng */ public class EnvoyMetricReceiverModule extends ModuleDefine { - public static final String NAME = "envoy-metric"; + public static final String NAME = "envoy-metrics"; public EnvoyMetricReceiverModule() { super(NAME); diff --git a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/MetricServiceGRPCHandler.java b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/MetricServiceGRPCHandler.java index 6ade6804c77a..ba59da619d26 100644 --- a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/MetricServiceGRPCHandler.java +++ b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/MetricServiceGRPCHandler.java @@ -42,18 +42,18 @@ public class MetricServiceGRPCHandler extends MetricsServiceGrpc.MetricsServiceI private final IServiceInventoryRegister serviceInventoryRegister; private final IServiceInstanceInventoryRegister serviceInstanceInventoryRegister; private final SourceReceiver sourceReceiver; - private CounterMetric counter; - private HistogramMetric histogram; + private CounterMetrics counter; + private HistogramMetrics histogram; public MetricServiceGRPCHandler(ModuleManager moduleManager) { serviceInventoryRegister = moduleManager.find(CoreModule.NAME).provider().getService(IServiceInventoryRegister.class); serviceInstanceInventoryRegister = moduleManager.find(CoreModule.NAME).provider().getService(IServiceInstanceInventoryRegister.class); sourceReceiver = moduleManager.find(CoreModule.NAME).provider().getService(SourceReceiver.class); - MetricCreator metricCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); - counter = metricCreator.createCounter("envoy_metric_in_count", "The count of envoy service metric received", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - histogram = metricCreator.createHistogramMetric("envoy_metric_in_latency", "The process latency of service metric receiver", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + MetricsCreator metricsCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); + counter = metricsCreator.createCounter("envoy_metric_in_count", "The count of envoy service metrics received", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + histogram = metricsCreator.createHistogramMetric("envoy_metric_in_latency", "The process latency of service metrics receiver", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); } @Override @@ -94,7 +94,7 @@ public StreamObserver streamMetrics(StreamObserver streamMetrics(StreamObserver 1000000000000000000L) { /** @@ -164,7 +164,7 @@ public StreamObserver streamMetrics(StreamObserver { - long minuteTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(metric.getTime()); - clrSourceDispatcher.sendMetric(serviceInstanceId, minuteTimeBucket, metric); + request.getMetricsList().forEach(metrics -> { + long minuteTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(metrics.getTime()); + clrSourceDispatcher.sendMetric(serviceInstanceId, minuteTimeBucket, metrics); }); responseObserver.onNext(Commands.newBuilder().build()); diff --git a/oap-server/server-receiver-plugin/skywalking-clr-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/clr/provider/handler/CLRSourceDispatcher.java b/oap-server/server-receiver-plugin/skywalking-clr-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/clr/provider/handler/CLRSourceDispatcher.java index ec42cd822ad1..82abdcb7ffed 100644 --- a/oap-server/server-receiver-plugin/skywalking-clr-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/clr/provider/handler/CLRSourceDispatcher.java +++ b/oap-server/server-receiver-plugin/skywalking-clr-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/clr/provider/handler/CLRSourceDispatcher.java @@ -49,7 +49,7 @@ public CLRSourceDispatcher(ModuleManager moduleManager) { instanceInventoryCache = moduleManager.find(CoreModule.NAME).provider().getService(ServiceInstanceInventoryCache.class); } - void sendMetric(int serviceInstanceId, long minuteTimeBucket, CLRMetric metric) { + void sendMetric(int serviceInstanceId, long minuteTimeBucket, CLRMetric metrics) { ServiceInstanceInventory serviceInstanceInventory = instanceInventoryCache.get(serviceInstanceId); int serviceId; if (Objects.nonNull(serviceInstanceInventory)) { @@ -59,7 +59,7 @@ void sendMetric(int serviceInstanceId, long minuteTimeBucket, CLRMetric metric) return; } - CPU cpu = metric.getCpu(); + CPU cpu = metrics.getCpu(); ServiceInstanceCLRCPU serviceInstanceCLRCPU = new ServiceInstanceCLRCPU(); serviceInstanceCLRCPU.setUsePercent(cpu.getUsagePercent()); serviceInstanceCLRCPU.setTimeBucket(minuteTimeBucket); @@ -69,7 +69,7 @@ void sendMetric(int serviceInstanceId, long minuteTimeBucket, CLRMetric metric) serviceInstanceCLRCPU.setServiceName(Const.EMPTY_STRING); sourceReceiver.receive(serviceInstanceCLRCPU); - ClrGC gc = metric.getGc(); + ClrGC gc = metrics.getGc(); ServiceInstanceCLRGC serviceInstanceCLRGC = new ServiceInstanceCLRGC(); serviceInstanceCLRGC.setGen0CollectCount(gc.getGen0CollectCount()); serviceInstanceCLRGC.setGen1CollectCount(gc.getGen1CollectCount()); @@ -82,7 +82,7 @@ void sendMetric(int serviceInstanceId, long minuteTimeBucket, CLRMetric metric) serviceInstanceCLRGC.setServiceName(Const.EMPTY_STRING); sourceReceiver.receive(serviceInstanceCLRGC); - ClrThread thread = metric.getThread(); + ClrThread thread = metrics.getThread(); ServiceInstanceCLRThread serviceInstanceCLRThread = new ServiceInstanceCLRThread(); serviceInstanceCLRThread.setAvailableCompletionPortThreads(thread.getAvailableCompletionPortThreads()); serviceInstanceCLRThread.setAvailableWorkerThreads(thread.getAvailableWorkerThreads()); diff --git a/oap-server/server-receiver-plugin/skywalking-istio-telemetry-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/istio/telemetry/provider/IstioTelemetryGRPCHandler.java b/oap-server/server-receiver-plugin/skywalking-istio-telemetry-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/istio/telemetry/provider/IstioTelemetryGRPCHandler.java index 668698cf842e..5307a5aa7a1a 100644 --- a/oap-server/server-receiver-plugin/skywalking-istio-telemetry-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/istio/telemetry/provider/IstioTelemetryGRPCHandler.java +++ b/oap-server/server-receiver-plugin/skywalking-istio-telemetry-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/istio/telemetry/provider/IstioTelemetryGRPCHandler.java @@ -45,15 +45,15 @@ public class IstioTelemetryGRPCHandler extends HandleMetricServiceGrpc.HandleMet private static final Joiner JOINER = Joiner.on("."); - private CounterMetric counter; - private HistogramMetric histogram; + private CounterMetrics counter; + private HistogramMetrics histogram; public IstioTelemetryGRPCHandler(ModuleManager moduleManager) { - MetricCreator metricCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); - counter = metricCreator.createCounter("istio_mesh_grpc_in_count", "The count of istio service mesh telemetry", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - histogram = metricCreator.createHistogramMetric("istio_mesh_grpc_in_latency", "The process latency of istio service mesh telemetry", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + MetricsCreator metricsCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); + counter = metricsCreator.createCounter("istio_mesh_grpc_in_count", "The count of istio service mesh telemetry", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + histogram = metricsCreator.createHistogramMetric("istio_mesh_grpc_in_latency", "The process latency of istio service mesh telemetry", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); } @Override public void handleMetric(IstioMetricProto.HandleMetricRequest request, @@ -63,7 +63,7 @@ public IstioTelemetryGRPCHandler(ModuleManager moduleManager) { } for (IstioMetricProto.InstanceMsg i : request.getInstancesList()) { counter.inc(); - HistogramMetric.Timer timer = histogram.createTimer(); + HistogramMetrics.Timer timer = histogram.createTimer(); try { String requestMethod = string(i, "requestMethod"); @@ -110,14 +110,14 @@ public IstioTelemetryGRPCHandler(ModuleManager moduleManager) { destServiceName = string(i, "destinationService"); } - ServiceMeshMetric metric = ServiceMeshMetric.newBuilder().setStartTime(requestTime.toEpochMilli()) + ServiceMeshMetric metrics = ServiceMeshMetric.newBuilder().setStartTime(requestTime.toEpochMilli()) .setEndTime(responseTime.toEpochMilli()).setSourceServiceName(sourceServiceName) .setSourceServiceInstance(string(i, "sourceUID")).setDestServiceName(destServiceName) .setDestServiceInstance(string(i, "destinationUID")).setEndpoint(endpoint).setLatency(latency) .setResponseCode(Math.toIntExact(responseCode)).setStatus(status).setProtocol(netProtocol).setDetectPoint(detectPoint).build(); - logger.debug("Transformed metric {}", metric); + logger.debug("Transformed metrics {}", metrics); - TelemetryDataDispatcher.preProcess(metric); + TelemetryDataDispatcher.preProcess(metrics); } finally { timer.finish(); } diff --git a/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMMetricReportServiceHandler.java b/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMMetricReportServiceHandler.java index eb40f9088373..1fc642a47572 100644 --- a/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMMetricReportServiceHandler.java +++ b/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMMetricReportServiceHandler.java @@ -40,12 +40,12 @@ public JVMMetricReportServiceHandler(ModuleManager moduleManager) { int serviceInstanceId = request.getServiceInstanceId(); if (logger.isDebugEnabled()) { - logger.debug("receive the jvm metric from service instance, id: {}", serviceInstanceId); + logger.debug("receive the jvm metrics from service instance, id: {}", serviceInstanceId); } - request.getMetricsList().forEach(metric -> { - long minuteTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(metric.getTime()); - jvmSourceDispatcher.sendMetric(serviceInstanceId, minuteTimeBucket, metric); + request.getMetricsList().forEach(metrics -> { + long minuteTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(metrics.getTime()); + jvmSourceDispatcher.sendMetric(serviceInstanceId, minuteTimeBucket, metrics); }); responseObserver.onNext(Commands.newBuilder().build()); diff --git a/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMMetricsServiceHandler.java b/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMMetricsServiceHandler.java index ed8afdf4bd16..116a43ba74b6 100644 --- a/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMMetricsServiceHandler.java +++ b/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMMetricsServiceHandler.java @@ -42,12 +42,12 @@ public JVMMetricsServiceHandler(ModuleManager moduleManager) { int serviceInstanceId = request.getApplicationInstanceId(); if (logger.isDebugEnabled()) { - logger.debug("receive the jvm metric from service instance, id: {}", serviceInstanceId); + logger.debug("receive the jvm metrics from service instance, id: {}", serviceInstanceId); } - request.getMetricsList().forEach(metric -> { - long minuteTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(metric.getTime()); - jvmSourceDispatcher.sendMetric(serviceInstanceId, minuteTimeBucket, metric); + request.getMetricsList().forEach(metrics -> { + long minuteTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(metrics.getTime()); + jvmSourceDispatcher.sendMetric(serviceInstanceId, minuteTimeBucket, metrics); }); responseObserver.onNext(Downstream.newBuilder().build()); diff --git a/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMSourceDispatcher.java b/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMSourceDispatcher.java index 3d41f69015f2..f98c856ef8ec 100644 --- a/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMSourceDispatcher.java +++ b/oap-server/server-receiver-plugin/skywalking-jvm-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/jvm/provider/handler/JVMSourceDispatcher.java @@ -42,7 +42,7 @@ public JVMSourceDispatcher(ModuleManager moduleManager) { instanceInventoryCache = moduleManager.find(CoreModule.NAME).provider().getService(ServiceInstanceInventoryCache.class); } - void sendMetric(int serviceInstanceId, long minuteTimeBucket, JVMMetric metric) { + void sendMetric(int serviceInstanceId, long minuteTimeBucket, JVMMetric metrics) { ServiceInstanceInventory serviceInstanceInventory = instanceInventoryCache.get(serviceInstanceId); int serviceId; if (Objects.nonNull(serviceInstanceInventory)) { @@ -52,10 +52,10 @@ void sendMetric(int serviceInstanceId, long minuteTimeBucket, JVMMetric metric) return; } - this.sendToCpuMetricProcess(serviceId, serviceInstanceId, minuteTimeBucket, metric.getCpu()); - this.sendToMemoryMetricProcess(serviceId, serviceInstanceId, minuteTimeBucket, metric.getMemoryList()); - this.sendToMemoryPoolMetricProcess(serviceId, serviceInstanceId, minuteTimeBucket, metric.getMemoryPoolList()); - this.sendToGCMetricProcess(serviceId, serviceInstanceId, minuteTimeBucket, metric.getGcList()); + this.sendToCpuMetricProcess(serviceId, serviceInstanceId, minuteTimeBucket, metrics.getCpu()); + this.sendToMemoryMetricProcess(serviceId, serviceInstanceId, minuteTimeBucket, metrics.getMemoryList()); + this.sendToMemoryPoolMetricProcess(serviceId, serviceInstanceId, minuteTimeBucket, metrics.getMemoryPoolList()); + this.sendToGCMetricProcess(serviceId, serviceInstanceId, minuteTimeBucket, metrics.getGcList()); } private void sendToCpuMetricProcess(int serviceId, int serviceInstanceId, long timeBucket, CPU cpu) { diff --git a/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/MeshDataBufferFileCache.java b/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/MeshDataBufferFileCache.java index ba6da628b69c..2dff78033c43 100644 --- a/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/MeshDataBufferFileCache.java +++ b/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/MeshDataBufferFileCache.java @@ -32,20 +32,20 @@ public class MeshDataBufferFileCache implements IConsumer dataCarrier; private BufferStream stream; - private CounterMetric meshBufferFileIn; - private CounterMetric meshBufferFileRetry; - private CounterMetric meshBufferFileOut; + private CounterMetrics meshBufferFileIn; + private CounterMetrics meshBufferFileRetry; + private CounterMetrics meshBufferFileOut; public MeshDataBufferFileCache(MeshModuleConfig config, ModuleManager moduleManager) { this.config = config; dataCarrier = new DataCarrier<>("MeshDataBufferFileCache", 3, 1024); - MetricCreator metricCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); - meshBufferFileIn = metricCreator.createCounter("mesh_buffer_file_in", "The number of mesh telemetry into the buffer file", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - meshBufferFileRetry = metricCreator.createCounter("mesh_buffer_file_retry", "The number of retry mesh telemetry from the buffer file, but haven't registered successfully.", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - meshBufferFileOut = metricCreator.createCounter("mesh_buffer_file_out", "The number of mesh telemetry out of the buffer file", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + MetricsCreator metricsCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); + meshBufferFileIn = metricsCreator.createCounter("mesh_buffer_file_in", "The number of mesh telemetry into the buffer file", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + meshBufferFileRetry = metricsCreator.createCounter("mesh_buffer_file_retry", "The number of retry mesh telemetry from the buffer file, but haven't registered successfully.", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + meshBufferFileOut = metricsCreator.createCounter("mesh_buffer_file_out", "The number of mesh telemetry out of the buffer file", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); } void start() throws IOException { @@ -65,8 +65,8 @@ void start() throws IOException { } - public void in(ServiceMeshMetric metric) { - dataCarrier.produce(new ServiceMeshMetricDataDecorator(metric)); + public void in(ServiceMeshMetric metrics) { + dataCarrier.produce(new ServiceMeshMetricDataDecorator(metrics)); } /** diff --git a/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/MeshGRPCHandler.java b/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/MeshGRPCHandler.java index 4658d3d39bed..b760adefa355 100644 --- a/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/MeshGRPCHandler.java +++ b/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/MeshGRPCHandler.java @@ -28,24 +28,24 @@ public class MeshGRPCHandler extends ServiceMeshMetricServiceGrpc.ServiceMeshMetricServiceImplBase { private static final Logger logger = LoggerFactory.getLogger(MeshGRPCHandler.class); - private HistogramMetric histogram; + private HistogramMetrics histogram; public MeshGRPCHandler(ModuleManager moduleManager) { - MetricCreator metricCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); - histogram = metricCreator.createHistogramMetric("mesh_grpc_in_latency", "The process latency of service mesh telemetry", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + MetricsCreator metricsCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); + histogram = metricsCreator.createHistogramMetric("mesh_grpc_in_latency", "The process latency of service mesh telemetry", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); } @Override public StreamObserver collect(StreamObserver responseObserver) { return new StreamObserver() { - @Override public void onNext(ServiceMeshMetric metric) { + @Override public void onNext(ServiceMeshMetric metrics) { if (logger.isDebugEnabled()) { - logger.debug("Received mesh metric: {}", metric); + logger.debug("Received mesh metrics: {}", metrics); } - HistogramMetric.Timer timer = histogram.createTimer(); + HistogramMetrics.Timer timer = histogram.createTimer(); try { - TelemetryDataDispatcher.preProcess(metric); + TelemetryDataDispatcher.preProcess(metrics); } finally { timer.finish(); } diff --git a/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/TelemetryDataDispatcher.java b/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/TelemetryDataDispatcher.java index 4731d48f6f8f..5bcf54b85027 100644 --- a/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/TelemetryDataDispatcher.java +++ b/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/TelemetryDataDispatcher.java @@ -88,11 +88,11 @@ public static void preProcess(ServiceMeshMetric data) { * @param decorator */ static void doDispatch(ServiceMeshMetricDataDecorator decorator) { - ServiceMeshMetric metric = decorator.getMetric(); - long minuteTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(metric.getStartTime()); + ServiceMeshMetric metrics = decorator.getMetric(); + long minuteTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(metrics.getStartTime()); heartbeat(decorator, minuteTimeBucket); - if (org.apache.skywalking.apm.network.common.DetectPoint.server.equals(metric.getDetectPoint())) { + if (org.apache.skywalking.apm.network.common.DetectPoint.server.equals(metrics.getDetectPoint())) { toAll(decorator, minuteTimeBucket); toService(decorator, minuteTimeBucket); toServiceInstance(decorator, minuteTimeBucket); @@ -103,30 +103,30 @@ static void doDispatch(ServiceMeshMetricDataDecorator decorator) { } private static void heartbeat(ServiceMeshMetricDataDecorator decorator, long minuteTimeBucket) { - ServiceMeshMetric metric = decorator.getMetric(); + ServiceMeshMetric metrics = decorator.getMetric(); int heartbeatCycle = 10000; // source - int instanceId = metric.getSourceServiceInstanceId(); + int instanceId = metrics.getSourceServiceInstanceId(); ServiceInstanceInventory serviceInstanceInventory = SERVICE_INSTANCE_CACHE.get(instanceId); if (Objects.nonNull(serviceInstanceInventory)) { - if (metric.getEndTime() - serviceInstanceInventory.getHeartbeatTime() > heartbeatCycle) { + if (metrics.getEndTime() - serviceInstanceInventory.getHeartbeatTime() > heartbeatCycle) { // trigger heartbeat every 10s. - SERVICE_INSTANCE_INVENTORY_REGISTER.heartbeat(metric.getSourceServiceInstanceId(), metric.getEndTime()); - SERVICE_INVENTORY_REGISTER.heartbeat(serviceInstanceInventory.getServiceId(), metric.getEndTime()); + SERVICE_INSTANCE_INVENTORY_REGISTER.heartbeat(metrics.getSourceServiceInstanceId(), metrics.getEndTime()); + SERVICE_INVENTORY_REGISTER.heartbeat(serviceInstanceInventory.getServiceId(), metrics.getEndTime()); } } else { logger.warn("Can't found service by service instance id from cache, service instance id is: {}", instanceId); } // dest - instanceId = metric.getDestServiceInstanceId(); + instanceId = metrics.getDestServiceInstanceId(); serviceInstanceInventory = SERVICE_INSTANCE_CACHE.get(instanceId); if (Objects.nonNull(serviceInstanceInventory)) { - if (metric.getEndTime() - serviceInstanceInventory.getHeartbeatTime() > heartbeatCycle) { + if (metrics.getEndTime() - serviceInstanceInventory.getHeartbeatTime() > heartbeatCycle) { // trigger heartbeat every 10s. - SERVICE_INSTANCE_INVENTORY_REGISTER.heartbeat(metric.getDestServiceInstanceId(), metric.getEndTime()); - SERVICE_INVENTORY_REGISTER.heartbeat(serviceInstanceInventory.getServiceId(), metric.getEndTime()); + SERVICE_INSTANCE_INVENTORY_REGISTER.heartbeat(metrics.getDestServiceInstanceId(), metrics.getEndTime()); + SERVICE_INVENTORY_REGISTER.heartbeat(serviceInstanceInventory.getServiceId(), metrics.getEndTime()); } } else { logger.warn("Can't found service by service instance id from cache, service instance id is: {}", instanceId); @@ -134,112 +134,112 @@ private static void heartbeat(ServiceMeshMetricDataDecorator decorator, long min } private static void toAll(ServiceMeshMetricDataDecorator decorator, long minuteTimeBucket) { - ServiceMeshMetric metric = decorator.getMetric(); + ServiceMeshMetric metrics = decorator.getMetric(); All all = new All(); all.setTimeBucket(minuteTimeBucket); - all.setName(getServiceName(metric.getDestServiceId(), metric.getDestServiceName())); - all.setServiceInstanceName(getServiceInstanceName(metric.getDestServiceInstanceId(), metric.getDestServiceInstance())); - all.setEndpointName(metric.getEndpoint()); - all.setLatency(metric.getLatency()); - all.setStatus(metric.getStatus()); - all.setType(protocol2Type(metric.getProtocol())); + all.setName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); + all.setServiceInstanceName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + all.setEndpointName(metrics.getEndpoint()); + all.setLatency(metrics.getLatency()); + all.setStatus(metrics.getStatus()); + all.setType(protocol2Type(metrics.getProtocol())); SOURCE_RECEIVER.receive(all); } private static void toService(ServiceMeshMetricDataDecorator decorator, long minuteTimeBucket) { - ServiceMeshMetric metric = decorator.getMetric(); + ServiceMeshMetric metrics = decorator.getMetric(); Service service = new Service(); service.setTimeBucket(minuteTimeBucket); - service.setId(metric.getDestServiceId()); - service.setName(getServiceName(metric.getDestServiceId(), metric.getDestServiceName())); - service.setServiceInstanceName(getServiceInstanceName(metric.getDestServiceInstanceId(), metric.getDestServiceInstance())); - service.setEndpointName(metric.getEndpoint()); - service.setLatency(metric.getLatency()); - service.setStatus(metric.getStatus()); - service.setType(protocol2Type(metric.getProtocol())); + service.setId(metrics.getDestServiceId()); + service.setName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); + service.setServiceInstanceName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + service.setEndpointName(metrics.getEndpoint()); + service.setLatency(metrics.getLatency()); + service.setStatus(metrics.getStatus()); + service.setType(protocol2Type(metrics.getProtocol())); SOURCE_RECEIVER.receive(service); } private static void toServiceRelation(ServiceMeshMetricDataDecorator decorator, long minuteTimeBucket) { - ServiceMeshMetric metric = decorator.getMetric(); + ServiceMeshMetric metrics = decorator.getMetric(); ServiceRelation serviceRelation = new ServiceRelation(); serviceRelation.setTimeBucket(minuteTimeBucket); - serviceRelation.setSourceServiceId(metric.getSourceServiceId()); - serviceRelation.setSourceServiceName(getServiceName(metric.getSourceServiceId(), metric.getSourceServiceName())); - serviceRelation.setSourceServiceInstanceName(getServiceInstanceName(metric.getSourceServiceInstanceId(), metric.getSourceServiceInstance())); - - serviceRelation.setDestServiceId(metric.getDestServiceId()); - serviceRelation.setDestServiceName(getServiceName(metric.getDestServiceId(), metric.getDestServiceName())); - serviceRelation.setDestServiceInstanceName(getServiceInstanceName(metric.getDestServiceInstanceId(), metric.getDestServiceInstance())); - - serviceRelation.setEndpoint(metric.getEndpoint()); - serviceRelation.setLatency(metric.getLatency()); - serviceRelation.setStatus(metric.getStatus()); - serviceRelation.setType(protocol2Type(metric.getProtocol())); - serviceRelation.setResponseCode(metric.getResponseCode()); - serviceRelation.setDetectPoint(detectPointMapping(metric.getDetectPoint())); - serviceRelation.setComponentId(protocol2Component(metric.getProtocol())); + serviceRelation.setSourceServiceId(metrics.getSourceServiceId()); + serviceRelation.setSourceServiceName(getServiceName(metrics.getSourceServiceId(), metrics.getSourceServiceName())); + serviceRelation.setSourceServiceInstanceName(getServiceInstanceName(metrics.getSourceServiceInstanceId(), metrics.getSourceServiceInstance())); + + serviceRelation.setDestServiceId(metrics.getDestServiceId()); + serviceRelation.setDestServiceName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); + serviceRelation.setDestServiceInstanceName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + + serviceRelation.setEndpoint(metrics.getEndpoint()); + serviceRelation.setLatency(metrics.getLatency()); + serviceRelation.setStatus(metrics.getStatus()); + serviceRelation.setType(protocol2Type(metrics.getProtocol())); + serviceRelation.setResponseCode(metrics.getResponseCode()); + serviceRelation.setDetectPoint(detectPointMapping(metrics.getDetectPoint())); + serviceRelation.setComponentId(protocol2Component(metrics.getProtocol())); SOURCE_RECEIVER.receive(serviceRelation); } private static void toServiceInstance(ServiceMeshMetricDataDecorator decorator, long minuteTimeBucket) { - ServiceMeshMetric metric = decorator.getMetric(); + ServiceMeshMetric metrics = decorator.getMetric(); ServiceInstance serviceInstance = new ServiceInstance(); serviceInstance.setTimeBucket(minuteTimeBucket); - serviceInstance.setId(metric.getDestServiceInstanceId()); - serviceInstance.setName(getServiceInstanceName(metric.getDestServiceInstanceId(), metric.getDestServiceInstance())); - serviceInstance.setServiceId(metric.getDestServiceId()); - serviceInstance.setServiceName(getServiceName(metric.getDestServiceId(), metric.getDestServiceName())); - serviceInstance.setEndpointName(metric.getEndpoint()); - serviceInstance.setLatency(metric.getLatency()); - serviceInstance.setStatus(metric.getStatus()); - serviceInstance.setType(protocol2Type(metric.getProtocol())); + serviceInstance.setId(metrics.getDestServiceInstanceId()); + serviceInstance.setName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + serviceInstance.setServiceId(metrics.getDestServiceId()); + serviceInstance.setServiceName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); + serviceInstance.setEndpointName(metrics.getEndpoint()); + serviceInstance.setLatency(metrics.getLatency()); + serviceInstance.setStatus(metrics.getStatus()); + serviceInstance.setType(protocol2Type(metrics.getProtocol())); SOURCE_RECEIVER.receive(serviceInstance); } private static void toServiceInstanceRelation(ServiceMeshMetricDataDecorator decorator, long minuteTimeBucket) { - ServiceMeshMetric metric = decorator.getMetric(); + ServiceMeshMetric metrics = decorator.getMetric(); ServiceInstanceRelation serviceRelation = new ServiceInstanceRelation(); serviceRelation.setTimeBucket(minuteTimeBucket); - serviceRelation.setSourceServiceInstanceId(metric.getSourceServiceInstanceId()); - serviceRelation.setSourceServiceInstanceName(getServiceInstanceName(metric.getSourceServiceInstanceId(), metric.getSourceServiceInstance())); - serviceRelation.setSourceServiceId(metric.getSourceServiceId()); - serviceRelation.setSourceServiceName(getServiceName(metric.getSourceServiceId(), metric.getSourceServiceName())); - - serviceRelation.setDestServiceInstanceId(metric.getDestServiceInstanceId()); - serviceRelation.setDestServiceInstanceName(getServiceInstanceName(metric.getDestServiceInstanceId(), metric.getDestServiceInstance())); - serviceRelation.setDestServiceId(metric.getDestServiceId()); - serviceRelation.setDestServiceName(getServiceName(metric.getDestServiceId(), metric.getDestServiceName())); - - serviceRelation.setEndpoint(metric.getEndpoint()); - serviceRelation.setLatency(metric.getLatency()); - serviceRelation.setStatus(metric.getStatus()); - serviceRelation.setType(protocol2Type(metric.getProtocol())); - serviceRelation.setResponseCode(metric.getResponseCode()); - serviceRelation.setDetectPoint(detectPointMapping(metric.getDetectPoint())); - serviceRelation.setComponentId(protocol2Component(metric.getProtocol())); + serviceRelation.setSourceServiceInstanceId(metrics.getSourceServiceInstanceId()); + serviceRelation.setSourceServiceInstanceName(getServiceInstanceName(metrics.getSourceServiceInstanceId(), metrics.getSourceServiceInstance())); + serviceRelation.setSourceServiceId(metrics.getSourceServiceId()); + serviceRelation.setSourceServiceName(getServiceName(metrics.getSourceServiceId(), metrics.getSourceServiceName())); + + serviceRelation.setDestServiceInstanceId(metrics.getDestServiceInstanceId()); + serviceRelation.setDestServiceInstanceName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + serviceRelation.setDestServiceId(metrics.getDestServiceId()); + serviceRelation.setDestServiceName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); + + serviceRelation.setEndpoint(metrics.getEndpoint()); + serviceRelation.setLatency(metrics.getLatency()); + serviceRelation.setStatus(metrics.getStatus()); + serviceRelation.setType(protocol2Type(metrics.getProtocol())); + serviceRelation.setResponseCode(metrics.getResponseCode()); + serviceRelation.setDetectPoint(detectPointMapping(metrics.getDetectPoint())); + serviceRelation.setComponentId(protocol2Component(metrics.getProtocol())); SOURCE_RECEIVER.receive(serviceRelation); } private static void toEndpoint(ServiceMeshMetricDataDecorator decorator, long minuteTimeBucket) { - ServiceMeshMetric metric = decorator.getMetric(); + ServiceMeshMetric metrics = decorator.getMetric(); Endpoint endpoint = new Endpoint(); endpoint.setTimeBucket(minuteTimeBucket); endpoint.setId(decorator.getEndpointId()); - endpoint.setName(metric.getEndpoint()); - endpoint.setServiceId(metric.getDestServiceId()); - endpoint.setServiceName(getServiceName(metric.getDestServiceId(), metric.getDestServiceName())); - endpoint.setServiceInstanceId(metric.getDestServiceInstanceId()); - endpoint.setServiceInstanceName(getServiceInstanceName(metric.getDestServiceInstanceId(), metric.getDestServiceInstance())); - - endpoint.setLatency(metric.getLatency()); - endpoint.setStatus(metric.getStatus()); - endpoint.setType(protocol2Type(metric.getProtocol())); + endpoint.setName(metrics.getEndpoint()); + endpoint.setServiceId(metrics.getDestServiceId()); + endpoint.setServiceName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); + endpoint.setServiceInstanceId(metrics.getDestServiceInstanceId()); + endpoint.setServiceInstanceName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + + endpoint.setLatency(metrics.getLatency()); + endpoint.setStatus(metrics.getStatus()); + endpoint.setType(protocol2Type(metrics.getProtocol())); SOURCE_RECEIVER.receive(endpoint); } diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/TraceServiceModuleConfig.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/TraceServiceModuleConfig.java index fce1ca7ea34a..13ceabeffafe 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/TraceServiceModuleConfig.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/TraceServiceModuleConfig.java @@ -42,7 +42,7 @@ public class TraceServiceModuleConfig extends ModuleConfig { /** * Analysis trace status. * - * 1. Default(YES) means analysis all metric from trace. + * 1. Default(YES) means analysis all metrics from trace. * * 2. NO means, only save trace, but metrics come other places, such as service mesh. */ diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/handler/v6/grpc/TraceSegmentReportServiceHandler.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/handler/v6/grpc/TraceSegmentReportServiceHandler.java index e411d0e584f7..827d5f7f8f77 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/handler/v6/grpc/TraceSegmentReportServiceHandler.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/handler/v6/grpc/TraceSegmentReportServiceHandler.java @@ -37,13 +37,13 @@ public class TraceSegmentReportServiceHandler extends TraceSegmentReportServiceG private static final Logger logger = LoggerFactory.getLogger(TraceSegmentServiceHandler.class); private final SegmentParseV2.Producer segmentProducer; - private HistogramMetric histogram; + private HistogramMetrics histogram; public TraceSegmentReportServiceHandler(SegmentParseV2.Producer segmentProducer, ModuleManager moduleManager) { this.segmentProducer = segmentProducer; - MetricCreator metricCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); - histogram = metricCreator.createHistogramMetric("trace_grpc_v6_in_latency", "The process latency of service mesh telemetry", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + MetricsCreator metricsCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); + histogram = metricsCreator.createHistogramMetric("trace_grpc_v6_in_latency", "The process latency of service mesh telemetry", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); } @Override public StreamObserver collect(StreamObserver responseObserver) { @@ -53,7 +53,7 @@ public TraceSegmentReportServiceHandler(SegmentParseV2.Producer segmentProducer, logger.debug("receive segment"); } - HistogramMetric.Timer timer = histogram.createTimer(); + HistogramMetrics.Timer timer = histogram.createTimer(); try { segmentProducer.send(segment, SegmentSource.Agent); } finally { diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/SegmentParse.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/SegmentParse.java index 7abe9e592229..c2bd511a94ad 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/SegmentParse.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/SegmentParse.java @@ -46,9 +46,9 @@ public class SegmentParse { private final SegmentCoreInfo segmentCoreInfo; private final TraceServiceModuleConfig config; @Setter private SegmentStandardizationWorker standardizationWorker; - private volatile static CounterMetric TRACE_BUFFER_FILE_RETRY; - private volatile static CounterMetric TRACE_BUFFER_FILE_OUT; - private volatile static CounterMetric TRACE_PARSE_ERROR; + private volatile static CounterMetrics TRACE_BUFFER_FILE_RETRY; + private volatile static CounterMetrics TRACE_BUFFER_FILE_OUT; + private volatile static CounterMetrics TRACE_PARSE_ERROR; private SegmentParse(ModuleManager moduleManager, SegmentParserListenerManager listenerManager, TraceServiceModuleConfig config) { @@ -61,13 +61,13 @@ private SegmentParse(ModuleManager moduleManager, SegmentParserListenerManager l this.segmentCoreInfo.setV2(false); this.config = config; - MetricCreator metricCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); - TRACE_BUFFER_FILE_RETRY = metricCreator.createCounter("v5_trace_buffer_file_retry", "The number of retry trace segment from the buffer file, but haven't registered successfully.", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - TRACE_BUFFER_FILE_OUT = metricCreator.createCounter("v5_trace_buffer_file_out", "The number of trace segment out of the buffer file", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - TRACE_PARSE_ERROR = metricCreator.createCounter("v5_trace_parse_error", "The number of trace segment out of the buffer file", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + MetricsCreator metricsCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); + TRACE_BUFFER_FILE_RETRY = metricsCreator.createCounter("v5_trace_buffer_file_retry", "The number of retry trace segment from the buffer file, but haven't registered successfully.", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + TRACE_BUFFER_FILE_OUT = metricsCreator.createCounter("v5_trace_buffer_file_out", "The number of trace segment out of the buffer file", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + TRACE_PARSE_ERROR = metricsCreator.createCounter("v5_trace_parse_error", "The number of trace segment out of the buffer file", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); } public boolean parse(BufferData bufferData, Source source) { diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/SegmentParseV2.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/SegmentParseV2.java index 543b0eb1a184..07e3395fc9b0 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/SegmentParseV2.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/SegmentParseV2.java @@ -49,9 +49,9 @@ public class SegmentParseV2 { private final SegmentCoreInfo segmentCoreInfo; private final TraceServiceModuleConfig config; @Setter private SegmentStandardizationWorker standardizationWorker; - private volatile static CounterMetric TRACE_BUFFER_FILE_RETRY; - private volatile static CounterMetric TRACE_BUFFER_FILE_OUT; - private volatile static CounterMetric TRACE_PARSE_ERROR; + private volatile static CounterMetrics TRACE_BUFFER_FILE_RETRY; + private volatile static CounterMetrics TRACE_BUFFER_FILE_OUT; + private volatile static CounterMetrics TRACE_PARSE_ERROR; private SegmentParseV2(ModuleManager moduleManager, SegmentParserListenerManager listenerManager, TraceServiceModuleConfig config) { this.moduleManager = moduleManager; @@ -64,13 +64,13 @@ private SegmentParseV2(ModuleManager moduleManager, SegmentParserListenerManager this.config = config; if (TRACE_BUFFER_FILE_RETRY == null) { - MetricCreator metricCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); - TRACE_BUFFER_FILE_RETRY = metricCreator.createCounter("v6_trace_buffer_file_retry", "The number of retry trace segment from the buffer file, but haven't registered successfully.", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - TRACE_BUFFER_FILE_OUT = metricCreator.createCounter("v6_trace_buffer_file_out", "The number of trace segment out of the buffer file", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); - TRACE_PARSE_ERROR = metricCreator.createCounter("v6_trace_parse_error", "The number of trace segment out of the buffer file", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + MetricsCreator metricsCreator = moduleManager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); + TRACE_BUFFER_FILE_RETRY = metricsCreator.createCounter("v6_trace_buffer_file_retry", "The number of retry trace segment from the buffer file, but haven't registered successfully.", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + TRACE_BUFFER_FILE_OUT = metricsCreator.createCounter("v6_trace_buffer_file_out", "The number of trace segment out of the buffer file", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); + TRACE_PARSE_ERROR = metricsCreator.createCounter("v6_trace_parse_error", "The number of trace segment out of the buffer file", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); } } diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/SegmentStandardizationWorker.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/SegmentStandardizationWorker.java index 15672c5e93a4..5e363b009980 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/SegmentStandardizationWorker.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/SegmentStandardizationWorker.java @@ -39,7 +39,7 @@ public class SegmentStandardizationWorker extends AbstractWorker dataCarrier; - private CounterMetric traceBufferFileIn; + private CounterMetrics traceBufferFileIn; public SegmentStandardizationWorker(ModuleDefineHolder moduleDefineHolder, SegmentParse.Producer segmentParseCreator, String path, int offsetFileMaxSize, @@ -59,10 +59,10 @@ public SegmentStandardizationWorker(ModuleDefineHolder moduleDefineHolder, dataCarrier = new DataCarrier<>("SegmentStandardizationWorker", 1, 1024); dataCarrier.consume(new Consumer(stream), 1, 200); - MetricCreator metricCreator = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricCreator.class); + MetricsCreator metricsCreator = moduleDefineHolder.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class); String metricNamePrefix = isV6 ? "v6_" : "v5_"; - traceBufferFileIn = metricCreator.createCounter(metricNamePrefix + "trace_buffer_file_in", "The number of trace segment into the buffer file", - MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE); + traceBufferFileIn = metricsCreator.createCounter(metricNamePrefix + "trace_buffer_file_in", "The number of trace segment into the buffer file", + MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE); } @Override diff --git a/oap-server/server-starter/src/main/assembly/alarm-settings-sample.yml b/oap-server/server-starter/src/main/assembly/alarm-settings-sample.yml index 67a60de4406f..e332587a32ab 100644 --- a/oap-server/server-starter/src/main/assembly/alarm-settings-sample.yml +++ b/oap-server/server-starter/src/main/assembly/alarm-settings-sample.yml @@ -18,20 +18,20 @@ rules: # Rule unique name, must be ended with `_rule`. endpoint_percent_rule: - # Indicator value need to be long, double or int - indicator-name: endpoint_percent + # Metrics value need to be long, double or int + metrics-name: endpoint_percent threshold: 75 op: < - # The length of time to evaluate the metric + # The length of time to evaluate the metrics period: 10 - # How many times after the metric match the condition, will trigger alarm + # How many times after the metrics match the condition, will trigger alarm count: 3 # How many times of checks, the alarm keeps silence after alarm triggered, default as same as period. silence-period: 10 message: Successful rate of endpoint {name} is lower than 75% service_resp_time_rule: - indicator-name: service_resp_time - # [Optional] Default, match all services in this indicator + metrics-name: service_resp_time + # [Optional] Default, match all services in this metrics include-names: - dubbox-provider - dubbox-consumer diff --git a/oap-server/server-starter/src/main/assembly/alarm-settings.yml b/oap-server/server-starter/src/main/assembly/alarm-settings.yml index 345b0b4ae9e0..8ed9c2e7235f 100644 --- a/oap-server/server-starter/src/main/assembly/alarm-settings.yml +++ b/oap-server/server-starter/src/main/assembly/alarm-settings.yml @@ -18,7 +18,7 @@ rules: # Rule unique name, must be ended with `_rule`. service_resp_time_rule: - indicator-name: service_resp_time + metrics-name: service_resp_time op: ">" threshold: 1000 period: 10 @@ -26,20 +26,20 @@ rules: silence-period: 5 message: Response time of service {name} is more than 1000ms in 3 minutes of last 10 minutes. service_sla_rule: - # Indicator value need to be long, double or int - indicator-name: service_sla + # Metrics value need to be long, double or int + metrics-name: service_sla op: "<" threshold: 8000 - # The length of time to evaluate the metric + # The length of time to evaluate the metrics period: 10 - # How many times after the metric match the condition, will trigger alarm + # How many times after the metrics match the condition, will trigger alarm count: 2 # How many times of checks, the alarm keeps silence after alarm triggered, default as same as period. silence-period: 3 message: Successful rate of service {name} is lower than 80% in 2 minutes of last 10 minutes service_p90_sla_rule: - # Indicator value need to be long, double or int - indicator-name: service_p90 + # Metrics value need to be long, double or int + metrics-name: service_p90 op: ">" threshold: 1000 period: 10 @@ -47,18 +47,18 @@ rules: silence-period: 5 message: 90% response time of service {name} is more than 1000ms in 3 minutes of last 10 minutes service_instance_resp_time_rule: - indicator-name: service_instance_resp_time + metrics-name: service_instance_resp_time op: ">" threshold: 1000 period: 10 count: 2 silence-period: 5 message: Response time of service instance {name} is more than 1000ms in 2 minutes of last 10 minutes -# Active endpoint related metric alarm will cost more memory than service and service instance metric alarm. +# Active endpoint related metrics alarm will cost more memory than service and service instance metrics alarm. # Because the number of endpoint is much more than service and instance. # # endpoint_avg_rule: -# indicator-name: endpoint_avg +# metrics-name: endpoint_avg # op: ">" # threshold: 1000 # period: 10 diff --git a/oap-server/server-starter/src/main/assembly/application.yml b/oap-server/server-starter/src/main/assembly/application.yml index 49fa6997cc52..0f25c93f10de 100644 --- a/oap-server/server-starter/src/main/assembly/application.yml +++ b/oap-server/server-starter/src/main/assembly/application.yml @@ -48,7 +48,7 @@ core: - Hour - Day - Month - # Set a timeout on metric data. After the timeout has expired, the metric data will automatically be deleted. + # Set a timeout on metrics data. After the timeout has expired, the metrics data will automatically be deleted. recordDataTTL: ${SW_CORE_RECORD_DATA_TTL:90} # Unit is minute minuteMetricsDataTTL: ${SW_CORE_MINUTE_METRIC_DATA_TTL:90} # Unit is minute hourMetricsDataTTL: ${SW_CORE_HOUR_METRIC_DATA_TTL:36} # Unit is hour @@ -100,7 +100,7 @@ service-mesh: bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false} istio-telemetry: default: -envoy-metric: +envoy-metrics: default: #receiver_zipkin: # default: diff --git a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java b/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java index 4f2f31620222..38b2efbe9d98 100644 --- a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java +++ b/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/OAPServerStartUp.java @@ -42,8 +42,8 @@ public static void main(String[] args) { ApplicationConfiguration applicationConfiguration = configLoader.load(); manager.init(applicationConfiguration); - manager.find(TelemetryModule.NAME).provider().getService(MetricCreator.class).createGauge("uptime", - "oap server start up time", MetricTag.EMPTY_KEY, MetricTag.EMPTY_VALUE) + manager.find(TelemetryModule.NAME).provider().getService(MetricsCreator.class).createGauge("uptime", + "oap server start up time", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE) // Set uptime to second .setValue(System.currentTimeMillis() / 1000d); diff --git a/oap-server/server-starter/src/main/resources/alarm-settings.yml b/oap-server/server-starter/src/main/resources/alarm-settings.yml index 9ea69756ba3f..539d3690e452 100644 --- a/oap-server/server-starter/src/main/resources/alarm-settings.yml +++ b/oap-server/server-starter/src/main/resources/alarm-settings.yml @@ -18,20 +18,20 @@ rules: # Rule unique name, must be ended with `_rule`. # endpoint_percent_rule: -# # Indicator value need to be long, double or int -# indicator-name: endpoint_percent +# # Metrics value need to be long, double or int +# metrics-name: endpoint_percent # threshold: 75 # op: < -# # The length of time to evaluate the metric +# # The length of time to evaluate the metrics # period: 10 -# # How many times after the metric match the condition, will trigger alarm +# # How many times after the metrics match the condition, will trigger alarm # count: 3 # # How many times of checks, the alarm keeps silence after alarm triggered, default as same as period. # silence-period: 10 # message: Successful rate of endpoint {name} is lower than 75% service_resp_time_rule: - indicator-name: service_resp_time - # [Optional] Default, match all services in this indicator + metrics-name: service_resp_time + # [Optional] Default, match all services in this metrics include-names: - dubbox-provider - dubbox-consumer diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-starter/src/main/resources/application.yml index 796d17ce5bde..27a9f25d02bb 100644 --- a/oap-server/server-starter/src/main/resources/application.yml +++ b/oap-server/server-starter/src/main/resources/application.yml @@ -48,7 +48,7 @@ core: - Hour - Day - Month - # Set a timeout on metric data. After the timeout has expired, the metric data will automatically be deleted. + # Set a timeout on metrics data. After the timeout has expired, the metrics data will automatically be deleted. recordDataTTL: ${SW_CORE_RECORD_DATA_TTL:90} # Unit is minute minuteMetricsDataTTL: ${SW_CORE_MINUTE_METRIC_DATA_TTL:90} # Unit is minute hourMetricsDataTTL: ${SW_CORE_HOUR_METRIC_DATA_TTL:36} # Unit is hour @@ -100,7 +100,7 @@ service-mesh: bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false} istio-telemetry: default: -envoy-metric: +envoy-metrics: default: #receiver_zipkin: # default: diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java index a77992115403..5382955e989c 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java @@ -35,7 +35,7 @@ import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ILogQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO; -import org.apache.skywalking.oap.server.core.storage.query.IMetricQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.IMetricsQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ITopNRecordsQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO; @@ -59,7 +59,7 @@ import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.AlarmQueryEsDAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.LogQueryEsDAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.MetadataQueryEsDAO; -import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.MetricQueryEsDAO; +import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.MetricsQueryEsDAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopNRecordsQueryEsDAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopologyQueryEsDAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TraceQueryEsDAO; @@ -114,7 +114,7 @@ public void prepare() throws ServiceNotProvidedException { this.registerServiceImplementation(INetworkAddressInventoryCacheDAO.class, new NetworkAddressInventoryCacheEsDAO(elasticSearchClient)); this.registerServiceImplementation(ITopologyQueryDAO.class, new TopologyQueryEsDAO(elasticSearchClient)); - this.registerServiceImplementation(IMetricQueryDAO.class, new MetricQueryEsDAO(elasticSearchClient)); + this.registerServiceImplementation(IMetricsQueryDAO.class, new MetricsQueryEsDAO(elasticSearchClient)); this.registerServiceImplementation(ITraceQueryDAO.class, new TraceQueryEsDAO(elasticSearchClient, config.getSegmentQueryMaxSize())); this.registerServiceImplementation(IMetadataQueryDAO.class, new MetadataQueryEsDAO(elasticSearchClient, config.getMetadataQueryMaxSize())); this.registerServiceImplementation(IAggregationQueryDAO.class, new AggregationQueryEsDAO(elasticSearchClient)); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/ColumnTypeEsMapping.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/ColumnTypeEsMapping.java index 9df21489d3b2..c657412ddf66 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/ColumnTypeEsMapping.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/ColumnTypeEsMapping.java @@ -18,7 +18,7 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base; -import org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray; +import org.apache.skywalking.oap.server.core.analysis.metrics.IntKeyLongValueArray; import org.apache.skywalking.oap.server.core.storage.model.DataTypeMapping; /** diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/EsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/EsDAO.java index 48bb44c1eb6b..2cd3789f4be0 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/EsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/EsDAO.java @@ -18,7 +18,7 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.query.sql.Where; import org.apache.skywalking.oap.server.core.storage.AbstractDAO; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; @@ -35,7 +35,7 @@ public EsDAO(ElasticSearchClient client) { } public final void queryBuild(SearchSourceBuilder sourceBuilder, Where where, long startTB, long endTB) { - RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).gte(startTB).lte(endTB); + RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(Metrics.TIME_BUCKET).gte(startTB).lte(endTB); if (where.getKeyValues().isEmpty()) { sourceBuilder.query(rangeQueryBuilder); } else { diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/IndicatorEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java similarity index 77% rename from oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/IndicatorEsDAO.java rename to oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java index 6e855d64572d..5095252d98e5 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/IndicatorEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.util.Map; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.storage.*; import org.apache.skywalking.oap.server.core.storage.type.StorageDataType; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; @@ -33,19 +33,19 @@ /** * @author peng-yongsheng */ -public class IndicatorEsDAO extends EsDAO implements IIndicatorDAO { +public class MetricsEsDAO extends EsDAO implements IMetricsDAO { - private static final Logger logger = LoggerFactory.getLogger(IndicatorEsDAO.class); + private static final Logger logger = LoggerFactory.getLogger(MetricsEsDAO.class); - private final StorageBuilder storageBuilder; + private final StorageBuilder storageBuilder; - public IndicatorEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { + public MetricsEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { super(client); this.storageBuilder = storageBuilder; } - @Override public Indicator get(String modelName, Indicator indicator) throws IOException { - GetResponse response = getClient().get(modelName, indicator.id()); + @Override public Metrics get(String modelName, Metrics metrics) throws IOException { + GetResponse response = getClient().get(modelName, metrics.id()); if (response.isExists()) { return storageBuilder.map2Data(response.getSource()); } else { @@ -53,8 +53,8 @@ public IndicatorEsDAO(ElasticSearchClient client, StorageBuilder stor } } - @Override public IndexRequest prepareBatchInsert(String modelName, Indicator indicator) throws IOException { - Map objectMap = storageBuilder.data2Map(indicator); + @Override public IndexRequest prepareBatchInsert(String modelName, Metrics metrics) throws IOException { + Map objectMap = storageBuilder.data2Map(metrics); XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); for (String key : objectMap.keySet()) { @@ -66,11 +66,11 @@ public IndicatorEsDAO(ElasticSearchClient client, StorageBuilder stor } } builder.endObject(); - return getClient().prepareInsert(modelName, indicator.id(), builder); + return getClient().prepareInsert(modelName, metrics.id(), builder); } - @Override public UpdateRequest prepareBatchUpdate(String modelName, Indicator indicator) throws IOException { - Map objectMap = storageBuilder.data2Map(indicator); + @Override public UpdateRequest prepareBatchUpdate(String modelName, Metrics metrics) throws IOException { + Map objectMap = storageBuilder.data2Map(metrics); XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); for (String key : objectMap.keySet()) { @@ -82,6 +82,6 @@ public IndicatorEsDAO(ElasticSearchClient client, StorageBuilder stor } } builder.endObject(); - return getClient().prepareUpdate(modelName, indicator.id(), builder); + return getClient().prepareUpdate(modelName, metrics.id(), builder); } } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsDAO.java index 3774d65df6cd..52fe3fb97aec 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsDAO.java @@ -18,7 +18,7 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.analysis.record.Record; import org.apache.skywalking.oap.server.core.register.RegisterSource; import org.apache.skywalking.oap.server.core.storage.*; @@ -33,8 +33,8 @@ public StorageEsDAO(ElasticSearchClient client) { super(client); } - @Override public IIndicatorDAO newIndicatorDao(StorageBuilder storageBuilder) { - return new IndicatorEsDAO(getClient(), storageBuilder); + @Override public IMetricsDAO newMetricsDao(StorageBuilder storageBuilder) { + return new MetricsEsDAO(getClient(), storageBuilder); } @Override public IRegisterDAO newRegisterDao(StorageBuilder storageBuilder) { diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java index e1216d877d12..21bf20119543 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.util.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.query.entity.*; import org.apache.skywalking.oap.server.core.register.*; import org.apache.skywalking.oap.server.core.storage.DownSamplingModelNameBuilder; @@ -49,7 +49,7 @@ public List getServiceTopN(String indName, String valueCName, int to String indexName = DownSamplingModelNameBuilder.build(step, indName); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); - sourceBuilder.query(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB)); + sourceBuilder.query(QueryBuilders.rangeQuery(Metrics.TIME_BUCKET).lte(endTB).gte(startTB)); return aggregation(indexName, valueCName, sourceBuilder, topN, order); } @@ -58,7 +58,7 @@ public List getServiceTopN(String indName, String valueCName, int to String indexName = DownSamplingModelNameBuilder.build(step, indName); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); - sourceBuilder.query(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB)); + sourceBuilder.query(QueryBuilders.rangeQuery(Metrics.TIME_BUCKET).lte(endTB).gte(startTB)); return aggregation(indexName, valueCName, sourceBuilder, topN, order); } @@ -71,7 +71,7 @@ public List getServiceTopN(String indName, String valueCName, int to BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); sourceBuilder.query(boolQueryBuilder); - boolQueryBuilder.must().add(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB)); + boolQueryBuilder.must().add(QueryBuilders.rangeQuery(Metrics.TIME_BUCKET).lte(endTB).gte(startTB)); boolQueryBuilder.must().add(QueryBuilders.termQuery(ServiceInstanceInventory.SERVICE_ID, serviceId)); return aggregation(indexName, valueCName, sourceBuilder, topN, order); @@ -83,7 +83,7 @@ public List getAllEndpointTopN(String indName, String valueCName, in String indexName = DownSamplingModelNameBuilder.build(step, indName); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); - sourceBuilder.query(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB)); + sourceBuilder.query(QueryBuilders.rangeQuery(Metrics.TIME_BUCKET).lte(endTB).gte(startTB)); return aggregation(indexName, valueCName, sourceBuilder, topN, order); } @@ -97,7 +97,7 @@ public List getEndpointTopN(int serviceId, String indName, String va BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); sourceBuilder.query(boolQueryBuilder); - boolQueryBuilder.must().add(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB)); + boolQueryBuilder.must().add(QueryBuilders.rangeQuery(Metrics.TIME_BUCKET).lte(endTB).gte(startTB)); boolQueryBuilder.must().add(QueryBuilders.termQuery(EndpointInventory.SERVICE_ID, serviceId)); return aggregation(indexName, valueCName, sourceBuilder, topN, order); @@ -112,8 +112,8 @@ private List aggregation(String indexName, String valueCName, Search } TermsAggregationBuilder aggregationBuilder = AggregationBuilders - .terms(Indicator.ENTITY_ID) - .field(Indicator.ENTITY_ID) + .terms(Metrics.ENTITY_ID) + .field(Metrics.ENTITY_ID) .order(BucketOrder.aggregation(valueCName, asc)) .size(topN) .subAggregation( @@ -124,7 +124,7 @@ private List aggregation(String indexName, String valueCName, Search SearchResponse response = getClient().search(indexName, sourceBuilder); List topNEntities = new ArrayList<>(); - Terms idTerms = response.getAggregations().get(Indicator.ENTITY_ID); + Terms idTerms = response.getAggregations().get(Metrics.ENTITY_ID); for (Terms.Bucket termsBucket : idTerms.getBuckets()) { TopNEntity topNEntity = new TopNEntity(); topNEntity.setId(termsBucket.getKeyAsString()); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java similarity index 91% rename from oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java rename to oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java index 3ee9d4760d81..0d6336975e81 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricsQueryEsDAO.java @@ -20,11 +20,11 @@ import java.io.IOException; import java.util.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; import org.apache.skywalking.oap.server.core.query.entity.*; import org.apache.skywalking.oap.server.core.query.sql.*; import org.apache.skywalking.oap.server.core.storage.DownSamplingModelNameBuilder; -import org.apache.skywalking.oap.server.core.storage.query.IMetricQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.IMetricsQueryDAO; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO; import org.elasticsearch.action.get.*; @@ -38,9 +38,9 @@ /** * @author peng-yongsheng */ -public class MetricQueryEsDAO extends EsDAO implements IMetricQueryDAO { +public class MetricsQueryEsDAO extends EsDAO implements IMetricsQueryDAO { - public MetricQueryEsDAO(ElasticSearchClient client) { + public MetricsQueryEsDAO(ElasticSearchClient client) { super(client); } @@ -51,7 +51,7 @@ public IntValues getValues(String indName, Step step, long startTB, long endTB, SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); queryBuild(sourceBuilder, where, startTB, endTB); - TermsAggregationBuilder entityIdAggregation = AggregationBuilders.terms(Indicator.ENTITY_ID).field(Indicator.ENTITY_ID).size(1000); + TermsAggregationBuilder entityIdAggregation = AggregationBuilders.terms(Metrics.ENTITY_ID).field(Metrics.ENTITY_ID).size(1000); functionAggregation(function, entityIdAggregation, valueCName); sourceBuilder.aggregation(entityIdAggregation); @@ -59,7 +59,7 @@ public IntValues getValues(String indName, Step step, long startTB, long endTB, SearchResponse response = getClient().search(indexName, sourceBuilder); IntValues intValues = new IntValues(); - Terms idTerms = response.getAggregations().get(Indicator.ENTITY_ID); + Terms idTerms = response.getAggregations().get(Metrics.ENTITY_ID); for (Terms.Bucket idBucket : idTerms.getBuckets()) { long value = 0; switch (function) { @@ -136,11 +136,11 @@ private void functionAggregation(Function function, TermsAggregationBuilder pare // add empty list to represent no data exist for this time bucket thermodynamicValueMatrix.add(new ArrayList<>()); } else { - int axisYStep = ((Number)source.get(ThermodynamicIndicator.STEP)).intValue(); + int axisYStep = ((Number)source.get(ThermodynamicMetrics.STEP)).intValue(); thermodynamic.setAxisYStep(axisYStep); - numOfSteps = ((Number)source.get(ThermodynamicIndicator.NUM_OF_STEPS)).intValue() + 1; + numOfSteps = ((Number)source.get(ThermodynamicMetrics.NUM_OF_STEPS)).intValue() + 1; - String value = (String)source.get(ThermodynamicIndicator.DETAIL_GROUP); + String value = (String)source.get(ThermodynamicMetrics.DETAIL_GROUP); IntKeyLongValueArray intKeyLongValues = new IntKeyLongValueArray(5); intKeyLongValues.toObject(value); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java index 5a90d67b0c48..52d8e26118a6 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java @@ -22,10 +22,10 @@ import java.util.ArrayList; import java.util.List; import org.apache.skywalking.oap.server.core.UnexpectedException; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation.EndpointRelationServerSideIndicator; -import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.ServiceRelationClientSideIndicator; -import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.ServiceRelationServerSideIndicator; +import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation.EndpointRelationServerSideMetrics; +import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.ServiceRelationServerSideMetrics; import org.apache.skywalking.oap.server.core.query.entity.Call; import org.apache.skywalking.oap.server.core.query.entity.Step; import org.apache.skywalking.oap.server.core.source.DetectPoint; @@ -62,7 +62,7 @@ public List loadSpecifiedServerSideServiceRelations(Step step, long startT sourceBuilder.size(0); setQueryCondition(sourceBuilder, startTB, endTB, serviceIds); - String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationServerSideIndicator.INDEX_NAME); + String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationServerSideMetrics.INDEX_NAME); return load(sourceBuilder, indexName, DetectPoint.SERVER); } @@ -77,41 +77,41 @@ public List loadSpecifiedClientSideServiceRelations(Step step, long startT sourceBuilder.size(0); setQueryCondition(sourceBuilder, startTB, endTB, serviceIds); - String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationClientSideIndicator.INDEX_NAME); + String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationClientSideMetrics.INDEX_NAME); return load(sourceBuilder, indexName, DetectPoint.CLIENT); } private void setQueryCondition(SearchSourceBuilder sourceBuilder, long startTB, long endTB, List serviceIds) { BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.rangeQuery(ServiceRelationServerSideIndicator.TIME_BUCKET).gte(startTB).lte(endTB)); + boolQuery.must().add(QueryBuilders.rangeQuery(ServiceRelationServerSideMetrics.TIME_BUCKET).gte(startTB).lte(endTB)); BoolQueryBuilder serviceIdBoolQuery = QueryBuilders.boolQuery(); boolQuery.must().add(serviceIdBoolQuery); if (serviceIds.size() == 1) { - serviceIdBoolQuery.should().add(QueryBuilders.termQuery(ServiceRelationServerSideIndicator.SOURCE_SERVICE_ID, serviceIds.get(0))); - serviceIdBoolQuery.should().add(QueryBuilders.termQuery(ServiceRelationServerSideIndicator.DEST_SERVICE_ID, serviceIds.get(0))); + serviceIdBoolQuery.should().add(QueryBuilders.termQuery(ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, serviceIds.get(0))); + serviceIdBoolQuery.should().add(QueryBuilders.termQuery(ServiceRelationServerSideMetrics.DEST_SERVICE_ID, serviceIds.get(0))); } else { - serviceIdBoolQuery.should().add(QueryBuilders.termsQuery(ServiceRelationServerSideIndicator.SOURCE_SERVICE_ID, serviceIds)); - serviceIdBoolQuery.should().add(QueryBuilders.termsQuery(ServiceRelationServerSideIndicator.DEST_SERVICE_ID, serviceIds)); + serviceIdBoolQuery.should().add(QueryBuilders.termsQuery(ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, serviceIds)); + serviceIdBoolQuery.should().add(QueryBuilders.termsQuery(ServiceRelationServerSideMetrics.DEST_SERVICE_ID, serviceIds)); } sourceBuilder.query(boolQuery); } @Override public List loadServerSideServiceRelations(Step step, long startTB, long endTB) throws IOException { - String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationServerSideIndicator.INDEX_NAME); + String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationServerSideMetrics.INDEX_NAME); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); - sourceBuilder.query(QueryBuilders.rangeQuery(ServiceRelationServerSideIndicator.TIME_BUCKET).gte(startTB).lte(endTB)); + sourceBuilder.query(QueryBuilders.rangeQuery(ServiceRelationServerSideMetrics.TIME_BUCKET).gte(startTB).lte(endTB)); sourceBuilder.size(0); return load(sourceBuilder, indexName, DetectPoint.SERVER); } @Override public List loadClientSideServiceRelations(Step step, long startTB, long endTB) throws IOException { - String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationClientSideIndicator.INDEX_NAME); + String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationClientSideMetrics.INDEX_NAME); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); - sourceBuilder.query(QueryBuilders.rangeQuery(ServiceRelationServerSideIndicator.TIME_BUCKET).gte(startTB).lte(endTB)); + sourceBuilder.query(QueryBuilders.rangeQuery(ServiceRelationServerSideMetrics.TIME_BUCKET).gte(startTB).lte(endTB)); sourceBuilder.size(0); return load(sourceBuilder, indexName, DetectPoint.CLIENT); @@ -120,18 +120,18 @@ private void setQueryCondition(SearchSourceBuilder sourceBuilder, long startTB, @Override public List loadSpecifiedDestOfServerSideEndpointRelations(Step step, long startTB, long endTB, int destEndpointId) throws IOException { - String indexName = DownSamplingModelNameBuilder.build(step, EndpointRelationServerSideIndicator.INDEX_NAME); + String indexName = DownSamplingModelNameBuilder.build(step, EndpointRelationServerSideMetrics.INDEX_NAME); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); sourceBuilder.size(0); BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.rangeQuery(EndpointRelationServerSideIndicator.TIME_BUCKET).gte(startTB).lte(endTB)); + boolQuery.must().add(QueryBuilders.rangeQuery(EndpointRelationServerSideMetrics.TIME_BUCKET).gte(startTB).lte(endTB)); BoolQueryBuilder serviceIdBoolQuery = QueryBuilders.boolQuery(); boolQuery.must().add(serviceIdBoolQuery); - serviceIdBoolQuery.should().add(QueryBuilders.termQuery(EndpointRelationServerSideIndicator.SOURCE_ENDPOINT_ID, destEndpointId)); - serviceIdBoolQuery.should().add(QueryBuilders.termQuery(EndpointRelationServerSideIndicator.DEST_ENDPOINT_ID, destEndpointId)); + serviceIdBoolQuery.should().add(QueryBuilders.termQuery(EndpointRelationServerSideMetrics.SOURCE_ENDPOINT_ID, destEndpointId)); + serviceIdBoolQuery.should().add(QueryBuilders.termQuery(EndpointRelationServerSideMetrics.DEST_ENDPOINT_ID, destEndpointId)); sourceBuilder.query(boolQuery); @@ -140,12 +140,12 @@ public List loadSpecifiedDestOfServerSideEndpointRelations(Step step, long private List load(SearchSourceBuilder sourceBuilder, String indexName, DetectPoint detectPoint) throws IOException { - sourceBuilder.aggregation(AggregationBuilders.terms(Indicator.ENTITY_ID).field(Indicator.ENTITY_ID).size(1000)); + sourceBuilder.aggregation(AggregationBuilders.terms(Metrics.ENTITY_ID).field(Metrics.ENTITY_ID).size(1000)); SearchResponse response = getClient().search(indexName, sourceBuilder); List calls = new ArrayList<>(); - Terms entityTerms = response.getAggregations().get(Indicator.ENTITY_ID); + Terms entityTerms = response.getAggregations().get(Metrics.ENTITY_ID); for (Terms.Bucket entityBucket : entityTerms.getBuckets()) { String entityId = entityBucket.getKeyAsString(); diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java index fc8c16dd823e..e2135f51d025 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java @@ -34,7 +34,7 @@ import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ILogQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO; -import org.apache.skywalking.oap.server.core.storage.query.IMetricQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.IMetricsQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ITopNRecordsQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO; @@ -51,7 +51,7 @@ import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2HistoryDeleteDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2LogQueryDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetadataQueryDAO; -import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetricQueryDAO; +import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetricsQueryDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2NetworkAddressInventoryCacheDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2RegisterLockDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2RegisterLockInstaller; @@ -117,7 +117,7 @@ public H2StorageProvider() { this.registerServiceImplementation(INetworkAddressInventoryCacheDAO.class, new H2NetworkAddressInventoryCacheDAO(h2Client)); this.registerServiceImplementation(ITopologyQueryDAO.class, new H2TopologyQueryDAO(h2Client)); - this.registerServiceImplementation(IMetricQueryDAO.class, new H2MetricQueryDAO(h2Client)); + this.registerServiceImplementation(IMetricsQueryDAO.class, new H2MetricsQueryDAO(h2Client)); this.registerServiceImplementation(ITraceQueryDAO.class, new H2TraceQueryDAO(h2Client)); this.registerServiceImplementation(IMetadataQueryDAO.class, new H2MetadataQueryDAO(h2Client, config.getMetadataQueryMaxSize())); this.registerServiceImplementation(IAggregationQueryDAO.class, new H2AggregationQueryDAO(h2Client)); diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java index d87412b0f7ad..968c4b5a3cc0 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java @@ -24,7 +24,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.query.entity.Order; import org.apache.skywalking.oap.server.core.query.entity.Step; import org.apache.skywalking.oap.server.core.query.entity.TopNEntity; @@ -83,13 +83,13 @@ public List topNQuery(String indName, String valueCName, int topN, S String tableName = DownSamplingModelNameBuilder.build(step, indName); StringBuilder sql = new StringBuilder(); List conditions = new ArrayList<>(10); - sql.append("select * from (select avg(").append(valueCName).append(") value,").append(Indicator.ENTITY_ID).append(" from ") + sql.append("select * from (select avg(").append(valueCName).append(") value,").append(Metrics.ENTITY_ID).append(" from ") .append(tableName).append(" where "); this.setTimeRangeCondition(sql, conditions, startTB, endTB); if (appender != null) { appender.append(sql, conditions); } - sql.append(" group by ").append(Indicator.ENTITY_ID); + sql.append(" group by ").append(Metrics.ENTITY_ID); sql.append(") order by value ").append(order.equals(Order.ASC) ? "asc" : "desc").append(" limit ").append(topN); List topNEntities = new ArrayList<>(); @@ -99,7 +99,7 @@ public List topNQuery(String indName, String valueCName, int topN, S try { while (resultSet.next()) { TopNEntity topNEntity = new TopNEntity(); - topNEntity.setId(resultSet.getString(Indicator.ENTITY_ID)); + topNEntity.setId(resultSet.getString(Metrics.ENTITY_ID)); topNEntity.setValue(resultSet.getLong("value")); topNEntities.add(topNEntity); } @@ -119,7 +119,7 @@ public JDBCHikariCPClient getClient() { protected void setTimeRangeCondition(StringBuilder sql, List conditions, long startTimestamp, long endTimestamp) { - sql.append(Indicator.TIME_BUCKET).append(" >= ? and ").append(Indicator.TIME_BUCKET).append(" <= ?"); + sql.append(Metrics.TIME_BUCKET).append(" >= ? and ").append(Metrics.TIME_BUCKET).append(" <= ?"); conditions.add(startTimestamp); conditions.add(endTimestamp); } diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2IndicatorDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricsDAO.java similarity index 63% rename from oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2IndicatorDAO.java rename to oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricsDAO.java index 1d568ab6e1fe..412001702db7 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2IndicatorDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricsDAO.java @@ -19,8 +19,8 @@ package org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao; import java.io.IOException; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.storage.IIndicatorDAO; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.storage.IMetricsDAO; import org.apache.skywalking.oap.server.core.storage.StorageBuilder; import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient; import org.apache.skywalking.oap.server.storage.plugin.jdbc.SQLExecutor; @@ -28,24 +28,24 @@ /** * @author wusheng */ -public class H2IndicatorDAO extends H2SQLExecutor implements IIndicatorDAO { +public class H2MetricsDAO extends H2SQLExecutor implements IMetricsDAO { private JDBCHikariCPClient h2Client; - private StorageBuilder storageBuilder; + private StorageBuilder storageBuilder; - public H2IndicatorDAO(JDBCHikariCPClient h2Client, StorageBuilder storageBuilder) { + public H2MetricsDAO(JDBCHikariCPClient h2Client, StorageBuilder storageBuilder) { this.h2Client = h2Client; this.storageBuilder = storageBuilder; } - @Override public Indicator get(String modelName, Indicator indicator) throws IOException { - return (Indicator)getByID(h2Client, modelName, indicator.id(), storageBuilder); + @Override public Metrics get(String modelName, Metrics metrics) throws IOException { + return (Metrics)getByID(h2Client, modelName, metrics.id(), storageBuilder); } - @Override public SQLExecutor prepareBatchInsert(String modelName, Indicator indicator) throws IOException { - return getInsertExecutor(modelName, indicator, storageBuilder); + @Override public SQLExecutor prepareBatchInsert(String modelName, Metrics metrics) throws IOException { + return getInsertExecutor(modelName, metrics, storageBuilder); } - @Override public SQLExecutor prepareBatchUpdate(String modelName, Indicator indicator) throws IOException { - return getUpdateExecutor(modelName, indicator, storageBuilder); + @Override public SQLExecutor prepareBatchUpdate(String modelName, Metrics metrics) throws IOException { + return getUpdateExecutor(modelName, metrics, storageBuilder); } } diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricsQueryDAO.java similarity index 90% rename from oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricQueryDAO.java rename to oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricsQueryDAO.java index a61c6db97535..dc4c17d12c6c 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricQueryDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetricsQueryDAO.java @@ -26,10 +26,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValue; -import org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray; -import org.apache.skywalking.oap.server.core.analysis.indicator.ThermodynamicIndicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.query.entity.IntValues; import org.apache.skywalking.oap.server.core.query.entity.KVInt; import org.apache.skywalking.oap.server.core.query.entity.Step; @@ -38,16 +36,16 @@ import org.apache.skywalking.oap.server.core.query.sql.KeyValues; import org.apache.skywalking.oap.server.core.query.sql.Where; import org.apache.skywalking.oap.server.core.storage.DownSamplingModelNameBuilder; -import org.apache.skywalking.oap.server.core.storage.query.IMetricQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.IMetricsQueryDAO; import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient; /** * @author wusheng */ -public class H2MetricQueryDAO extends H2SQLExecutor implements IMetricQueryDAO { +public class H2MetricsQueryDAO extends H2SQLExecutor implements IMetricsQueryDAO { private JDBCHikariCPClient h2Client; - public H2MetricQueryDAO(JDBCHikariCPClient h2Client) { + public H2MetricsQueryDAO(JDBCHikariCPClient h2Client) { this.h2Client = h2Client; } @@ -92,10 +90,10 @@ public IntValues getValues(String indName, Step step, long startTB, long endTB, IntValues intValues = new IntValues(); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, "select " + Indicator.ENTITY_ID + " id, " + op + "(" + valueCName + ") value from " + tableName + try (ResultSet resultSet = h2Client.executeQuery(connection, "select " + Metrics.ENTITY_ID + " id, " + op + "(" + valueCName + ") value from " + tableName + " where " + whereSql - + Indicator.TIME_BUCKET + ">= ? and " + Indicator.TIME_BUCKET + "<=?" - + " group by " + Indicator.ENTITY_ID, + + Metrics.TIME_BUCKET + ">= ? and " + Metrics.TIME_BUCKET + "<=?" + + " group by " + Metrics.ENTITY_ID, startTB, endTB)) { while (resultSet.next()) { @@ -179,9 +177,9 @@ private IntValues orderWithDefault0(IntValues origin, List expectedOrder Thermodynamic thermodynamic = new Thermodynamic(); int numOfSteps = 0; int axisYStep = 0; - try (ResultSet resultSet = h2Client.executeQuery(connection, "select " + ThermodynamicIndicator.STEP + " step, " - + ThermodynamicIndicator.NUM_OF_STEPS + " num_of_steps, " - + ThermodynamicIndicator.DETAIL_GROUP + " detail_group, " + try (ResultSet resultSet = h2Client.executeQuery(connection, "select " + ThermodynamicMetrics.STEP + " step, " + + ThermodynamicMetrics.NUM_OF_STEPS + " num_of_steps, " + + ThermodynamicMetrics.DETAIL_GROUP + " detail_group, " + "id " + " from " + tableName + " where id in (" + idValues.toString() + ")")) { diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2SQLExecutor.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2SQLExecutor.java index 6de21ddbcd25..21d3d3c26f93 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2SQLExecutor.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2SQLExecutor.java @@ -100,15 +100,15 @@ protected int getEntityIDByID(JDBCHikariCPClient h2Client, String entityColumnNa return Const.NONE; } - protected SQLExecutor getInsertExecutor(String modelName, StorageData indicator, + protected SQLExecutor getInsertExecutor(String modelName, StorageData metrics, StorageBuilder storageBuilder) throws IOException { - Map objectMap = storageBuilder.data2Map(indicator); + Map objectMap = storageBuilder.data2Map(metrics); SQLBuilder sqlBuilder = new SQLBuilder("INSERT INTO " + modelName + " VALUES"); List columns = TableMetaInfo.get(modelName).getColumns(); List param = new ArrayList<>(); sqlBuilder.append("(?,"); - param.add(indicator.id()); + param.add(metrics.id()); for (int i = 0; i < columns.size(); i++) { ModelColumn column = columns.get(i); sqlBuilder.append("?"); @@ -128,9 +128,9 @@ protected SQLExecutor getInsertExecutor(String modelName, StorageData indicator, return new SQLExecutor(sqlBuilder.toString(), param); } - protected SQLExecutor getUpdateExecutor(String modelName, StorageData indicator, + protected SQLExecutor getUpdateExecutor(String modelName, StorageData metrics, StorageBuilder storageBuilder) throws IOException { - Map objectMap = storageBuilder.data2Map(indicator); + Map objectMap = storageBuilder.data2Map(metrics); SQLBuilder sqlBuilder = new SQLBuilder("UPDATE " + modelName + " SET "); List columns = TableMetaInfo.get(modelName).getColumns(); @@ -150,7 +150,7 @@ protected SQLExecutor getUpdateExecutor(String modelName, StorageData indicator, } } sqlBuilder.append(" WHERE id = ?"); - param.add(indicator.id()); + param.add(metrics.id()); return new SQLExecutor(sqlBuilder.toString(), param); } diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2StorageDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2StorageDAO.java index 05d31764f294..d23001dee075 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2StorageDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2StorageDAO.java @@ -18,10 +18,10 @@ package org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.analysis.record.Record; import org.apache.skywalking.oap.server.core.register.RegisterSource; -import org.apache.skywalking.oap.server.core.storage.IIndicatorDAO; +import org.apache.skywalking.oap.server.core.storage.IMetricsDAO; import org.apache.skywalking.oap.server.core.storage.IRecordDAO; import org.apache.skywalking.oap.server.core.storage.IRegisterDAO; import org.apache.skywalking.oap.server.core.storage.StorageBuilder; @@ -38,8 +38,8 @@ public H2StorageDAO(JDBCHikariCPClient h2Client) { this.h2Client = h2Client; } - @Override public IIndicatorDAO newIndicatorDao(StorageBuilder storageBuilder) { - return new H2IndicatorDAO(h2Client, storageBuilder); + @Override public IMetricsDAO newMetricsDao(StorageBuilder storageBuilder) { + return new H2MetricsDAO(h2Client, storageBuilder); } @Override public IRegisterDAO newRegisterDao(StorageBuilder storageBuilder) { diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TableInstaller.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TableInstaller.java index 946ae03872c2..e2336f056c33 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TableInstaller.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TableInstaller.java @@ -21,7 +21,7 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; -import org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray; +import org.apache.skywalking.oap.server.core.analysis.metrics.IntKeyLongValueArray; import org.apache.skywalking.oap.server.core.storage.StorageException; import org.apache.skywalking.oap.server.core.storage.model.ColumnName; import org.apache.skywalking.oap.server.core.storage.model.Model; diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java index 4b527eca6382..653c74ebd893 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java @@ -24,10 +24,10 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; -import org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation.EndpointRelationServerSideIndicator; -import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.ServiceRelationClientSideIndicator; -import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.ServiceRelationServerSideIndicator; +import org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation.EndpointRelationServerSideMetrics; +import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.*; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.ServiceRelationServerSideMetrics; import org.apache.skywalking.oap.server.core.query.entity.Call; import org.apache.skywalking.oap.server.core.query.entity.Step; import org.apache.skywalking.oap.server.core.source.DetectPoint; @@ -48,32 +48,32 @@ public H2TopologyQueryDAO(JDBCHikariCPClient h2Client) { @Override public List loadSpecifiedServerSideServiceRelations(Step step, long startTB, long endTB, List serviceIds) throws IOException { - String tableName = DownSamplingModelNameBuilder.build(step, ServiceRelationServerSideIndicator.INDEX_NAME); - return loadServiceCalls(tableName, startTB, endTB, ServiceRelationServerSideIndicator.SOURCE_SERVICE_ID, ServiceRelationServerSideIndicator.DEST_SERVICE_ID, serviceIds, true); + String tableName = DownSamplingModelNameBuilder.build(step, ServiceRelationServerSideMetrics.INDEX_NAME); + return loadServiceCalls(tableName, startTB, endTB, ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, ServiceRelationServerSideMetrics.DEST_SERVICE_ID, serviceIds, true); } @Override public List loadSpecifiedClientSideServiceRelations(Step step, long startTB, long endTB, List serviceIds) throws IOException { - String tableName = DownSamplingModelNameBuilder.build(step, ServiceRelationClientSideIndicator.INDEX_NAME); - return loadServiceCalls(tableName, startTB, endTB, ServiceRelationServerSideIndicator.SOURCE_SERVICE_ID, ServiceRelationServerSideIndicator.DEST_SERVICE_ID, serviceIds, false); + String tableName = DownSamplingModelNameBuilder.build(step, ServiceRelationClientSideMetrics.INDEX_NAME); + return loadServiceCalls(tableName, startTB, endTB, ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, ServiceRelationServerSideMetrics.DEST_SERVICE_ID, serviceIds, false); } @Override public List loadServerSideServiceRelations(Step step, long startTB, long endTB) throws IOException { - String tableName = DownSamplingModelNameBuilder.build(step, ServiceRelationServerSideIndicator.INDEX_NAME); - return loadServiceCalls(tableName, startTB, endTB, ServiceRelationServerSideIndicator.SOURCE_SERVICE_ID, ServiceRelationServerSideIndicator.DEST_SERVICE_ID, new ArrayList<>(0), false); + String tableName = DownSamplingModelNameBuilder.build(step, ServiceRelationServerSideMetrics.INDEX_NAME); + return loadServiceCalls(tableName, startTB, endTB, ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, ServiceRelationServerSideMetrics.DEST_SERVICE_ID, new ArrayList<>(0), false); } @Override public List loadClientSideServiceRelations(Step step, long startTB, long endTB) throws IOException { - String tableName = DownSamplingModelNameBuilder.build(step, ServiceRelationClientSideIndicator.INDEX_NAME); - return loadServiceCalls(tableName, startTB, endTB, ServiceRelationServerSideIndicator.SOURCE_SERVICE_ID, ServiceRelationServerSideIndicator.DEST_SERVICE_ID, new ArrayList<>(0), true); + String tableName = DownSamplingModelNameBuilder.build(step, ServiceRelationClientSideMetrics.INDEX_NAME); + return loadServiceCalls(tableName, startTB, endTB, ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, ServiceRelationServerSideMetrics.DEST_SERVICE_ID, new ArrayList<>(0), true); } @Override public List loadSpecifiedDestOfServerSideEndpointRelations(Step step, long startTB, long endTB, int destEndpointId) throws IOException { - String tableName = DownSamplingModelNameBuilder.build(step, EndpointRelationServerSideIndicator.INDEX_NAME); + String tableName = DownSamplingModelNameBuilder.build(step, EndpointRelationServerSideMetrics.INDEX_NAME); - List calls = loadEndpointFromSide(tableName, startTB, endTB, EndpointRelationServerSideIndicator.SOURCE_ENDPOINT_ID, EndpointRelationServerSideIndicator.DEST_ENDPOINT_ID, destEndpointId, false); - calls.addAll(loadEndpointFromSide(tableName, startTB, endTB, EndpointRelationServerSideIndicator.SOURCE_ENDPOINT_ID, EndpointRelationServerSideIndicator.DEST_ENDPOINT_ID, destEndpointId, true)); + List calls = loadEndpointFromSide(tableName, startTB, endTB, EndpointRelationServerSideMetrics.SOURCE_ENDPOINT_ID, EndpointRelationServerSideMetrics.DEST_ENDPOINT_ID, destEndpointId, false); + calls.addAll(loadEndpointFromSide(tableName, startTB, endTB, EndpointRelationServerSideMetrics.SOURCE_ENDPOINT_ID, EndpointRelationServerSideMetrics.DEST_ENDPOINT_ID, destEndpointId, true)); return calls; } @@ -98,11 +98,11 @@ private List loadServiceCalls(String tableName, long startTB, long endTB, List calls = new ArrayList<>(); try (Connection connection = h2Client.getConnection()) { try (ResultSet resultSet = h2Client.executeQuery(connection, "select " - + Indicator.ENTITY_ID + + Metrics.ENTITY_ID + " from " + tableName + " where " - + Indicator.TIME_BUCKET + ">= ? and " + Indicator.TIME_BUCKET + "<=? " + + Metrics.TIME_BUCKET + ">= ? and " + Metrics.TIME_BUCKET + "<=? " + serviceIdMatchSql.toString() - + " group by " + Indicator.ENTITY_ID, + + " group by " + Metrics.ENTITY_ID, conditions)) { buildCalls(resultSet, calls, isClientSide); } @@ -121,11 +121,11 @@ private List loadEndpointFromSide(String tableName, long startTB, long end List calls = new ArrayList<>(); try (Connection connection = h2Client.getConnection()) { try (ResultSet resultSet = h2Client.executeQuery(connection, "select " - + Indicator.ENTITY_ID + + Metrics.ENTITY_ID + " from " + tableName + " where " - + Indicator.TIME_BUCKET + ">= ? and " + Indicator.TIME_BUCKET + "<=? and " + + Metrics.TIME_BUCKET + ">= ? and " + Metrics.TIME_BUCKET + "<=? and " + (isSourceId ? sourceCName : destCName) + "=?" - + " group by " + Indicator.ENTITY_ID, + + " group by " + Metrics.ENTITY_ID, conditions)) { buildCalls(resultSet, calls, isSourceId); } @@ -138,7 +138,7 @@ private List loadEndpointFromSide(String tableName, long startTB, long end private void buildCalls(ResultSet resultSet, List calls, boolean isClientSide) throws SQLException { while (resultSet.next()) { Call call = new Call(); - String entityId = resultSet.getString(Indicator.ENTITY_ID); + String entityId = resultSet.getString(Metrics.ENTITY_ID); Integer[] entityIds = ServiceRelation.splitEntityId(entityId); call.setSource(entityIds[0]); diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLAggregationQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLAggregationQueryDAO.java index f6e86fc8c8db..a2b8a341e450 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLAggregationQueryDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLAggregationQueryDAO.java @@ -24,7 +24,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.query.entity.Order; import org.apache.skywalking.oap.server.core.query.entity.Step; import org.apache.skywalking.oap.server.core.query.entity.TopNEntity; @@ -47,14 +47,14 @@ public List topNQuery(String indName, String valueCName, int topN, S String tableName = DownSamplingModelNameBuilder.build(step, indName); StringBuilder sql = new StringBuilder(); List conditions = new ArrayList<>(10); - sql.append("select * from (select avg(").append(valueCName).append(") value,").append(Indicator.ENTITY_ID).append(" from ") + sql.append("select * from (select avg(").append(valueCName).append(") value,").append(Metrics.ENTITY_ID).append(" from ") .append(tableName).append(" where "); this.setTimeRangeCondition(sql, conditions, startTB, endTB); if (appender != null) { appender.append(sql, conditions); } - sql.append(" group by ").append(Indicator.ENTITY_ID); - sql.append(") AS INDICATOR order by value ").append(order.equals(Order.ASC) ? "asc" : "desc").append(" limit ").append(topN); + sql.append(" group by ").append(Metrics.ENTITY_ID); + sql.append(") AS METRICS order by value ").append(order.equals(Order.ASC) ? "asc" : "desc").append(" limit ").append(topN); List topNEntities = new ArrayList<>(); try (Connection connection = getClient().getConnection()) { @@ -63,7 +63,7 @@ public List topNQuery(String indName, String valueCName, int topN, S try { while (resultSet.next()) { TopNEntity topNEntity = new TopNEntity(); - topNEntity.setId(resultSet.getString(Indicator.ENTITY_ID)); + topNEntity.setId(resultSet.getString(Metrics.ENTITY_ID)); topNEntity.setValue(resultSet.getLong("value")); topNEntities.add(topNEntity); } diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java index 3b9e256fa6ce..f780f4cf49bd 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java @@ -35,7 +35,7 @@ import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ILogQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO; -import org.apache.skywalking.oap.server.core.storage.query.IMetricQueryDAO; +import org.apache.skywalking.oap.server.core.storage.query.IMetricsQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ITopNRecordsQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO; import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO; @@ -52,7 +52,7 @@ import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2EndpointInventoryCacheDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2HistoryDeleteDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetadataQueryDAO; -import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetricQueryDAO; +import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetricsQueryDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2NetworkAddressInventoryCacheDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2RegisterLockDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2RegisterLockInstaller; @@ -119,7 +119,7 @@ public MySQLStorageProvider() { this.registerServiceImplementation(INetworkAddressInventoryCacheDAO.class, new H2NetworkAddressInventoryCacheDAO(mysqlClient)); this.registerServiceImplementation(ITopologyQueryDAO.class, new H2TopologyQueryDAO(mysqlClient)); - this.registerServiceImplementation(IMetricQueryDAO.class, new H2MetricQueryDAO(mysqlClient)); + this.registerServiceImplementation(IMetricsQueryDAO.class, new H2MetricsQueryDAO(mysqlClient)); this.registerServiceImplementation(ITraceQueryDAO.class, new MySQLTraceQueryDAO(mysqlClient)); this.registerServiceImplementation(IMetadataQueryDAO.class, new H2MetadataQueryDAO(mysqlClient, config.getMetadataQueryMaxSize())); this.registerServiceImplementation(IAggregationQueryDAO.class, new MySQLAggregationQueryDAO(mysqlClient)); diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java index a54216eac582..58483284caa7 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java @@ -20,7 +20,7 @@ import java.sql.Connection; import java.sql.SQLException; -import org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray; +import org.apache.skywalking.oap.server.core.analysis.metrics.IntKeyLongValueArray; import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord; import org.apache.skywalking.oap.server.core.register.RegisterSource; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; @@ -108,12 +108,12 @@ protected void createIndexes(JDBCHikariCPClient client, Model model) throws Stor createAlarmIndexes(client, model); return; default: - createIndexesForAllIndicators(client, model); + createIndexesForAllMetrics(client, model); } } - private void createIndexesForAllIndicators(JDBCHikariCPClient client, Model model) throws StorageException { + private void createIndexesForAllMetrics(JDBCHikariCPClient client, Model model) throws StorageException { try (Connection connection = client.getConnection()) { SQLBuilder tableIndexSQL = new SQLBuilder("CREATE INDEX "); tableIndexSQL.append(model.getName().toUpperCase()).append("_TIME_BUCKET "); diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/TelemetryModule.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/TelemetryModule.java index f0f51c9601b1..78cdce45b6a7 100644 --- a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/TelemetryModule.java +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/TelemetryModule.java @@ -19,7 +19,7 @@ package org.apache.skywalking.oap.server.telemetry; import org.apache.skywalking.oap.server.library.module.ModuleDefine; -import org.apache.skywalking.oap.server.telemetry.api.MetricCreator; +import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator; /** * Telemetry module definition @@ -34,6 +34,6 @@ public TelemetryModule() { } @Override public Class[] services() { - return new Class[] {MetricCreator.class}; + return new Class[] {MetricsCreator.class}; } } diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/CounterMetric.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/CounterMetrics.java similarity index 89% rename from oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/CounterMetric.java rename to oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/CounterMetrics.java index 3cd47fd673b3..870c46f268a1 100644 --- a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/CounterMetric.java +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/CounterMetrics.java @@ -19,13 +19,13 @@ package org.apache.skywalking.oap.server.telemetry.api; /** - * A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only + * A counter is a cumulative metrics that represents a single monotonically increasing counter whose value can only * increase or be reset to zero on restart. For example, you can use a counter to represent the number of requests * served, tasks completed, or errors.z * * @author wusheng */ -public interface CounterMetric { +public interface CounterMetrics { /** * Increase 1 to counter */ diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/GaugeMetric.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/GaugeMetrics.java similarity index 91% rename from oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/GaugeMetric.java rename to oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/GaugeMetrics.java index 8a3cf45850c2..ce070bb6f0f4 100644 --- a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/GaugeMetric.java +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/GaugeMetrics.java @@ -19,11 +19,11 @@ package org.apache.skywalking.oap.server.telemetry.api; /** - * A gauge is a metric that represents a single numerical value that can arbitrarily go up and down. + * A gauge is a metrics that represents a single numerical value that can arbitrarily go up and down. * * @author wusheng */ -public interface GaugeMetric { +public interface GaugeMetrics { /** * Increase 1 to gauge */ diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/HistogramMetric.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/HistogramMetrics.java similarity index 89% rename from oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/HistogramMetric.java rename to oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/HistogramMetrics.java index f5670e485c09..41e73da2079d 100644 --- a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/HistogramMetric.java +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/HistogramMetrics.java @@ -26,7 +26,7 @@ * * @author wusheng */ -public abstract class HistogramMetric { +public abstract class HistogramMetrics { public Timer createTimer() { return new Timer(this); } @@ -39,19 +39,19 @@ public Timer createTimer() { public abstract void observe(double value); public class Timer implements Closeable { - private final HistogramMetric metric; + private final HistogramMetrics metrics; private final long startNanos; private double duration; - public Timer(HistogramMetric metric) { - this.metric = metric; + public Timer(HistogramMetrics metrics) { + this.metrics = metrics; startNanos = System.nanoTime(); } public void finish() { long endNanos = System.nanoTime(); duration = (double)(endNanos - startNanos) / 1.0E9D; - metric.observe(duration); + metrics.observe(duration); } @Override diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricCreator.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricsCreator.java similarity index 66% rename from oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricCreator.java rename to oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricsCreator.java index 8dcb8cd223e2..60c19f6fc579 100644 --- a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricCreator.java +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricsCreator.java @@ -21,34 +21,34 @@ import org.apache.skywalking.oap.server.library.module.Service; /** - * Open API to telemetry module, allow to create metric instance with different type. Types inherits from prometheus + * Open API to telemetry module, allow to create metrics instance with different type. Types inherits from prometheus * project, and plan to move to openmetrics APIs after it is ready. * * @author wusheng */ -public interface MetricCreator extends Service { +public interface MetricsCreator extends Service { /** - * Create a counter type metric instance. + * Create a counter type metrics instance. * * @param name * @param tips * @param tagKeys * @return */ - CounterMetric createCounter(String name, String tips, MetricTag.Keys tagKeys, MetricTag.Values tagValues); + CounterMetrics createCounter(String name, String tips, MetricsTag.Keys tagKeys, MetricsTag.Values tagValues); /** - * Create a gauge type metric instance. + * Create a gauge type metrics instance. * * @param name * @param tips * @param tagKeys * @return */ - GaugeMetric createGauge(String name, String tips, MetricTag.Keys tagKeys, MetricTag.Values tagValues); + GaugeMetrics createGauge(String name, String tips, MetricsTag.Keys tagKeys, MetricsTag.Values tagValues); /** - * Create a Histogram type metric instance. + * Create a Histogram type metrics instance. * * @param name * @param tips @@ -56,5 +56,5 @@ public interface MetricCreator extends Service { * @param buckets Time bucket for duration. * @return */ - HistogramMetric createHistogramMetric(String name, String tips, MetricTag.Keys tagKeys, MetricTag.Values tagValues, double... buckets); + HistogramMetrics createHistogramMetric(String name, String tips, MetricsTag.Keys tagKeys, MetricsTag.Values tagValues, double... buckets); } diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricTag.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricsTag.java similarity index 96% rename from oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricTag.java rename to oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricsTag.java index 1e8beb6d329c..f9542ba62c92 100644 --- a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricTag.java +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/MetricsTag.java @@ -19,11 +19,11 @@ package org.apache.skywalking.oap.server.telemetry.api; /** - * Tag for the target metric. + * Tag for the target metrics. * * The tag values should be set in putting value phase. */ -public class MetricTag { +public class MetricsTag { public static final Keys EMPTY_KEY = new Keys(); public static final Values EMPTY_VALUE = new Values(); diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TelemetryRelatedContext.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TelemetryRelatedContext.java index 0ed338a8eddd..3bceccab2970 100644 --- a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TelemetryRelatedContext.java +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/api/TelemetryRelatedContext.java @@ -19,7 +19,7 @@ package org.apache.skywalking.oap.server.telemetry.api; /** - * The telemetry context which the metric instances may need to know. + * The telemetry context which the metrics instances may need to know. * @author wusheng */ public enum TelemetryRelatedContext { diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/MetricCreatorNoop.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/MetricsCreatorNoop.java similarity index 71% rename from oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/MetricCreatorNoop.java rename to oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/MetricsCreatorNoop.java index 10d3ba2a691e..90b022854f82 100644 --- a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/MetricCreatorNoop.java +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/MetricsCreatorNoop.java @@ -21,14 +21,14 @@ import org.apache.skywalking.oap.server.telemetry.api.*; /** - * A no-op metric create, just create nut shell metric instance. + * A no-op metrics create, just create nut shell metrics instance. * * @author wusheng */ -public class MetricCreatorNoop implements MetricCreator { +public class MetricsCreatorNoop implements MetricsCreator { @Override - public CounterMetric createCounter(String name, String tips, MetricTag.Keys tagKeys, MetricTag.Values tagValues) { - return new CounterMetric() { + public CounterMetrics createCounter(String name, String tips, MetricsTag.Keys tagKeys, MetricsTag.Values tagValues) { + return new CounterMetrics() { @Override public void inc() { } @@ -40,8 +40,8 @@ public CounterMetric createCounter(String name, String tips, MetricTag.Keys tagK } @Override - public GaugeMetric createGauge(String name, String tips, MetricTag.Keys tagKeys, MetricTag.Values tagValues) { - return new GaugeMetric() { + public GaugeMetrics createGauge(String name, String tips, MetricsTag.Keys tagKeys, MetricsTag.Values tagValues) { + return new GaugeMetrics() { @Override public void inc() { } @@ -65,9 +65,9 @@ public GaugeMetric createGauge(String name, String tips, MetricTag.Keys tagKeys, } @Override - public HistogramMetric createHistogramMetric(String name, String tips, MetricTag.Keys tagKeys, - MetricTag.Values tagValues, double... buckets) { - return new HistogramMetric() { + public HistogramMetrics createHistogramMetric(String name, String tips, MetricsTag.Keys tagKeys, + MetricsTag.Values tagValues, double... buckets) { + return new HistogramMetrics() { @Override public void observe(double value) { } diff --git a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/NoneTelemetryProvider.java b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/NoneTelemetryProvider.java index 2fd8123fb2cf..25db52b49ef2 100644 --- a/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/NoneTelemetryProvider.java +++ b/oap-server/server-telemetry/telemetry-api/src/main/java/org/apache/skywalking/oap/server/telemetry/none/NoneTelemetryProvider.java @@ -20,7 +20,7 @@ import org.apache.skywalking.oap.server.library.module.*; import org.apache.skywalking.oap.server.telemetry.TelemetryModule; -import org.apache.skywalking.oap.server.telemetry.api.MetricCreator; +import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator; /** * A nutshell telemetry implementor. @@ -42,7 +42,7 @@ public class NoneTelemetryProvider extends ModuleProvider { } @Override public void prepare() throws ServiceNotProvidedException, ModuleStartException { - this.registerServiceImplementation(MetricCreator.class, new MetricCreatorNoop()); + this.registerServiceImplementation(MetricsCreator.class, new MetricsCreatorNoop()); } @Override public void start() throws ServiceNotProvidedException, ModuleStartException { diff --git a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/BaseMetric.java b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/BaseMetrics.java similarity index 82% rename from oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/BaseMetric.java rename to oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/BaseMetrics.java index e7d6a0024881..92435cfabd8a 100644 --- a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/BaseMetric.java +++ b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/BaseMetrics.java @@ -24,22 +24,22 @@ import org.apache.skywalking.oap.server.telemetry.api.*; /** - * BaseMetric parent class represents the me + * BaseMetrics parent class represents the me * * @author wusheng */ -public abstract class BaseMetric { +public abstract class BaseMetrics { private static Map ALL_METRICS = new HashMap<>(); - private volatile C metricInstance; + private volatile C metricsInstance; protected final String name; protected final String tips; - protected final MetricTag.Keys labels; - protected final MetricTag.Values values; + protected final MetricsTag.Keys labels; + protected final MetricsTag.Values values; private ReentrantLock lock = new ReentrantLock(); - public BaseMetric(String name, String tips, MetricTag.Keys labels, - MetricTag.Values values) { + public BaseMetrics(String name, String tips, MetricsTag.Keys labels, + MetricsTag.Values values) { this.name = name; this.tips = tips; this.labels = labels; @@ -51,11 +51,11 @@ protected boolean isIDReady() { } protected C getMetric() { - if (metricInstance == null) { + if (metricsInstance == null) { if (isIDReady()) { lock.lock(); try { - if (metricInstance == null) { + if (metricsInstance == null) { String[] labelNames = new String[labels.getKeys().length + 1]; labelNames[0] = "sw_backend_instance"; for (int i = 0; i < labels.getKeys().length; i++) { @@ -76,9 +76,9 @@ protected C getMetric() { } } - T metric = (T)ALL_METRICS.get(name); + T metrics = (T)ALL_METRICS.get(name); - metricInstance = (C)metric.labels(labelValues); + metricsInstance = (C)metrics.labels(labelValues); } } finally { lock.unlock(); @@ -86,7 +86,7 @@ protected C getMetric() { } } - return metricInstance; + return metricsInstance; } protected abstract T create(String[] labelNames); diff --git a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusCounterMetric.java b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusCounterMetrics.java similarity index 72% rename from oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusCounterMetric.java rename to oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusCounterMetrics.java index cae0edb0c61e..4b6284da4bde 100644 --- a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusCounterMetric.java +++ b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusCounterMetrics.java @@ -22,28 +22,28 @@ import org.apache.skywalking.oap.server.telemetry.api.*; /** - * Counter metric in Prometheus implementor. + * Counter metrics in Prometheus implementor. * * @author wusheng */ -public class PrometheusCounterMetric extends BaseMetric implements CounterMetric { +public class PrometheusCounterMetrics extends BaseMetrics implements CounterMetrics { - public PrometheusCounterMetric(String name, String tips, - MetricTag.Keys labels, MetricTag.Values values) { + public PrometheusCounterMetrics(String name, String tips, + MetricsTag.Keys labels, MetricsTag.Values values) { super(name, tips, labels, values); } @Override public void inc() { - Counter.Child metric = this.getMetric(); - if (metric != null) { - metric.inc(); + Counter.Child metrics = this.getMetric(); + if (metrics != null) { + metrics.inc(); } } @Override public void inc(double value) { - Counter.Child metric = this.getMetric(); - if (metric != null) { - metric.inc(value); + Counter.Child metrics = this.getMetric(); + if (metrics != null) { + metrics.inc(value); } } diff --git a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusGaugeMetric.java b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusGaugeMetrics.java similarity index 64% rename from oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusGaugeMetric.java rename to oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusGaugeMetrics.java index c65172572811..0f4aea36c4c0 100644 --- a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusGaugeMetric.java +++ b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusGaugeMetrics.java @@ -22,49 +22,49 @@ import org.apache.skywalking.oap.server.telemetry.api.*; /** - * Gauge metric in Prometheus implementor. + * Gauge metrics in Prometheus implementor. * * @author wusheng */ -public class PrometheusGaugeMetric extends BaseMetric implements GaugeMetric { - public PrometheusGaugeMetric(String name, String tips, - MetricTag.Keys labels, - MetricTag.Values values) { +public class PrometheusGaugeMetrics extends BaseMetrics implements GaugeMetrics { + public PrometheusGaugeMetrics(String name, String tips, + MetricsTag.Keys labels, + MetricsTag.Values values) { super(name, tips, labels, values); } @Override public void inc() { - Gauge.Child metric = this.getMetric(); - if (metric != null) { - metric.inc(); + Gauge.Child metrics = this.getMetric(); + if (metrics != null) { + metrics.inc(); } } @Override public void inc(double value) { - Gauge.Child metric = this.getMetric(); - if (metric != null) { - metric.inc(value); + Gauge.Child metrics = this.getMetric(); + if (metrics != null) { + metrics.inc(value); } } @Override public void dec() { - Gauge.Child metric = this.getMetric(); - if (metric != null) { - metric.dec(); + Gauge.Child metrics = this.getMetric(); + if (metrics != null) { + metrics.dec(); } } @Override public void dec(double value) { - Gauge.Child metric = this.getMetric(); - if (metric != null) { - metric.dec(value); + Gauge.Child metrics = this.getMetric(); + if (metrics != null) { + metrics.dec(value); } } @Override public void setValue(double value) { - Gauge.Child metric = this.getMetric(); - if (metric != null) { - metric.set(value); + Gauge.Child metrics = this.getMetric(); + if (metrics != null) { + metrics.set(value); } } diff --git a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusHistogramMetric.java b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusHistogramMetrics.java similarity index 76% rename from oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusHistogramMetric.java rename to oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusHistogramMetrics.java index a2ad2ecb3d60..ea4294bb67ba 100644 --- a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusHistogramMetric.java +++ b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusHistogramMetrics.java @@ -22,30 +22,30 @@ import org.apache.skywalking.oap.server.telemetry.api.*; /** - * HistogramMetric metric in Prometheus implementor. + * HistogramMetrics metrics in Prometheus implementor. * * @author wusheng */ -public class PrometheusHistogramMetric extends HistogramMetric { +public class PrometheusHistogramMetrics extends HistogramMetrics { private InnerMetricObject inner; private final double[] buckets; - public PrometheusHistogramMetric(String name, String tips, MetricTag.Keys labels, - MetricTag.Values values, double... buckets) { + public PrometheusHistogramMetrics(String name, String tips, MetricsTag.Keys labels, + MetricsTag.Values values, double... buckets) { inner = new InnerMetricObject(name, tips, labels, values); this.buckets = buckets; } @Override public void observe(double value) { - Histogram.Child metric = inner.getMetric(); - if (metric != null) { - metric.observe(value); + Histogram.Child metrics = inner.getMetric(); + if (metrics != null) { + metrics.observe(value); } } - class InnerMetricObject extends BaseMetric { - public InnerMetricObject(String name, String tips, MetricTag.Keys labels, - MetricTag.Values values) { + class InnerMetricObject extends BaseMetrics { + public InnerMetricObject(String name, String tips, MetricsTag.Keys labels, + MetricsTag.Values values) { super(name, tips, labels, values); } diff --git a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusMetricCreator.java b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusMetricsCreator.java similarity index 57% rename from oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusMetricCreator.java rename to oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusMetricsCreator.java index 966a9ce25961..592103c2be2b 100644 --- a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusMetricCreator.java +++ b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusMetricsCreator.java @@ -21,24 +21,24 @@ import org.apache.skywalking.oap.server.telemetry.api.*; /** - * Create metric instance for Prometheus exporter. + * Create metrics instance for Prometheus exporter. * * @author wusheng */ -public class PrometheusMetricCreator implements MetricCreator { +public class PrometheusMetricsCreator implements MetricsCreator { @Override - public CounterMetric createCounter(String name, String tips, MetricTag.Keys tagKeys, MetricTag.Values tagValues) { - return new PrometheusCounterMetric(name, tips, tagKeys, tagValues); + public CounterMetrics createCounter(String name, String tips, MetricsTag.Keys tagKeys, MetricsTag.Values tagValues) { + return new PrometheusCounterMetrics(name, tips, tagKeys, tagValues); } @Override - public GaugeMetric createGauge(String name, String tips, MetricTag.Keys tagKeys, MetricTag.Values tagValues) { - return new PrometheusGaugeMetric(name, tips, tagKeys, tagValues); + public GaugeMetrics createGauge(String name, String tips, MetricsTag.Keys tagKeys, MetricsTag.Values tagValues) { + return new PrometheusGaugeMetrics(name, tips, tagKeys, tagValues); } @Override - public HistogramMetric createHistogramMetric(String name, String tips, MetricTag.Keys tagKeys, - MetricTag.Values tagValues, double... buckets) { - return new PrometheusHistogramMetric(name, tips, tagKeys, tagValues, buckets); + public HistogramMetrics createHistogramMetric(String name, String tips, MetricsTag.Keys tagKeys, + MetricsTag.Values tagValues, double... buckets) { + return new PrometheusHistogramMetrics(name, tips, tagKeys, tagValues, buckets); } } diff --git a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusTelemetryProvider.java b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusTelemetryProvider.java index da9b643fbfbb..da9433818b4b 100644 --- a/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusTelemetryProvider.java +++ b/oap-server/server-telemetry/telemetry-prometheus/src/main/java/org/apache/skywalking/oap/server/telemetry/prometheus/PrometheusTelemetryProvider.java @@ -23,7 +23,7 @@ import java.io.IOException; import org.apache.skywalking.oap.server.library.module.*; import org.apache.skywalking.oap.server.telemetry.TelemetryModule; -import org.apache.skywalking.oap.server.telemetry.api.MetricCreator; +import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator; /** * Start the Prometheus @@ -50,7 +50,7 @@ public PrometheusTelemetryProvider() { } @Override public void prepare() throws ServiceNotProvidedException, ModuleStartException { - this.registerServiceImplementation(MetricCreator.class, new PrometheusMetricCreator()); + this.registerServiceImplementation(MetricsCreator.class, new PrometheusMetricsCreator()); try { new HTTPServer(config.getHost(), config.getPort()); } catch (IOException e) { From dd9d178cb31165a5a1192ccc78fa3fea9de1f6e1 Mon Sep 17 00:00:00 2001 From: caoyixiong <32847163+IanCao@users.noreply.github.com> Date: Fri, 10 May 2019 11:14:39 +0800 Subject: [PATCH 17/24] Support span#error in toolkit (#2605) * Fix #2546 --- .../apm/toolkit/trace/ActiveSpan.java | 16 +- .../trace/ActiveSpanActivation.java | 154 +++++++++++++++ .../trace/ActiveSpanDebugInterceptor.java | 58 ++++++ .../trace/ActiveSpanErrorInterceptor.java | 53 +++++ .../trace/ActiveSpanErrorMsgInterceptor.java | 59 ++++++ .../ActiveSpanErrorThrowableInteceptor.java | 53 +++++ .../trace/ActiveSpanInfoInterceptor.java | 58 ++++++ .../trace/ActiveSpanTagActivation.java | 69 ------- .../src/main/resources/skywalking-plugin.def | 2 +- .../activation/trace/ActiveSpanTest.java | 187 ++++++++++++++++++ .../java-agent/Application-toolkit-trace.md | 14 ++ 11 files changed, 652 insertions(+), 71 deletions(-) create mode 100644 apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanActivation.java create mode 100644 apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanDebugInterceptor.java create mode 100644 apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorInterceptor.java create mode 100644 apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorMsgInterceptor.java create mode 100644 apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorThrowableInteceptor.java create mode 100644 apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanInfoInterceptor.java delete mode 100644 apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanTagActivation.java create mode 100644 apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/test/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanTest.java diff --git a/apm-application-toolkit/apm-toolkit-trace/src/main/java/org/apache/skywalking/apm/toolkit/trace/ActiveSpan.java b/apm-application-toolkit/apm-toolkit-trace/src/main/java/org/apache/skywalking/apm/toolkit/trace/ActiveSpan.java index 0c6e4956c038..a34707fec339 100644 --- a/apm-application-toolkit/apm-toolkit-trace/src/main/java/org/apache/skywalking/apm/toolkit/trace/ActiveSpan.java +++ b/apm-application-toolkit/apm-toolkit-trace/src/main/java/org/apache/skywalking/apm/toolkit/trace/ActiveSpan.java @@ -26,10 +26,24 @@ */ public class ActiveSpan { /** - * @param key tag key + * @param key tag key * @param value tag value */ public static void tag(String key, String value) { + } + + public static void error() { + } + + public static void error(String errorMsg) { + } + + public static void error(Throwable throwable) { + } + + public static void debug(String debugMsg) { + } + public static void info(String infoMsg) { } } diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanActivation.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanActivation.java new file mode 100644 index 000000000000..79f3fba0d613 --- /dev/null +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanActivation.java @@ -0,0 +1,154 @@ +/* + * 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.apm.toolkit.activation.trace; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArguments; +import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; + +/** + * {@link TraceAnnotationActivation} enhance the tag method of ActiveSpan + * by ActiveSpanTagInterceptor. + * + * @author zhangxin + */ +public class ActiveSpanActivation extends ClassStaticMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "org.apache.skywalking.apm.toolkit.trace.ActiveSpan"; + + private static final String TAG_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.toolkit.activation.trace.ActiveSpanTagInterceptor"; + private static final String TAG_INTERCEPTOR_METHOD_NAME = "tag"; + + private static final String ERROR_INTERCEPTOR_METHOD_NAME = "error"; + private static final String ERROR_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.toolkit.activation.trace.ActiveSpanErrorInterceptor"; + private static final String ERROR_MSG_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.toolkit.activation.trace.ActiveSpanErrorMsgInterceptor"; + private static final String ERROR_THROWABLE_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.toolkit.activation.trace.ActiveSpanErrorThrowableInteceptor"; + + private static final String DEBUG_INTERCEPTOR_METHOD_NAME = "debug"; + private static final String DEBUG_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.toolkit.activation.trace.ActiveSpanDebugInterceptor"; + + private static final String INFO_INTERCEPTOR_METHOD_NAME = "info"; + private static final String INFO_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.toolkit.activation.trace.ActiveSpanInfoInterceptor"; + + + @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override protected StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() { + return new StaticMethodsInterceptPoint[] { + new StaticMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named(TAG_INTERCEPTOR_METHOD_NAME); + } + + @Override public String getMethodsInterceptor() { + return TAG_INTERCEPTOR_CLASS; + } + + @Override public boolean isOverrideArgs() { + return false; + } + }, + new StaticMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named(DEBUG_INTERCEPTOR_METHOD_NAME) + .and(takesArgumentWithType(0, "java.lang.String")); + } + + @Override public String getMethodsInterceptor() { + return DEBUG_INTERCEPTOR_CLASS; + } + + @Override public boolean isOverrideArgs() { + return false; + } + }, + new StaticMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named(INFO_INTERCEPTOR_METHOD_NAME) + .and(takesArgumentWithType(0, "java.lang.String")); + } + + @Override public String getMethodsInterceptor() { + return INFO_INTERCEPTOR_CLASS; + } + + @Override public boolean isOverrideArgs() { + return false; + } + }, + new StaticMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named(ERROR_INTERCEPTOR_METHOD_NAME) + .and(takesArgumentWithType(0, "java.lang.Throwable")); + } + + @Override public String getMethodsInterceptor() { + return ERROR_THROWABLE_INTERCEPTOR_CLASS; + } + + @Override public boolean isOverrideArgs() { + return false; + } + }, + new StaticMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named(ERROR_INTERCEPTOR_METHOD_NAME) + .and(takesArgumentWithType(0, "java.lang.String")); + } + + @Override public String getMethodsInterceptor() { + return ERROR_MSG_INTERCEPTOR_CLASS; + } + + @Override public boolean isOverrideArgs() { + return false; + } + }, + new StaticMethodsInterceptPoint() { + @Override public ElementMatcher getMethodsMatcher() { + return named(ERROR_INTERCEPTOR_METHOD_NAME) + .and(takesArguments(0)); + } + + @Override public String getMethodsInterceptor() { + return ERROR_INTERCEPTOR_CLASS; + } + + @Override public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } +} diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanDebugInterceptor.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanDebugInterceptor.java new file mode 100644 index 000000000000..54b5bce33f92 --- /dev/null +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanDebugInterceptor.java @@ -0,0 +1,58 @@ +/* + * 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.apm.toolkit.activation.trace; + +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + * @author caoyixiong + */ +public class ActiveSpanDebugInterceptor implements StaticMethodsAroundInterceptor { + @Override public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + MethodInterceptResult result) { + AbstractSpan activeSpan = null; + try { + activeSpan = ContextManager.activeSpan(); + Map event = new HashMap(); + event.put("event", "debug"); + event.put("message", String.valueOf(allArguments[0])); + activeSpan.log(System.currentTimeMillis(), event); + + } catch (NullPointerException e) { + } + } + + @Override public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + Object ret) { + return ret; + } + + @Override + public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + Throwable t) { + + } +} diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorInterceptor.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorInterceptor.java new file mode 100644 index 000000000000..9dd0363c13d7 --- /dev/null +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorInterceptor.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.apm.toolkit.activation.trace; + +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor; + +import java.lang.reflect.Method; + +/** + * @author caoyixiong + */ +public class ActiveSpanErrorInterceptor implements StaticMethodsAroundInterceptor { + @Override public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + MethodInterceptResult result) { + AbstractSpan activeSpan = null; + try { + activeSpan = ContextManager.activeSpan(); + activeSpan.errorOccurred(); + } catch (NullPointerException e) { + } + } + + @Override public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + Object ret) { + return ret; + } + + @Override + public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + Throwable t) { + + } +} \ No newline at end of file diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorMsgInterceptor.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorMsgInterceptor.java new file mode 100644 index 000000000000..647b2f9746c3 --- /dev/null +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorMsgInterceptor.java @@ -0,0 +1,59 @@ +/* + * 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.apm.toolkit.activation.trace; + +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + * @author caoyixiong + */ +public class ActiveSpanErrorMsgInterceptor implements StaticMethodsAroundInterceptor { + @Override public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + MethodInterceptResult result) { + AbstractSpan activeSpan = null; + try { + activeSpan = ContextManager.activeSpan(); + activeSpan.errorOccurred(); + Map event = new HashMap(); + event.put("event", "error"); + event.put("message", String.valueOf(allArguments[0])); + activeSpan.log(System.currentTimeMillis(), event); + + } catch (NullPointerException e) { + } + } + + @Override public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + Object ret) { + return ret; + } + + @Override + public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + Throwable t) { + + } +} \ No newline at end of file diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorThrowableInteceptor.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorThrowableInteceptor.java new file mode 100644 index 000000000000..e22f18b82abc --- /dev/null +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanErrorThrowableInteceptor.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.apm.toolkit.activation.trace; + +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor; + +import java.lang.reflect.Method; + +/** + * @author caoyixiong + */ +public class ActiveSpanErrorThrowableInteceptor implements StaticMethodsAroundInterceptor { + @Override public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + MethodInterceptResult result) { + AbstractSpan activeSpan = null; + try { + activeSpan = ContextManager.activeSpan(); + activeSpan.errorOccurred(); + activeSpan.log((Throwable) allArguments[0]); + } catch (NullPointerException e) { + } + } + + @Override public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + Object ret) { + return ret; + } + + @Override + public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + Throwable t) { + + } +} diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanInfoInterceptor.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanInfoInterceptor.java new file mode 100644 index 000000000000..ddcb27ecd01b --- /dev/null +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanInfoInterceptor.java @@ -0,0 +1,58 @@ +/* + * 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.apm.toolkit.activation.trace; + +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + * @author caoyixiong + */ +public class ActiveSpanInfoInterceptor implements StaticMethodsAroundInterceptor { + @Override public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + MethodInterceptResult result) { + AbstractSpan activeSpan = null; + try { + activeSpan = ContextManager.activeSpan(); + Map event = new HashMap(); + event.put("event", "info"); + event.put("message", String.valueOf(allArguments[0])); + activeSpan.log(System.currentTimeMillis(), event); + + } catch (NullPointerException e) { + } + } + + @Override public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + Object ret) { + return ret; + } + + @Override + public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, + Throwable t) { + + } +} diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanTagActivation.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanTagActivation.java deleted file mode 100644 index c71c435ba2ff..000000000000 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanTagActivation.java +++ /dev/null @@ -1,69 +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.skywalking.apm.toolkit.activation.trace; - -import net.bytebuddy.description.method.MethodDescription; -import net.bytebuddy.matcher.ElementMatcher; -import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine; -import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; -import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; -import org.apache.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint; -import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; - -import static net.bytebuddy.matcher.ElementMatchers.named; - -/** - * {@link TraceAnnotationActivation} enhance the tag method of ActiveSpan - * by ActiveSpanTagInterceptor. - * - * @author zhangxin - */ -public class ActiveSpanTagActivation extends ClassStaticMethodsEnhancePluginDefine { - - public static final String ENHANCE_CLASS = "org.apache.skywalking.apm.toolkit.trace.ActiveSpan"; - public static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.toolkit.activation.trace.ActiveSpanTagInterceptor"; - public static final String INTERCEPTOR_METHOD_NAME = "tag"; - - @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { - return new ConstructorInterceptPoint[0]; - } - - @Override protected StaticMethodsInterceptPoint[] getStaticMethodsInterceptPoints() { - return new StaticMethodsInterceptPoint[] { - new StaticMethodsInterceptPoint() { - @Override public ElementMatcher getMethodsMatcher() { - return named(INTERCEPTOR_METHOD_NAME); - } - - @Override public String getMethodsInterceptor() { - return INTERCEPTOR_CLASS; - } - - @Override public boolean isOverrideArgs() { - return false; - } - } - }; - } - - @Override protected ClassMatch enhanceClass() { - return NameMatch.byName(ENHANCE_CLASS); - } -} diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/resources/skywalking-plugin.def index 2d540d5b8e04..a0e2fc8ede76 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/resources/skywalking-plugin.def +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/resources/skywalking-plugin.def @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -toolkit-trace=org.apache.skywalking.apm.toolkit.activation.trace.ActiveSpanTagActivation +toolkit-trace=org.apache.skywalking.apm.toolkit.activation.trace.ActiveSpanActivation toolkit-trace=org.apache.skywalking.apm.toolkit.activation.trace.TraceAnnotationActivation toolkit-trace=org.apache.skywalking.apm.toolkit.activation.trace.TraceContextActivation toolkit-trace=org.apache.skywalking.apm.toolkit.activation.trace.CallableOrRunnableActivation diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/test/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanTest.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/test/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanTest.java new file mode 100644 index 000000000000..de53303c6a6f --- /dev/null +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/test/java/org/apache/skywalking/apm/toolkit/activation/trace/ActiveSpanTest.java @@ -0,0 +1,187 @@ +/* + * 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.apm.toolkit.activation.trace; + +import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan; +import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.test.helper.SegmentHelper; +import org.apache.skywalking.apm.agent.test.tools.*; +import org.apache.skywalking.apm.toolkit.trace.ActiveSpan; +import org.apache.skywalking.apm.toolkit.trace.Trace; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +/** + * @author caoyixiong + */ +@RunWith(PowerMockRunner.class) +@PowerMockRunnerDelegate(TracingSegmentRunner.class) +public class ActiveSpanTest { + + private TraceAnnotationMethodInterceptor methodInterceptor; + private ActiveSpanErrorInterceptor activeSpanErrorInterceptor; + private ActiveSpanErrorMsgInterceptor activeSpanErrorMsgInterceptor; + private ActiveSpanErrorThrowableInteceptor activeSpanErrorThrowableInteceptor; + private ActiveSpanInfoInterceptor activeSpanInfoInterceptor; + + + @Mock + private EnhancedInstance enhancedInstance; + @Rule + public AgentServiceRule serviceRule = new AgentServiceRule(); + @SegmentStoragePoint + private SegmentStorage storage; + + private Object[] tagParametersMsg; + private Class[] tagParameterTypesMsg; + + private Object[] tagParametersThrowable; + private Class[] tagParameterTypesThrowable; + + @Before + public void setUp() throws Exception { + methodInterceptor = new TraceAnnotationMethodInterceptor(); + activeSpanErrorInterceptor = new ActiveSpanErrorInterceptor(); + activeSpanErrorMsgInterceptor = new ActiveSpanErrorMsgInterceptor(); + activeSpanErrorThrowableInteceptor = new ActiveSpanErrorThrowableInteceptor(); + activeSpanInfoInterceptor = new ActiveSpanInfoInterceptor(); + + tagParametersMsg = new Object[]{"testMsgValue"}; + tagParameterTypesMsg = new Class[]{String.class}; + + tagParametersThrowable = new Object[]{new RuntimeException("test-Throwable")}; + tagParameterTypesThrowable = new Class[]{Throwable.class}; + } + + @Test + public void testActiveSpanError() throws Throwable { + Method withOperationNameMethod = MockActiveSpan.class.getDeclaredMethod("testErrorMethod"); + methodInterceptor.beforeMethod(enhancedInstance, withOperationNameMethod, null, null, null); + activeSpanErrorMsgInterceptor.beforeMethod(MockActiveSpan.class, withOperationNameMethod, tagParametersMsg, tagParameterTypesMsg, null); + activeSpanErrorMsgInterceptor.afterMethod(MockActiveSpan.class, withOperationNameMethod, tagParametersMsg, tagParameterTypesMsg, null); + methodInterceptor.afterMethod(enhancedInstance, withOperationNameMethod, null, null, null); + + assertThat(storage.getTraceSegments().size(), is(1)); + TraceSegment traceSegment = storage.getTraceSegments().get(0); + List spans = SegmentHelper.getSpans(traceSegment); + assertThat(spans.size(), is(1)); + + AbstractTracingSpan tracingSpan = spans.get(0); + Field field = AbstractTracingSpan.class.getDeclaredField("errorOccurred"); + field.setAccessible(true); + assertTrue(field.getBoolean(tracingSpan)); + SpanAssert.assertLogSize(tracingSpan, 1); + SpanAssert.assertTagSize(tracingSpan, 0); + } + + @Test + public void testActiveSpanErrorNoMsg() throws Throwable { + Method withOperationNameMethod = MockActiveSpan.class.getDeclaredMethod("testErrorNoMsgMethod"); + methodInterceptor.beforeMethod(enhancedInstance, withOperationNameMethod, null, null, null); + activeSpanErrorInterceptor.beforeMethod(MockActiveSpan.class, withOperationNameMethod, null, null, null); + activeSpanErrorInterceptor.afterMethod(MockActiveSpan.class, withOperationNameMethod, null, null, null); + methodInterceptor.afterMethod(enhancedInstance, withOperationNameMethod, null, null, null); + + assertThat(storage.getTraceSegments().size(), is(1)); + TraceSegment traceSegment = storage.getTraceSegments().get(0); + List spans = SegmentHelper.getSpans(traceSegment); + assertThat(spans.size(), is(1)); + + AbstractTracingSpan tracingSpan = spans.get(0); + Field field = AbstractTracingSpan.class.getDeclaredField("errorOccurred"); + field.setAccessible(true); + assertTrue(field.getBoolean(tracingSpan)); + SpanAssert.assertLogSize(tracingSpan, 0); + SpanAssert.assertTagSize(tracingSpan, 0); + } + + @Test + public void testActiveSpanErrorThrowable() throws Throwable { + Method withOperationNameMethod = MockActiveSpan.class.getDeclaredMethod("testErrorThrowableMethod"); + methodInterceptor.beforeMethod(enhancedInstance, withOperationNameMethod, null, null, null); + activeSpanErrorThrowableInteceptor.beforeMethod(MockActiveSpan.class, withOperationNameMethod, tagParametersThrowable, tagParameterTypesThrowable, null); + activeSpanErrorThrowableInteceptor.afterMethod(MockActiveSpan.class, withOperationNameMethod, tagParametersThrowable, tagParameterTypesThrowable, null); + methodInterceptor.afterMethod(enhancedInstance, withOperationNameMethod, null, null, null); + + assertThat(storage.getTraceSegments().size(), is(1)); + TraceSegment traceSegment = storage.getTraceSegments().get(0); + List spans = SegmentHelper.getSpans(traceSegment); + assertThat(spans.size(), is(1)); + AbstractTracingSpan tracingSpan = spans.get(0); + Field field = AbstractTracingSpan.class.getDeclaredField("errorOccurred"); + field.setAccessible(true); + assertTrue(field.getBoolean(tracingSpan)); + SpanAssert.assertLogSize(tracingSpan, 1); + SpanAssert.assertTagSize(tracingSpan, 0); + } + + @Test + public void testActiveSpanInfo() throws Throwable { + Method withOperationNameMethod = MockActiveSpan.class.getDeclaredMethod("testInfoMethod"); + methodInterceptor.beforeMethod(enhancedInstance, withOperationNameMethod, null, null, null); + activeSpanInfoInterceptor.beforeMethod(MockActiveSpan.class, withOperationNameMethod, tagParametersThrowable, tagParameterTypesThrowable, null); + activeSpanInfoInterceptor.afterMethod(MockActiveSpan.class, withOperationNameMethod, tagParametersThrowable, tagParameterTypesThrowable, null); + methodInterceptor.afterMethod(enhancedInstance, withOperationNameMethod, null, null, null); + + assertThat(storage.getTraceSegments().size(), is(1)); + TraceSegment traceSegment = storage.getTraceSegments().get(0); + List spans = SegmentHelper.getSpans(traceSegment); + assertThat(spans.size(), is(1)); + + AbstractTracingSpan tracingSpan = spans.get(0); + SpanAssert.assertLogSize(tracingSpan, 1); + SpanAssert.assertTagSize(tracingSpan, 0); + } + + private class MockActiveSpan { + @Trace + public void testErrorMethod() { + ActiveSpan.error("testValue"); + } + + @Trace + public void testInfoMethod() { + ActiveSpan.info("testValue"); + } + + @Trace + public void testErrorNoMsgMethod() { + ActiveSpan.error(); + } + + @Trace + public void testErrorThrowableMethod() { + ActiveSpan.error(new RuntimeException("test-Throwable")); + } + } +} diff --git a/docs/en/setup/service-agent/java-agent/Application-toolkit-trace.md b/docs/en/setup/service-agent/java-agent/Application-toolkit-trace.md index bbd8df6de368..16b135e17ff0 100644 --- a/docs/en/setup/service-agent/java-agent/Application-toolkit-trace.md +++ b/docs/en/setup/service-agent/java-agent/Application-toolkit-trace.md @@ -18,6 +18,20 @@ _Sample codes only_ * Add `@Trace` to any method you want to trace. After that, you can see the span in the Stack. * Add custom tag in the context of traced method . + +* `ActiveSpan.error()` Mark the current span as error status. +* `ActiveSpan.error(String errorMsg)` Mark the current span as error status with a message. +* `ActiveSpan.error(Throwable throwable)` Mark the current span as error status with a Throwable. +* `ActiveSpan.debug(String debugMsg)` Add a debug level log message in the current span. +* `ActiveSpan.info(String infoMsg)` Add an info level log message in the current span. + ```java ActiveSpan.tag("my_tag", "my_value"); +ActiveSpan.error(); +ActiveSpan.error("Test-Error-Reason"); + +ActiveSpan.error(new RuntimeException("Test-Error-Throwable")); +ActiveSpan.info("Test-Info-Msg"); +ActiveSpan.debug("Test-debug-Msg"); ``` + From 3a318128545627da1420fb26eb24030df07623b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E5=8B=87=E5=8D=87=20pengys?= Date: Fri, 10 May 2019 12:02:17 +0800 Subject: [PATCH 18/24] Recover the module name of envoy-metric. (#2645) --- docs/en/setup/backend/backend-receivers.md | 4 ++-- .../oap/server/receiver/envoy/EnvoyMetricReceiverModule.java | 2 +- oap-server/server-starter/src/main/assembly/application.yml | 2 +- oap-server/server-starter/src/main/resources/application.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/en/setup/backend/backend-receivers.md b/docs/en/setup/backend/backend-receivers.md index 2a2540f7c8d1..a5cd09b4a6da 100644 --- a/docs/en/setup/backend/backend-receivers.md +++ b/docs/en/setup/backend/backend-receivers.md @@ -10,7 +10,7 @@ We have following receivers, and `default` implementors are provided in our Apac 1. **service-mesh**. gRPC services accept data from inbound mesh probes. 1. **receiver-jvm**. gRPC services accept JVM metrics data. 1. **istio-telemetry**. Istio telemetry is from Istio official bypass adaptor, this receiver match its gRPC services. -1. **envoy-metrics**. Envoy `metrics_service` supported by this receiver. OAL script support all GAUGE type metrics. +1. **envoy-metric**. Envoy `metrics_service` supported by this receiver. OAL script support all GAUGE type metrics. 1. **receiver_zipkin**. See [details](#zipkin-receiver). 1. **receiver_jaeger**. See [details](#jaeger-receiver). @@ -35,7 +35,7 @@ service-mesh: bufferFileCleanWhenRestart: false istio-telemetry: default: -envoy-metrics: +envoy-metric: default: receiver_zipkin: default: diff --git a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/EnvoyMetricReceiverModule.java b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/EnvoyMetricReceiverModule.java index 449518f081c2..d43042877955 100644 --- a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/EnvoyMetricReceiverModule.java +++ b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/EnvoyMetricReceiverModule.java @@ -26,7 +26,7 @@ * @author wusheng */ public class EnvoyMetricReceiverModule extends ModuleDefine { - public static final String NAME = "envoy-metrics"; + public static final String NAME = "envoy-metric"; public EnvoyMetricReceiverModule() { super(NAME); diff --git a/oap-server/server-starter/src/main/assembly/application.yml b/oap-server/server-starter/src/main/assembly/application.yml index 0f25c93f10de..cd71767a5f16 100644 --- a/oap-server/server-starter/src/main/assembly/application.yml +++ b/oap-server/server-starter/src/main/assembly/application.yml @@ -100,7 +100,7 @@ service-mesh: bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false} istio-telemetry: default: -envoy-metrics: +envoy-metric: default: #receiver_zipkin: # default: diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-starter/src/main/resources/application.yml index 27a9f25d02bb..08ccd0635ebc 100644 --- a/oap-server/server-starter/src/main/resources/application.yml +++ b/oap-server/server-starter/src/main/resources/application.yml @@ -100,7 +100,7 @@ service-mesh: bufferFileCleanWhenRestart: ${SW_SERVICE_MESH_BUFFER_FILE_CLEAN_WHEN_RESTART:false} istio-telemetry: default: -envoy-metrics: +envoy-metric: default: #receiver_zipkin: # default: From 118485fbb7ebd437ced9b1d263fd17cc84f4a61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E5=8B=87=E5=8D=87=20pengys?= Date: Fri, 10 May 2019 12:43:17 +0800 Subject: [PATCH 19/24] Make the elasticsearch json object build to be a public method. (#2648) --- .../plugin/elasticsearch/base/EsDAO.java | 21 ++++++++++- .../base/HistoryDeleteEsDAO.java | 7 ++-- .../elasticsearch/base/MetricsEsDAO.java | 35 +++---------------- .../elasticsearch/base/RecordEsDAO.java | 19 ++-------- .../elasticsearch/base/RegisterEsDAO.java | 24 +++---------- 5 files changed, 33 insertions(+), 73 deletions(-) diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/EsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/EsDAO.java index 2cd3789f4be0..bc22597f033e 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/EsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/EsDAO.java @@ -18,10 +18,14 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base; +import java.io.IOException; +import java.util.Map; import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.query.sql.Where; import org.apache.skywalking.oap.server.core.storage.AbstractDAO; +import org.apache.skywalking.oap.server.core.storage.type.StorageDataType; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; +import org.elasticsearch.common.xcontent.*; import org.elasticsearch.index.query.*; import org.elasticsearch.search.builder.SearchSourceBuilder; @@ -34,7 +38,7 @@ public EsDAO(ElasticSearchClient client) { super(client); } - public final void queryBuild(SearchSourceBuilder sourceBuilder, Where where, long startTB, long endTB) { + protected final void queryBuild(SearchSourceBuilder sourceBuilder, Where where, long startTB, long endTB) { RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(Metrics.TIME_BUCKET).gte(startTB).lte(endTB); if (where.getKeyValues().isEmpty()) { sourceBuilder.query(rangeQueryBuilder); @@ -53,4 +57,19 @@ public final void queryBuild(SearchSourceBuilder sourceBuilder, Where where, lon } sourceBuilder.size(0); } + + XContentBuilder map2builder(Map objectMap) throws IOException { + XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); + for (String key : objectMap.keySet()) { + Object value = objectMap.get(key); + if (value instanceof StorageDataType) { + builder.field(key, ((StorageDataType)value).toStorageData()); + } else { + builder.field(key, value); + } + } + builder.endObject(); + + return builder; + } } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java index ca7ccee0bf91..44c6fdd71609 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java @@ -18,13 +18,10 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base; +import java.io.IOException; import org.apache.skywalking.oap.server.core.storage.IHistoryDeleteDAO; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; - +import org.slf4j.*; /** * @author peng-yongsheng diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java index 5095252d98e5..7693d57dfbc3 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/MetricsEsDAO.java @@ -19,27 +19,22 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base; import java.io.IOException; -import java.util.Map; import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.storage.*; -import org.apache.skywalking.oap.server.core.storage.type.StorageDataType; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.update.UpdateRequest; -import org.elasticsearch.common.xcontent.*; -import org.slf4j.*; +import org.elasticsearch.common.xcontent.XContentBuilder; /** * @author peng-yongsheng */ public class MetricsEsDAO extends EsDAO implements IMetricsDAO { - private static final Logger logger = LoggerFactory.getLogger(MetricsEsDAO.class); - private final StorageBuilder storageBuilder; - public MetricsEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { + MetricsEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { super(client); this.storageBuilder = storageBuilder; } @@ -54,34 +49,12 @@ public MetricsEsDAO(ElasticSearchClient client, StorageBuilder storageB } @Override public IndexRequest prepareBatchInsert(String modelName, Metrics metrics) throws IOException { - Map objectMap = storageBuilder.data2Map(metrics); - - XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); - for (String key : objectMap.keySet()) { - Object value = objectMap.get(key); - if (value instanceof StorageDataType) { - builder.field(key, ((StorageDataType)value).toStorageData()); - } else { - builder.field(key, value); - } - } - builder.endObject(); + XContentBuilder builder = map2builder(storageBuilder.data2Map(metrics)); return getClient().prepareInsert(modelName, metrics.id(), builder); } @Override public UpdateRequest prepareBatchUpdate(String modelName, Metrics metrics) throws IOException { - Map objectMap = storageBuilder.data2Map(metrics); - - XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); - for (String key : objectMap.keySet()) { - Object value = objectMap.get(key); - if (value instanceof StorageDataType) { - builder.field(key, ((StorageDataType)value).toStorageData()); - } else { - builder.field(key, value); - } - } - builder.endObject(); + XContentBuilder builder = map2builder(storageBuilder.data2Map(metrics)); return getClient().prepareUpdate(modelName, metrics.id(), builder); } } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RecordEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RecordEsDAO.java index 4a1c1d47c1aa..f2fa26ed2fb3 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RecordEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RecordEsDAO.java @@ -19,13 +19,11 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base; import java.io.IOException; -import java.util.Map; import org.apache.skywalking.oap.server.core.analysis.record.Record; import org.apache.skywalking.oap.server.core.storage.*; -import org.apache.skywalking.oap.server.core.storage.type.StorageDataType; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.common.xcontent.*; +import org.elasticsearch.common.xcontent.XContentBuilder; /** * @author peng-yongsheng @@ -34,24 +32,13 @@ public class RecordEsDAO extends EsDAO implements IRecordDAO { private final StorageBuilder storageBuilder; - public RecordEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { + RecordEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { super(client); this.storageBuilder = storageBuilder; } @Override public IndexRequest prepareBatchInsert(String modelName, Record record) throws IOException { - Map objectMap = storageBuilder.data2Map(record); - - XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); - for (String key : objectMap.keySet()) { - Object value = objectMap.get(key); - if (value instanceof StorageDataType) { - builder.field(key, ((StorageDataType)value).toStorageData()); - } else { - builder.field(key, value); - } - } - builder.endObject(); + XContentBuilder builder = map2builder(storageBuilder.data2Map(record)); return getClient().prepareInsert(modelName, record.id(), builder); } } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RegisterEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RegisterEsDAO.java index 58f3a8d204e4..c4bd28931a64 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RegisterEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/RegisterEsDAO.java @@ -19,24 +19,20 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base; import java.io.IOException; -import java.util.Map; import org.apache.skywalking.oap.server.core.register.RegisterSource; import org.apache.skywalking.oap.server.core.storage.*; import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.common.xcontent.*; -import org.slf4j.*; +import org.elasticsearch.common.xcontent.XContentBuilder; /** * @author peng-yongsheng */ public class RegisterEsDAO extends EsDAO implements IRegisterDAO { - private static final Logger logger = LoggerFactory.getLogger(RegisterEsDAO.class); - private final StorageBuilder storageBuilder; - public RegisterEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { + RegisterEsDAO(ElasticSearchClient client, StorageBuilder storageBuilder) { super(client); this.storageBuilder = storageBuilder; } @@ -51,24 +47,12 @@ public RegisterEsDAO(ElasticSearchClient client, StorageBuilder } @Override public void forceInsert(String modelName, RegisterSource source) throws IOException { - XContentBuilder builder = build(source); + XContentBuilder builder = map2builder(storageBuilder.data2Map(source)); getClient().forceInsert(modelName, source.id(), builder); } @Override public void forceUpdate(String modelName, RegisterSource source) throws IOException { - XContentBuilder builder = build(source); + XContentBuilder builder = map2builder(storageBuilder.data2Map(source)); getClient().forceUpdate(modelName, source.id(), builder); } - - private XContentBuilder build(RegisterSource source) throws IOException { - Map objectMap = storageBuilder.data2Map(source); - - XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); - for (String key : objectMap.keySet()) { - builder.field(key, objectMap.get(key)); - } - builder.endObject(); - - return builder; - } } From 20611a3fe30580c00dcb27767bbb1f3556420a57 Mon Sep 17 00:00:00 2001 From: Jared Tan Date: Fri, 10 May 2019 16:36:40 +0800 Subject: [PATCH 20/24] sync ui. (#2632) * sync ui. * update --- skywalking-ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skywalking-ui b/skywalking-ui index ef3570fb126c..26322717f150 160000 --- a/skywalking-ui +++ b/skywalking-ui @@ -1 +1 @@ -Subproject commit ef3570fb126c534d0f15c3a241944fa46ee594b7 +Subproject commit 26322717f1503bc84ea052e31696fba8a445c438 From ff08ba7fa5c431685012a134b0e8005cf53b46aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E5=8B=87=E5=8D=87=20pengys?= Date: Mon, 13 May 2019 14:14:05 +0800 Subject: [PATCH 21/24] Update README.md (#2655) Add the second QQ group number. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fc8f1c320194..24277b015f49 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Follow this [document](docs/en/guides/How-to-build.md). * Submit an [issue](https://github.com/apache/skywalking/issues) * Mail list: **dev@skywalking.apache.org**. Mail to `dev-subscribe@skywalking.apache.org`, follow the reply to subscribe the mail list. * Join `#skywalking` channel at [Apache Slack](https://join.slack.com/t/the-asf/shared_invite/enQtNDQ3OTEwNzE1MDg5LWY2NjkwMTEzMGI2ZTI1NzUzMDk0MzJmMWM1NWVmODg0MzBjNjAxYzUwMjIwNDI3MjlhZWRjNmNhOTM5NmIxNDk) -* QQ Group: 392443393 +* QQ Group: 392443393, 901167865 # Who Uses SkyWalking? A wide variety of companies and organizations use SkyWalking for research, production and commercial product. From e07172b84f861190e18d945fcac2d8063fa51a5a Mon Sep 17 00:00:00 2001 From: SataQiu Date: Tue, 14 May 2019 16:12:59 +0800 Subject: [PATCH 22/24] update agent.config (#2664) --- apm-sniffer/config/agent.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-sniffer/config/agent.config b/apm-sniffer/config/agent.config index 37f2b4272488..327d9ef0f77a 100644 --- a/apm-sniffer/config/agent.config +++ b/apm-sniffer/config/agent.config @@ -31,7 +31,7 @@ agent.service_name=${SW_AGENT_NAME:Your_ApplicationName} # Through this config item, skywalking keep your application memory cost estimated. # agent.span_limit_per_segment=${SW_AGENT_SPAN_LIMIT:300} -# Ignore the segments if their operation names start with these suffix. +# Ignore the segments if their operation names end with these suffix. # agent.ignore_suffix=${SW_AGENT_IGNORE_SUFFIX:.jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,.mp4,.html,.svg} # If true, skywalking agent will save all instrumented classes files in `/debugging` folder. From b4ee1f17fb85555d384789a9a5b75093348290d3 Mon Sep 17 00:00:00 2001 From: caoyixiong <32847163+IanCao@users.noreply.github.com> Date: Tue, 14 May 2019 23:09:42 +0800 Subject: [PATCH 23/24] update dependencyManagement (#2660) * Fix #2546 * Change the stackdepth type * Fix bug * Fix CI failed * fix #2599 * fix ci * add license * add ActiveTag error methods * fix * fix * fix doc * update doc * update dependencyManagement * fix --- oap-server/pom.xml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/oap-server/pom.xml b/oap-server/pom.xml index db5bbe1cbd7e..b70168894c07 100644 --- a/oap-server/pom.xml +++ b/oap-server/pom.xml @@ -69,6 +69,12 @@ 2.9.1 2.6.2 3.9.0 + 2.9.5 + 2.9.5 + 2.9.5 + 1.11 + 3.7 + 0.6.0 0.28.0 @@ -322,6 +328,36 @@ ${caffeine.version} + + com.fasterxml.jackson.core + jackson-core + ${jackson-core.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-annotations.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-databind.version} + + + commons-codec + commons-codec + ${commons-codec.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + io.prometheus + simpleclient + ${simpleclient.version} + From 91ffae2526920e9f7c62a14d210f250608bf030d Mon Sep 17 00:00:00 2001 From: caoyixiong <32847163+IanCao@users.noreply.github.com> Date: Wed, 15 May 2019 00:29:23 +0800 Subject: [PATCH 24/24] support Nacos cluster (#2640) * Fix #2546 * Change the stackdepth type * Fix bug * Fix CI failed * fix #2599 * fix ci * add license * add ActiveTag error methods * fix * fix * nacos * nacos * nacos * nacos * fix ci * support nacos cluster * fix yml * fix license * fix ci * remove optional * update license * update license and doc * fix --- apm-dist/release-docs/LICENSE | 2 + apm-dist/release-docs/NOTICE | 38 +++++ .../licenses/LICENSE-fastjson.txt | 13 ++ docker/config/application.yml | 3 + docs/en/setup/backend/backend-cluster.md | 17 ++- .../cluster-nacos-plugin/pom.xml | 71 ++++++++++ .../nacos/ClusterModuleNacosConfig.java | 31 ++++ .../nacos/ClusterModuleNacosProvider.java | 84 +++++++++++ .../plugin/nacos/NacosCoordinator.java | 79 +++++++++++ ...g.oap.server.library.module.ModuleProvider | 19 +++ .../nacos/ClusterModuleNacosProviderTest.java | 106 ++++++++++++++ .../plugin/nacos/NacosCoordinatorTest.java | 134 ++++++++++++++++++ oap-server/server-cluster-plugin/pom.xml | 1 + .../core/cluster/ServiceQueryException.java | 29 ++++ oap-server/server-starter/pom.xml | 5 + .../src/main/assembly/application.yml | 3 + .../src/main/resources/application.yml | 3 + 17 files changed, 636 insertions(+), 2 deletions(-) create mode 100644 apm-dist/release-docs/licenses/LICENSE-fastjson.txt create mode 100644 oap-server/server-cluster-plugin/cluster-nacos-plugin/pom.xml create mode 100644 oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosConfig.java create mode 100644 oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProvider.java create mode 100644 oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinator.java create mode 100644 oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider create mode 100644 oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProviderTest.java create mode 100644 oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinatorTest.java create mode 100644 oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ServiceQueryException.java diff --git a/apm-dist/release-docs/LICENSE b/apm-dist/release-docs/LICENSE index 8b134b293f98..f8c1911e610f 100644 --- a/apm-dist/release-docs/LICENSE +++ b/apm-dist/release-docs/LICENSE @@ -217,6 +217,7 @@ The text of each license is also included at licenses/LICENSE-[project].txt. Apache: groovy 2.4.5-indy: https://github.com/apache/groovy, Apache 2.0 Apache: httpcomponents 4.x.x: http://hc.apache.org/index.html, Apache 2.0 + Apache: fastjson 1.2.47: https://github.com/alibaba/fastjson, Apache 2.0 ======================================================================== Apache 2.0 licenses @@ -307,6 +308,7 @@ The text of each license is the standard Apache 2.0 license. consul-client 1.2.6: https://github.com/rickfast/consul-client, Apache 2.0 okhttp 3.9.0: https://github.com/square/okhttp, Apache 2.0 prometheus client_java 0.6.0: https://github.com/prometheus/client_java, Apache 2.0 + nacos 1.0.0: https://github.com/alibaba/nacos, Apache 2.0 proto files from istio/istio: https://github.com/istio/istio Apache 2.0 proto files from istio/api: https://github.com/istio/api Apache 2.0 proto files from envoyproxy/data-plane-api: https://github.com/envoyproxy/data-plane-api Apache 2.0 diff --git a/apm-dist/release-docs/NOTICE b/apm-dist/release-docs/NOTICE index a904f3729605..60a4f4552ff6 100644 --- a/apm-dist/release-docs/NOTICE +++ b/apm-dist/release-docs/NOTICE @@ -831,3 +831,41 @@ from and not be held liable to the user for any such damages as noted above as far as the program is concerned. ------ + +=========================================================================== +nacos-1.0.0 Notice +=========================================================================== +Nacos +Copyright 2018-2019 The Apache Software Foundation + +This product includes software developed at +The Alibaba MiddleWare Group. + +------ +This product has a bundle Spring Boot: + The Spring Boot Project + ================= + +Please visit the Spring Boot web site for more information: + + * https://spring.io/projects/spring-boot + +Copyright 2014 The Spring Boot Project + +The Spring Boot Project 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. + +Also, please refer to each LICENSE..txt file, which is located in +the 'license' directory of the distribution file, for the license terms of the +components that this product depends on. + +------ \ No newline at end of file diff --git a/apm-dist/release-docs/licenses/LICENSE-fastjson.txt b/apm-dist/release-docs/licenses/LICENSE-fastjson.txt new file mode 100644 index 000000000000..b8500e573e47 --- /dev/null +++ b/apm-dist/release-docs/licenses/LICENSE-fastjson.txt @@ -0,0 +1,13 @@ +Copyright 1999-2019 Alibaba Group Holding Ltd. + +Licensed 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. \ No newline at end of file diff --git a/docker/config/application.yml b/docker/config/application.yml index 7865829d1c48..afbd3e7ad6ba 100644 --- a/docker/config/application.yml +++ b/docker/config/application.yml @@ -33,6 +33,9 @@ cluster: # serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"} # Consul cluster nodes, example: 10.0.0.1:8500,10.0.0.2:8500,10.0.0.3:8500 # hostPort: ${SW_CLUSTER_CONSUL_HOST_PORT:localhost:8500} +# nacos: +# serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"} +# hostPort: ${SW_CLUSTER_NACOS_HOST_PORT:localhost:8848} core: default: # Mixed: Receive agent data, Level 1 aggregate, Level 2 aggregate diff --git a/docs/en/setup/backend/backend-cluster.md b/docs/en/setup/backend/backend-cluster.md index a6206e550621..0ec9116ecffe 100644 --- a/docs/en/setup/backend/backend-cluster.md +++ b/docs/en/setup/backend/backend-cluster.md @@ -9,7 +9,7 @@ with each other. - [Kubernetes](#kubernetes). When backend cluster are deployed inside kubernetes, you could choose this by using k8s native APIs to manage cluster. - [Consul](#consul). Use Consul as backend cluster management implementor, to coordinate backend instances. - +- [Nacos](#nacos). Use Nacos to coordinate backend instances. ## Zookeeper coordinator Zookeeper is a very common and wide used cluster coordinator. Set the **cluster** module's implementor @@ -77,4 +77,17 @@ Same as Zookeeper coordinator, in some cases, oap default gRPC host and port in core are not suitable for internal communication among the oap nodes. The following setting are provided to set the hot and port manually, based on your own LAN env. - internalComHost, the host registered and other oap node use this to communicate with current node. -- internalComPort, the port registered and other oap node use this to communicate with current node. \ No newline at end of file +- internalComPort, the port registered and other oap node use this to communicate with current node. + + +## Nacos +Set the **cluster** module's implementor to **nacos** in +the yml to active. + +```yaml +cluster: + nacos: + serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"} + # Nacos cluster nodes, example: 10.0.0.1:8848,10.0.0.2:8848,10.0.0.3:8848 + hostPort: ${SW_CLUSTER_NACOS_HOST_PORT:localhost:8848} +``` \ No newline at end of file diff --git a/oap-server/server-cluster-plugin/cluster-nacos-plugin/pom.xml b/oap-server/server-cluster-plugin/cluster-nacos-plugin/pom.xml new file mode 100644 index 000000000000..15889ad145a8 --- /dev/null +++ b/oap-server/server-cluster-plugin/cluster-nacos-plugin/pom.xml @@ -0,0 +1,71 @@ + + + + + server-cluster-plugin + org.apache.skywalking + 6.2.0-SNAPSHOT + + 4.0.0 + + cluster-nacos-plugin + + 1.0.0 + + + + org.apache.skywalking + server-core + ${project.version} + + + com.alibaba.nacos + nacos-client + ${nacos.version} + + + org.slf4j + slf4j-api + + + org.apache.logging.log4j + log4j-core + + + org.apache.logging.log4j + log4j-slf4j-impl + + + ch.qos.logback + logback-classic + + + ch.qos.logback + logback-core + + + net.jcip + jcip-annotations + + + + + \ No newline at end of file diff --git a/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosConfig.java b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosConfig.java new file mode 100644 index 000000000000..2b5590d856a2 --- /dev/null +++ b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosConfig.java @@ -0,0 +1,31 @@ +/* + * 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.cluster.plugin.nacos; + +import lombok.Getter; +import lombok.Setter; +import org.apache.skywalking.oap.server.library.module.ModuleConfig; + +/** + * @author caoyixiong + */ +public class ClusterModuleNacosConfig extends ModuleConfig { + @Setter @Getter private String serviceName; + @Setter @Getter private String hostPort; +} diff --git a/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProvider.java b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProvider.java new file mode 100644 index 000000000000..34b3bc37fce5 --- /dev/null +++ b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProvider.java @@ -0,0 +1,84 @@ +/* + * 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.cluster.plugin.nacos; + +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.naming.NamingFactory; +import com.alibaba.nacos.api.naming.NamingService; +import org.apache.skywalking.oap.server.core.CoreModule; +import org.apache.skywalking.oap.server.core.cluster.ClusterModule; +import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery; +import org.apache.skywalking.oap.server.core.cluster.ClusterRegister; +import org.apache.skywalking.oap.server.library.module.*; + +/** + * @author caoyixiong + */ +public class ClusterModuleNacosProvider extends ModuleProvider { + + private final ClusterModuleNacosConfig config; + private NamingService namingService; + + public ClusterModuleNacosProvider() { + super(); + this.config = new ClusterModuleNacosConfig(); + } + + @Override + public String name() { + return "nacos"; + } + + @Override + public Class module() { + return ClusterModule.class; + } + + @Override + public ModuleConfig createConfigBeanIfAbsent() { + return config; + } + + @Override + public void prepare() throws ServiceNotProvidedException, ModuleStartException { + try { + namingService = NamingFactory.createNamingService(config.getHostPort()); + } catch (NacosException e) { + throw new ModuleStartException(e.getMessage(), e); + } + NacosCoordinator coordinator = new NacosCoordinator(namingService, config); + this.registerServiceImplementation(ClusterRegister.class, coordinator); + this.registerServiceImplementation(ClusterNodesQuery.class, coordinator); + } + + @Override + public void start() throws ServiceNotProvidedException { + + } + + @Override + public void notifyAfterCompleted() throws ServiceNotProvidedException { + + } + + @Override + public String[] requiredModules() { + return new String[]{CoreModule.NAME}; + } +} diff --git a/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinator.java b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinator.java new file mode 100644 index 000000000000..10d56f4ab8b7 --- /dev/null +++ b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinator.java @@ -0,0 +1,79 @@ +/* + * 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.cluster.plugin.nacos; + +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.naming.NamingService; +import com.alibaba.nacos.api.naming.pojo.Instance; +import org.apache.skywalking.oap.server.core.cluster.*; +import org.apache.skywalking.oap.server.core.remote.client.Address; +import org.apache.skywalking.oap.server.library.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * @author caoyixiong + */ +public class NacosCoordinator implements ClusterRegister, ClusterNodesQuery { + + private final NamingService namingService; + private final ClusterModuleNacosConfig config; + private volatile Address selfAddress; + + public NacosCoordinator(NamingService namingService, ClusterModuleNacosConfig config) { + this.namingService = namingService; + this.config = config; + } + + @Override + public List queryRemoteNodes() { + List result = new ArrayList<>(); + try { + List instances = namingService.selectInstances(config.getServiceName(), true); + if (CollectionUtils.isNotEmpty(instances)) { + instances.forEach(instance -> { + if (Objects.nonNull(selfAddress)) { + if (selfAddress.getHost().equals(instance.getIp()) && selfAddress.getPort() == instance.getPort()) { + result.add(new RemoteInstance(new Address(instance.getIp(), instance.getPort(), true))); + } else { + result.add(new RemoteInstance(new Address(instance.getIp(), instance.getPort(), false))); + } + } + }); + } + } catch (NacosException e) { + throw new ServiceQueryException(e.getErrMsg()); + } + return result; + } + + @Override + public void registerRemote(RemoteInstance remoteInstance) throws ServiceRegisterException { + String host = remoteInstance.getAddress().getHost(); + int port = remoteInstance.getAddress().getPort(); + try { + namingService.registerInstance(config.getServiceName(), host, port); + } catch (Exception e) { + throw new ServiceRegisterException(e.getMessage()); + } + this.selfAddress = remoteInstance.getAddress(); + } +} diff --git a/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider new file mode 100644 index 000000000000..1a1c0e89fa17 --- /dev/null +++ b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleProvider @@ -0,0 +1,19 @@ +# +# 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. +# +# + +org.apache.skywalking.oap.server.cluster.plugin.nacos.ClusterModuleNacosProvider \ No newline at end of file diff --git a/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProviderTest.java b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProviderTest.java new file mode 100644 index 000000000000..b60777b18649 --- /dev/null +++ b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProviderTest.java @@ -0,0 +1,106 @@ +/* + * 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.cluster.plugin.nacos; + +import com.alibaba.nacos.api.naming.NamingFactory; +import com.alibaba.nacos.api.naming.NamingService; +import org.apache.skywalking.oap.server.core.CoreModule; +import org.apache.skywalking.oap.server.core.cluster.ClusterModule; +import org.apache.skywalking.oap.server.library.module.ModuleConfig; +import org.apache.skywalking.oap.server.library.module.ModuleStartException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.reflect.Whitebox; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +/** + * @author caoyixiong + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(NamingFactory.class) +@PowerMockIgnore("javax.management.*") +public class ClusterModuleNacosProviderTest { + + private static final String SERVICE_NAME = "test-service_name"; + + private ClusterModuleNacosProvider provider = new ClusterModuleNacosProvider(); + + @Test + public void name() { + assertEquals("nacos", provider.name()); + } + + @Test + public void module() { + assertEquals(ClusterModule.class, provider.module()); + } + + + @Test + public void createConfigBeanIfAbsent() { + ModuleConfig moduleConfig = provider.createConfigBeanIfAbsent(); + assertTrue(moduleConfig instanceof ClusterModuleNacosConfig); + } + + @Test(expected = ModuleStartException.class) + public void prepareWithNonHost() throws Exception { + provider.prepare(); + } + + @Test + public void prepare() throws Exception { + PowerMockito.mockStatic(NamingFactory.class); + ClusterModuleNacosConfig nacosConfig = new ClusterModuleNacosConfig(); + nacosConfig.setHostPort("10.0.0.1:1000,10.0.0.2:1001"); + nacosConfig.setServiceName(SERVICE_NAME); + Whitebox.setInternalState(provider, "config", nacosConfig); + NamingService namingService = mock(NamingService.class); + PowerMockito.when(NamingFactory.createNamingService("10.0.0.1:1000,10.0.0.2:1001")).thenReturn(namingService); + provider.prepare(); + ArgumentCaptor addressCaptor = ArgumentCaptor.forClass(String.class); + PowerMockito.verifyStatic(); + NamingFactory.createNamingService(addressCaptor.capture()); + String data = addressCaptor.getValue(); + assertEquals("10.0.0.1:1000,10.0.0.2:1001", data); + } + + @Test + public void start() { + provider.start(); + } + + @Test + public void notifyAfterCompleted() { + provider.notifyAfterCompleted(); + } + + @Test + public void requiredModules() { + String[] modules = provider.requiredModules(); + assertArrayEquals(new String[]{CoreModule.NAME}, modules); + } +} diff --git a/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinatorTest.java b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinatorTest.java new file mode 100644 index 000000000000..b362d5a54275 --- /dev/null +++ b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/NacosCoordinatorTest.java @@ -0,0 +1,134 @@ +/* + * 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.cluster.plugin.nacos; + +import com.alibaba.nacos.api.exception.NacosException; +import com.alibaba.nacos.api.naming.NamingService; +import com.alibaba.nacos.api.naming.pojo.Instance; +import org.apache.skywalking.oap.server.core.cluster.RemoteInstance; +import org.apache.skywalking.oap.server.core.remote.client.Address; +import org.junit.Before; +import org.junit.Test; +import org.mockito.ArgumentCaptor; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +/** + * @author caoyixiong + */ +public class NacosCoordinatorTest { + private NamingService namingService = mock(NamingService.class); + private ClusterModuleNacosConfig nacosConfig = new ClusterModuleNacosConfig(); + private NacosCoordinator coordinator; + + private Address remoteAddress = new Address("10.0.0.1", 1000, false); + private Address selfRemoteAddress = new Address("10.0.0.2", 1001, true); + + private static final String SERVICE_NAME = "test-service"; + + @Before + public void setUp() throws NacosException { + nacosConfig.setServiceName(SERVICE_NAME); + coordinator = new NacosCoordinator(namingService, nacosConfig); + } + + @Test + @SuppressWarnings("unchecked") + public void queryRemoteNodesWithNonOrEmpty() throws NacosException { + when(namingService.selectInstances(anyString(), anyBoolean())).thenReturn(null, Collections.emptyList()); + assertEquals(0, coordinator.queryRemoteNodes().size()); + } + + @Test + public void queryRemoteNodes() throws NacosException { + registerSelfRemote(); + List instances = mockInstance(); + when(namingService.selectInstances(anyString(), anyBoolean())).thenReturn(instances); + List remoteInstances = coordinator.queryRemoteNodes(); + assertEquals(2, remoteInstances.size()); + + RemoteInstance selfInstance = remoteInstances.get(0); + validate(selfRemoteAddress, selfInstance); + + RemoteInstance notSelfInstance = remoteInstances.get(1); + validate(remoteAddress, notSelfInstance); + } + + @Test + public void queryRemoteNodesWithNullSelf() throws NacosException { + List instances = mockInstance(); + when(namingService.selectInstances(anyString(), anyBoolean())).thenReturn(instances); + List remoteInstances = coordinator.queryRemoteNodes(); + assertTrue(remoteInstances.isEmpty()); + } + + @Test + public void registerRemote() throws NacosException { + registerRemote(remoteAddress); + } + + @Test + public void registerSelfRemote() throws NacosException { + registerRemote(selfRemoteAddress); + } + + private void validate(Address originArress, RemoteInstance instance) { + Address instanceAddress = instance.getAddress(); + assertEquals(originArress.getHost(), instanceAddress.getHost()); + assertEquals(originArress.getPort(), instanceAddress.getPort()); + } + + private void registerRemote(Address address) throws NacosException { + coordinator.registerRemote(new RemoteInstance(address)); + + ArgumentCaptor serviceNameArgumentCaptor = ArgumentCaptor.forClass(String.class); + ArgumentCaptor hostArgumentCaptor = ArgumentCaptor.forClass(String.class); + ArgumentCaptor portArgumentCaptor = ArgumentCaptor.forClass(Integer.class); + verify(namingService).registerInstance(serviceNameArgumentCaptor.capture(), hostArgumentCaptor.capture(), portArgumentCaptor.capture()); + + assertEquals(SERVICE_NAME, serviceNameArgumentCaptor.getValue()); + assertEquals(address.getHost(), hostArgumentCaptor.getValue()); + assertEquals(Long.valueOf(address.getPort()), Long.valueOf(portArgumentCaptor.getValue())); + } + + private List mockInstance() { + Instance remoteInstance = new Instance(); + Instance selfInstance = new Instance(); + selfInstance.setIp(selfRemoteAddress.getHost()); + selfInstance.setPort(selfRemoteAddress.getPort()); + + remoteInstance.setIp(remoteAddress.getHost()); + remoteInstance.setPort(remoteAddress.getPort()); + + List instances = new ArrayList<>(); + instances.add(selfInstance); + instances.add(remoteInstance); + return instances; + } +} diff --git a/oap-server/server-cluster-plugin/pom.xml b/oap-server/server-cluster-plugin/pom.xml index 153015a1709c..2cd0a94b92c8 100644 --- a/oap-server/server-cluster-plugin/pom.xml +++ b/oap-server/server-cluster-plugin/pom.xml @@ -32,6 +32,7 @@ cluster-standalone-plugin cluster-kubernetes-plugin cluster-consul-plugin + cluster-nacos-plugin diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ServiceQueryException.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ServiceQueryException.java new file mode 100644 index 000000000000..495b8c3b9882 --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ServiceQueryException.java @@ -0,0 +1,29 @@ +/* + * 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.cluster; + +/** + * @author caoyixiong + */ +public class ServiceQueryException extends RuntimeException { + + public ServiceQueryException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/oap-server/server-starter/pom.xml b/oap-server/server-starter/pom.xml index e7d91a53c5aa..44653f9ef63c 100644 --- a/oap-server/server-starter/pom.xml +++ b/oap-server/server-starter/pom.xml @@ -70,6 +70,11 @@ cluster-consul-plugin ${project.version} + + org.apache.skywalking + cluster-nacos-plugin + ${project.version} + diff --git a/oap-server/server-starter/src/main/assembly/application.yml b/oap-server/server-starter/src/main/assembly/application.yml index cd71767a5f16..05edfc04feb5 100644 --- a/oap-server/server-starter/src/main/assembly/application.yml +++ b/oap-server/server-starter/src/main/assembly/application.yml @@ -33,6 +33,9 @@ cluster: # serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"} # Consul cluster nodes, example: 10.0.0.1:8500,10.0.0.2:8500,10.0.0.3:8500 # hostPort: ${SW_CLUSTER_CONSUL_HOST_PORT:localhost:8500} +# nacos: +# serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"} +# hostPort: ${SW_CLUSTER_NACOS_HOST_PORT:localhost:8848} core: default: # Mixed: Receive agent data, Level 1 aggregate, Level 2 aggregate diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-starter/src/main/resources/application.yml index 08ccd0635ebc..ced2d4373b2a 100644 --- a/oap-server/server-starter/src/main/resources/application.yml +++ b/oap-server/server-starter/src/main/resources/application.yml @@ -33,6 +33,9 @@ cluster: # serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"} # Consul cluster nodes, example: 10.0.0.1:8500,10.0.0.2:8500,10.0.0.3:8500 # hostPort: ${SW_CLUSTER_CONSUL_HOST_PORT:localhost:8500} +# nacos: +# serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"} +# hostPort: ${SW_CLUSTER_NACOS_HOST_PORT:localhost:8848} core: default: # Mixed: Receive agent data, Level 1 aggregate, Level 2 aggregate