This is an automated email from the ASF dual-hosted git repository.
sunnianjun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 37a7e03a293 Refactor MetricsWrapper (#23615)
37a7e03a293 is described below
commit 37a7e03a293574b5cde194528fe46dffcb85f3d7
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jan 17 18:50:25 2023 +0800
Refactor MetricsWrapper (#23615)
---
.../core/advice/RouteResultCountAdvice.java | 7 +++---
.../metrics/core/advice/SQLParseCountAdvice.java | 27 +++++++++++----------
.../metrics/core/advice/SQLRouteCountAdvice.java | 11 +++++----
.../proxy/CommitTransactionsCountAdvice.java | 5 ++--
.../proxy/CurrentConnectionsCountAdvice.java | 7 +++---
.../advice/proxy/ExecuteErrorsCountAdvice.java | 5 ++--
.../proxy/ExecuteLatencyHistogramAdvice.java | 5 ++--
.../core/advice/proxy/RequestsCountAdvice.java | 5 ++--
.../proxy/RollbackTransactionsCountAdvice.java | 5 ++--
.../MetricsWrapper.java} | 14 +++--------
.../core/{ => wrapper}/MetricsWrapperFactory.java | 2 +-
.../core/{ => wrapper}/MetricsWrapperRegistry.java | 10 ++++----
.../type/CounterMetricsWrapper.java} | 20 ++++++++++------
.../type/GaugeMetricsWrapper.java} | 28 +++++++---------------
.../type/HistogramMetricsWrapper.java} | 15 ++++++------
.../type/SummaryMetricsWrapper.java} | 15 ++++++------
.../metrics/core/MetricsWrapperRegistryTest.java | 1 +
.../metrics/core/advice/MetricsAdviceBaseTest.java | 2 +-
.../core/advice/RouteResultCountAdviceTest.java | 6 ++---
.../core/advice/SQLParseCountAdviceTest.java | 2 +-
.../core/advice/SQLRouteCountAdviceTest.java | 2 +-
.../proxy/CommitTransactionsCountAdviceTest.java | 2 +-
.../proxy/CurrentConnectionsCountAdviceTest.java | 2 +-
.../advice/proxy/ExecuteErrorsCountAdviceTest.java | 2 +-
.../proxy/ExecuteLatencyHistogramAdviceTest.java | 2 +-
.../core/advice/proxy/RequestsCountAdviceTest.java | 2 +-
.../proxy/RollbackTransactionsCountAdviceTest.java | 2 +-
.../metrics/core/fixture/FixtureWrapper.java | 7 ++++--
.../core/fixture/FixtureWrapperFactory.java | 4 ++--
.../PrometheusPluginLifecycleService.java | 2 +-
.../wrapper/PrometheusWrapperFactory.java | 20 ++++++++--------
...rWrapper.java => PrometheusCounterWrapper.java} | 4 ++--
...ugeWrapper.java => PrometheusGaugeWrapper.java} | 4 ++--
...rapper.java => PrometheusHistogramWrapper.java} | 4 ++--
...yWrapper.java => PrometheusSummaryWrapper.java} | 4 ++--
.../wrapper/PrometheusWrapperFactoryTest.java | 18 +++++++-------
...Test.java => PrometheusCounterWrapperTest.java} | 6 ++---
...erTest.java => PrometheusGaugeWrapperTest.java} | 6 ++---
...st.java => PrometheusHistogramWrapperTest.java} | 6 ++---
...Test.java => PrometheusSummaryWrapperTest.java} | 6 ++---
40 files changed, 151 insertions(+), 146 deletions(-)
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/RouteResultCountAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/RouteResultCountAdvice.java
index 5cd9da45abc..5974881f610 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/RouteResultCountAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/RouteResultCountAdvice.java
@@ -19,7 +19,8 @@ package
org.apache.shardingsphere.agent.plugin.metrics.core.advice;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.CounterMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
import org.apache.shardingsphere.infra.route.context.RouteUnit;
@@ -42,8 +43,8 @@ public final class RouteResultCountAdvice implements
InstanceMethodAdvice {
}
for (RouteUnit each : ((RouteContext) result).getRouteUnits()) {
RouteMapper dataSourceMapper = each.getDataSourceMapper();
-
MetricsWrapperRegistry.get(ROUTED_DATA_SOURCES_METRIC_KEY).inc(dataSourceMapper.getActualName());
- each.getTableMappers().forEach(table ->
MetricsWrapperRegistry.get(ROUTED_TABLES_METRIC_KEY).inc(table.getActualName()));
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(ROUTED_DATA_SOURCES_METRIC_KEY).inc(dataSourceMapper.getActualName());
+ each.getTableMappers().forEach(table ->
MetricsWrapperRegistry.<CounterMetricsWrapper>get(ROUTED_TABLES_METRIC_KEY).inc(table.getActualName()));
}
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLParseCountAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLParseCountAdvice.java
index dd0007942c9..f9e415153dd 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLParseCountAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLParseCountAdvice.java
@@ -19,7 +19,8 @@ package
org.apache.shardingsphere.agent.plugin.metrics.core.advice;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.CounterMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
import org.apache.shardingsphere.distsql.parser.statement.rdl.RDLStatement;
import org.apache.shardingsphere.distsql.parser.statement.rql.RQLStatement;
@@ -74,33 +75,33 @@ public final class SQLParseCountAdvice implements
InstanceMethodAdvice {
private void countSQL(final SQLStatement sqlStatement) {
if (sqlStatement instanceof InsertStatement) {
- MetricsWrapperRegistry.get(PARSED_INSERT_SQL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_INSERT_SQL_METRIC_KEY).inc();
} else if (sqlStatement instanceof UpdateStatement) {
- MetricsWrapperRegistry.get(PARSED_UPDATE_SQL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_UPDATE_SQL_METRIC_KEY).inc();
} else if (sqlStatement instanceof DeleteStatement) {
- MetricsWrapperRegistry.get(PARSED_DELETE_SQL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_DELETE_SQL_METRIC_KEY).inc();
} else if (sqlStatement instanceof SelectStatement) {
- MetricsWrapperRegistry.get(PARSED_SELECT_SQL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_SELECT_SQL_METRIC_KEY).inc();
} else if (sqlStatement instanceof DDLStatement) {
- MetricsWrapperRegistry.get(PARSED_DDL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_DDL_METRIC_KEY).inc();
} else if (sqlStatement instanceof DCLStatement) {
- MetricsWrapperRegistry.get(PARSED_DCL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_DCL_METRIC_KEY).inc();
} else if (sqlStatement instanceof DALStatement) {
- MetricsWrapperRegistry.get(PARSED_DAL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_DAL_METRIC_KEY).inc();
} else if (sqlStatement instanceof TCLStatement) {
- MetricsWrapperRegistry.get(PARSED_TCL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_TCL_METRIC_KEY).inc();
}
}
private void countDistSQL(final SQLStatement sqlStatement) {
if (sqlStatement instanceof RQLStatement) {
- MetricsWrapperRegistry.get(PARSED_RQL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_RQL_METRIC_KEY).inc();
} else if (sqlStatement instanceof RDLStatement) {
- MetricsWrapperRegistry.get(PARSED_RDL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_RDL_METRIC_KEY).inc();
} else if (sqlStatement instanceof RALStatement) {
- MetricsWrapperRegistry.get(PARSED_RAL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_RAL_METRIC_KEY).inc();
} else if (sqlStatement instanceof RULStatement) {
- MetricsWrapperRegistry.get(PARSED_RUL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PARSED_RUL_METRIC_KEY).inc();
}
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdvice.java
index 4e9ed9d82ca..24a9e36da95 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdvice.java
@@ -19,7 +19,8 @@ package
org.apache.shardingsphere.agent.plugin.metrics.core.advice;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.CounterMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import org.apache.shardingsphere.infra.binder.QueryContext;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DeleteStatement;
@@ -47,13 +48,13 @@ public final class SQLRouteCountAdvice implements
InstanceMethodAdvice {
QueryContext queryContext = (QueryContext) args[1];
SQLStatement sqlStatement =
queryContext.getSqlStatementContext().getSqlStatement();
if (sqlStatement instanceof InsertStatement) {
- MetricsWrapperRegistry.get(ROUTED_INSERT_SQL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(ROUTED_INSERT_SQL_METRIC_KEY).inc();
} else if (sqlStatement instanceof UpdateStatement) {
- MetricsWrapperRegistry.get(ROUTED_UPDATE_SQL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(ROUTED_UPDATE_SQL_METRIC_KEY).inc();
} else if (sqlStatement instanceof DeleteStatement) {
- MetricsWrapperRegistry.get(ROUTED_DELETE_SQL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(ROUTED_DELETE_SQL_METRIC_KEY).inc();
} else if (sqlStatement instanceof SelectStatement) {
- MetricsWrapperRegistry.get(ROUTED_SELECT_SQL_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(ROUTED_SELECT_SQL_METRIC_KEY).inc();
}
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CommitTransactionsCountAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CommitTransactionsCountAdvice.java
index 4a619787021..597f1a629a8 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CommitTransactionsCountAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CommitTransactionsCountAdvice.java
@@ -19,7 +19,8 @@ package
org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.CounterMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import java.lang.reflect.Method;
@@ -32,6 +33,6 @@ public final class CommitTransactionsCountAdvice implements
InstanceMethodAdvice
@Override
public void beforeMethod(final TargetAdviceObject target, final Method
method, final Object[] args) {
- MetricsWrapperRegistry.get(PROXY_COMMIT_TRANSACTIONS_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PROXY_COMMIT_TRANSACTIONS_METRIC_KEY).inc();
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdvice.java
index faee28ae9d6..d5ce8f85a74 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdvice.java
@@ -19,7 +19,8 @@ package
org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.GaugeMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import java.lang.reflect.Method;
@@ -34,10 +35,10 @@ public final class CurrentConnectionsCountAdvice implements
InstanceMethodAdvice
public void beforeMethod(final TargetAdviceObject target, final Method
method, final Object[] args) {
switch (method.getName()) {
case "channelActive":
-
MetricsWrapperRegistry.get(PROXY_CURRENT_CONNECTIONS_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<GaugeMetricsWrapper>get(PROXY_CURRENT_CONNECTIONS_METRIC_KEY).inc();
break;
case "channelInactive":
-
MetricsWrapperRegistry.get(PROXY_CURRENT_CONNECTIONS_METRIC_KEY).dec();
+
MetricsWrapperRegistry.<GaugeMetricsWrapper>get(PROXY_CURRENT_CONNECTIONS_METRIC_KEY).dec();
break;
default:
break;
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteErrorsCountAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteErrorsCountAdvice.java
index 81749dafa0c..38cf1e75379 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteErrorsCountAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteErrorsCountAdvice.java
@@ -19,7 +19,8 @@ package
org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.CounterMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import java.lang.reflect.Method;
@@ -32,6 +33,6 @@ public final class ExecuteErrorsCountAdvice implements
InstanceMethodAdvice {
@Override
public void afterMethod(final TargetAdviceObject target, final Method
method, final Object[] args, final Object result) {
- MetricsWrapperRegistry.get(PROXY_EXECUTE_ERRORS_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PROXY_EXECUTE_ERRORS_METRIC_KEY).inc();
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteLatencyHistogramAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteLatencyHistogramAdvice.java
index e7cf0de8e8d..a2e1178878d 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteLatencyHistogramAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteLatencyHistogramAdvice.java
@@ -20,7 +20,8 @@ package
org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
import org.apache.shardingsphere.agent.plugin.core.recorder.MethodTimeRecorder;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.HistogramMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import java.lang.reflect.Method;
@@ -40,6 +41,6 @@ public final class ExecuteLatencyHistogramAdvice implements
InstanceMethodAdvice
@Override
public void afterMethod(final TargetAdviceObject target, final Method
method, final Object[] args, final Object result) {
-
MetricsWrapperRegistry.get(PROXY_EXECUTE_LATENCY_MILLIS_METRIC_KEY).observe(methodTimeRecorder.getElapsedTimeAndClean(method));
+
MetricsWrapperRegistry.<HistogramMetricsWrapper>get(PROXY_EXECUTE_LATENCY_MILLIS_METRIC_KEY).observe(methodTimeRecorder.getElapsedTimeAndClean(method));
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RequestsCountAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RequestsCountAdvice.java
index 35a8eb285a1..2adbc3295ce 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RequestsCountAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RequestsCountAdvice.java
@@ -19,7 +19,8 @@ package
org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.CounterMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import java.lang.reflect.Method;
@@ -32,6 +33,6 @@ public final class RequestsCountAdvice implements
InstanceMethodAdvice {
@Override
public void beforeMethod(final TargetAdviceObject target, final Method
method, final Object[] args) {
- MetricsWrapperRegistry.get(PROXY_REQUESTS_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PROXY_REQUESTS_METRIC_KEY).inc();
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RollbackTransactionsCountAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RollbackTransactionsCountAdvice.java
index 204c1731005..4e4e037c110 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RollbackTransactionsCountAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RollbackTransactionsCountAdvice.java
@@ -19,7 +19,8 @@ package
org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.CounterMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import java.lang.reflect.Method;
@@ -32,6 +33,6 @@ public final class RollbackTransactionsCountAdvice implements
InstanceMethodAdvi
@Override
public void beforeMethod(final TargetAdviceObject target, final Method
method, final Object[] args) {
-
MetricsWrapperRegistry.get(PROXY_ROLLBACK_TRANSACTIONS_METRIC_KEY).inc();
+
MetricsWrapperRegistry.<CounterMetricsWrapper>get(PROXY_ROLLBACK_TRANSACTIONS_METRIC_KEY).inc();
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/MetricsWrapper.java
similarity index 73%
copy from
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
copy to
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/MetricsWrapper.java
index 33895788d16..ba77d990da6 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/MetricsWrapper.java
@@ -15,18 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.plugin.metrics.core;
+package org.apache.shardingsphere.agent.plugin.metrics.core.wrapper;
/**
- * Metrics wrapper factory.
+ * Metrics wrapper.
*/
-public interface MetricsWrapperFactory {
-
- /**
- * Create metrics wrapper.
- *
- * @param id metrics wrapper ID
- * @return metrics wrapper
- */
- MetricsWrapper create(String id);
+public interface MetricsWrapper {
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/MetricsWrapperFactory.java
similarity index 93%
copy from
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
copy to
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/MetricsWrapperFactory.java
index 33895788d16..62f3f059648 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/MetricsWrapperFactory.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.plugin.metrics.core;
+package org.apache.shardingsphere.agent.plugin.metrics.core.wrapper;
/**
* Metrics wrapper factory.
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperRegistry.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/MetricsWrapperRegistry.java
similarity index 81%
rename from
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperRegistry.java
rename to
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/MetricsWrapperRegistry.java
index 091a861477e..c02595d04e8 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperRegistry.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/MetricsWrapperRegistry.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.plugin.metrics.core;
+package org.apache.shardingsphere.agent.plugin.metrics.core.wrapper;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -42,11 +42,13 @@ public final class MetricsWrapperRegistry {
* Get metrics wrapper.
*
* @param id metric ID
+ * @param <T> type of metrics wrapper
* @return metrics wrapper
* @see <a
href="https://bugs.openjdk.java.net/browse/JDK-8161372">JDK-8161372</a>
*/
- public static MetricsWrapper get(final String id) {
- MetricsWrapper result = METRICS_WRAPPERS.get(id);
- return null == result ? METRICS_WRAPPERS.computeIfAbsent(id,
metricsWrapperFactory::create) : result;
+ @SuppressWarnings("unchecked")
+ public static <T extends MetricsWrapper> T get(final String id) {
+ T result = (T) METRICS_WRAPPERS.get(id);
+ return (T) (null == result ? METRICS_WRAPPERS.computeIfAbsent(id,
metricsWrapperFactory::create) : result);
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/CounterMetricsWrapper.java
similarity index 67%
copy from
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
copy to
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/CounterMetricsWrapper.java
index 33895788d16..fa085ab329b 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/CounterMetricsWrapper.java
@@ -15,18 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.plugin.metrics.core;
+package org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type;
+
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapper;
/**
- * Metrics wrapper factory.
+ * Counter metrics wrapper.
*/
-public interface MetricsWrapperFactory {
+public interface CounterMetricsWrapper extends MetricsWrapper {
+
+ /**
+ * Metric increase.
+ */
+ void inc();
/**
- * Create metrics wrapper.
+ * Metric increase with labels.
*
- * @param id metrics wrapper ID
- * @return metrics wrapper
+ * @param labels labels
*/
- MetricsWrapper create(String id);
+ void inc(String... labels);
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapper.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/GaugeMetricsWrapper.java
similarity index 73%
rename from
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapper.java
rename to
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/GaugeMetricsWrapper.java
index f0b8962dfb9..4a3a852ea87 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapper.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/GaugeMetricsWrapper.java
@@ -15,46 +15,36 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.plugin.metrics.core;
+package org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type;
+
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapper;
/**
- * Metrics wrapper.
+ * Gauge metrics wrapper.
*/
-public interface MetricsWrapper {
+public interface GaugeMetricsWrapper extends MetricsWrapper {
/**
* Metric increase.
*/
- default void inc() {
- }
+ void inc();
/**
* Metric increase with labels.
*
* @param labels labels
*/
- default void inc(String... labels) {
- }
+ void inc(String... labels);
/**
* Metric decrease.
*/
- default void dec() {
- }
+ void dec();
/**
* Metric decrease with labels.
*
* @param labels counter labels
*/
- default void dec(String... labels) {
- }
-
- /**
- * Observed by value.
- *
- * @param value value
- */
- default void observe(double value) {
- }
+ void dec(String... labels);
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/HistogramMetricsWrapper.java
similarity index 71%
copy from
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
copy to
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/HistogramMetricsWrapper.java
index 33895788d16..489d28e3bab 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/HistogramMetricsWrapper.java
@@ -15,18 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.plugin.metrics.core;
+package org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type;
+
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapper;
/**
- * Metrics wrapper factory.
+ * Histogram metrics wrapper.
*/
-public interface MetricsWrapperFactory {
+public interface HistogramMetricsWrapper extends MetricsWrapper {
/**
- * Create metrics wrapper.
+ * Observed by value.
*
- * @param id metrics wrapper ID
- * @return metrics wrapper
+ * @param value value
*/
- MetricsWrapper create(String id);
+ void observe(double value);
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/SummaryMetricsWrapper.java
similarity index 71%
rename from
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
rename to
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/SummaryMetricsWrapper.java
index 33895788d16..6eb885ddf99 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperFactory.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/wrapper/type/SummaryMetricsWrapper.java
@@ -15,18 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.agent.plugin.metrics.core;
+package org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type;
+
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapper;
/**
- * Metrics wrapper factory.
+ * Summary metrics wrapper.
*/
-public interface MetricsWrapperFactory {
+public interface SummaryMetricsWrapper extends MetricsWrapper {
/**
- * Create metrics wrapper.
+ * Observed by value.
*
- * @param id metrics wrapper ID
- * @return metrics wrapper
+ * @param value value
*/
- MetricsWrapper create(String id);
+ void observe(double value);
}
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperRegistryTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperRegistryTest.java
index 47f845d3d7e..1d4e5577f59 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperRegistryTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsWrapperRegistryTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.agent.plugin.metrics.core;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapperFactory;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/MetricsAdviceBaseTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/MetricsAdviceBaseTest.java
index 1138102a841..2f19fb5590b 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/MetricsAdviceBaseTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/MetricsAdviceBaseTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapperFactory;
import org.junit.BeforeClass;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/RouteResultCountAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/RouteResultCountAdviceTest.java
index 0de4e3ec34c..1c02ce5206f 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/RouteResultCountAdviceTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/RouteResultCountAdviceTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
import org.apache.shardingsphere.infra.route.context.RouteContext;
import org.apache.shardingsphere.infra.route.context.RouteMapper;
@@ -47,9 +47,9 @@ public final class RouteResultCountAdviceTest extends
MetricsAdviceBaseTest {
RouteMapper tableMapper = new RouteMapper("t_order", "t_order_0");
routeContext.getRouteUnits().add(new RouteUnit(dataSourceMapper,
Collections.singleton(tableMapper)));
new RouteResultCountAdvice().afterMethod(new MockTargetAdviceObject(),
mock(Method.class), new Object[]{}, routeContext);
- FixtureWrapper wrapper = (FixtureWrapper)
MetricsWrapperRegistry.get("routed_data_sources_total");
+ FixtureWrapper wrapper =
MetricsWrapperRegistry.get("routed_data_sources_total");
assertThat(wrapper.getFixtureValue(), is(1d));
- wrapper = (FixtureWrapper)
MetricsWrapperRegistry.get("routed_tables_total");
+ wrapper = MetricsWrapperRegistry.get("routed_tables_total");
assertThat(wrapper.getFixtureValue(), is(1d));
}
}
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLParseCountAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLParseCountAdviceTest.java
index fd87e7852be..7cb81400a31 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLParseCountAdviceTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLParseCountAdviceTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
import
org.apache.shardingsphere.distsql.parser.statement.rdl.create.RegisterStorageUnitStatement;
import
org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowStorageUnitsStatement;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
index 4cade5177d3..b47c1319235 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/SQLRouteCountAdviceTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
import org.apache.shardingsphere.infra.binder.QueryContext;
import
org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CommitTransactionsCountAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CommitTransactionsCountAdviceTest.java
index f3383eed828..68c6a8f9db4 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CommitTransactionsCountAdviceTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CommitTransactionsCountAdviceTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MetricsAdviceBaseTest;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MockTargetAdviceObject;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdviceTest.java
index cff64cb8cea..fd9925ed109 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdviceTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdviceTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MetricsAdviceBaseTest;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MockTargetAdviceObject;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteErrorsCountAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteErrorsCountAdviceTest.java
index a9f6556cd31..988afbeedd5 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteErrorsCountAdviceTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteErrorsCountAdviceTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MetricsAdviceBaseTest;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MockTargetAdviceObject;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteLatencyHistogramAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteLatencyHistogramAdviceTest.java
index 9514639784b..f708ea450a8 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteLatencyHistogramAdviceTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/ExecuteLatencyHistogramAdviceTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MetricsAdviceBaseTest;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MockTargetAdviceObject;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RequestsCountAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RequestsCountAdviceTest.java
index 0386f626d71..68aa2d8e534 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RequestsCountAdviceTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RequestsCountAdviceTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MetricsAdviceBaseTest;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MockTargetAdviceObject;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RollbackTransactionsCountAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RollbackTransactionsCountAdviceTest.java
index ddeb513b4a4..75f734805aa 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RollbackTransactionsCountAdviceTest.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/RollbackTransactionsCountAdviceTest.java
@@ -17,7 +17,7 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MetricsAdviceBaseTest;
import
org.apache.shardingsphere.agent.plugin.metrics.core.advice.MockTargetAdviceObject;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/fixture/FixtureWrapper.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/fixture/FixtureWrapper.java
index 4b21c14ded8..688e72e47ab 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/fixture/FixtureWrapper.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/fixture/FixtureWrapper.java
@@ -18,13 +18,16 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.fixture;
import lombok.Getter;
-import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.CounterMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.GaugeMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.HistogramMetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.SummaryMetricsWrapper;
/**
* Fixed metric wrapper.
*/
@Getter
-public final class FixtureWrapper implements MetricsWrapper {
+public final class FixtureWrapper implements CounterMetricsWrapper,
GaugeMetricsWrapper, HistogramMetricsWrapper, SummaryMetricsWrapper {
private Double fixtureValue = 0d;
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/fixture/FixtureWrapperFactory.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/fixture/FixtureWrapperFactory.java
index 9ae64da1be5..32860d7063c 100644
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/fixture/FixtureWrapperFactory.java
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/fixture/FixtureWrapperFactory.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.fixture;
-import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapper;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperFactory;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperFactory;
public final class FixtureWrapperFactory implements MetricsWrapperFactory {
diff --git
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/PrometheusPluginLifecycleService.java
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/PrometheusPluginLifecycleService.java
index 1498d56c44b..7bde9a98a99 100644
---
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/PrometheusPluginLifecycleService.java
+++
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/PrometheusPluginLifecycleService.java
@@ -23,7 +23,7 @@ import io.prometheus.client.exporter.HTTPServer;
import io.prometheus.client.hotspot.DefaultExports;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.agent.api.PluginConfiguration;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperRegistry;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperRegistry;
import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.collector.BuildInfoCollector;
import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.collector.proxy.ProxyMetaDataInfoCollector;
import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.collector.proxy.ProxyStateCollector;
diff --git
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/PrometheusWrapperFactory.java
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/PrometheusWrapperFactory.java
index b2c218f99b3..1618f9b2893 100644
---
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/PrometheusWrapperFactory.java
+++
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/PrometheusWrapperFactory.java
@@ -22,16 +22,16 @@ import io.prometheus.client.Gauge;
import io.prometheus.client.GaugeMetricFamily;
import io.prometheus.client.Histogram;
import io.prometheus.client.Summary;
-import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapper;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapperFactory;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.MetricsWrapperFactory;
import
org.apache.shardingsphere.agent.plugin.metrics.core.config.MetricConfiguration;
import
org.apache.shardingsphere.agent.plugin.metrics.core.config.MetricsConfiguration;
import
org.apache.shardingsphere.agent.plugin.metrics.core.config.yaml.loader.YamlMetricConfigurationsLoader;
import
org.apache.shardingsphere.agent.plugin.metrics.core.config.yaml.swapper.YamlMetricsConfigurationSwapper;
-import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.CounterWrapper;
-import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.GaugeWrapper;
-import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.HistogramWrapper;
-import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.SummaryWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.PrometheusCounterWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.PrometheusGaugeWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.PrometheusHistogramWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.PrometheusSummaryWrapper;
import java.util.List;
import java.util.Map;
@@ -77,7 +77,7 @@ public final class PrometheusWrapperFactory implements
MetricsWrapperFactory {
if (!labels.isEmpty()) {
builder.labelNames(labels.toArray(new String[0]));
}
- return new CounterWrapper(builder.register());
+ return new PrometheusCounterWrapper(builder.register());
}
private MetricsWrapper createGauge(final MetricConfiguration metricConfig)
{
@@ -86,7 +86,7 @@ public final class PrometheusWrapperFactory implements
MetricsWrapperFactory {
if (!labels.isEmpty()) {
builder.labelNames(labels.toArray(new String[0]));
}
- return new GaugeWrapper(builder.register());
+ return new PrometheusGaugeWrapper(builder.register());
}
private MetricsWrapper createHistogram(final MetricConfiguration
metricConfig) {
@@ -99,7 +99,7 @@ public final class PrometheusWrapperFactory implements
MetricsWrapperFactory {
if (!props.isEmpty()) {
parseHistogramProperties(builder, props);
}
- return new HistogramWrapper(builder.register());
+ return new PrometheusHistogramWrapper(builder.register());
}
@SuppressWarnings("unchecked")
@@ -127,7 +127,7 @@ public final class PrometheusWrapperFactory implements
MetricsWrapperFactory {
if (!labels.isEmpty()) {
builder.labelNames(labels.toArray(new String[0]));
}
- return new SummaryWrapper(builder.register());
+ return new PrometheusSummaryWrapper(builder.register());
}
/**
diff --git
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/CounterWrapper.java
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusCounterWrapper.java
similarity index 87%
rename from
agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/CounterWrapper.java
rename to
agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusCounterWrapper.java
index 8c81afefafc..04e64459d50 100644
---
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/CounterWrapper.java
+++
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusCounterWrapper.java
@@ -19,13 +19,13 @@ package
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type;
import io.prometheus.client.Counter;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.CounterMetricsWrapper;
/**
* Prometheus counter wrapper.
*/
@RequiredArgsConstructor
-public final class CounterWrapper implements MetricsWrapper {
+public final class PrometheusCounterWrapper implements CounterMetricsWrapper {
private final Counter counter;
diff --git
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/GaugeWrapper.java
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusGaugeWrapper.java
similarity index 89%
rename from
agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/GaugeWrapper.java
rename to
agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusGaugeWrapper.java
index d3c7db897df..830d51cb3c8 100644
---
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/GaugeWrapper.java
+++
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusGaugeWrapper.java
@@ -19,13 +19,13 @@ package
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type;
import io.prometheus.client.Gauge;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.GaugeMetricsWrapper;
/**
* Prometheus gauge wrapper.
*/
@RequiredArgsConstructor
-public final class GaugeWrapper implements MetricsWrapper {
+public final class PrometheusGaugeWrapper implements GaugeMetricsWrapper {
private final Gauge gauge;
diff --git
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/HistogramWrapper.java
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusHistogramWrapper.java
similarity index 86%
rename from
agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/HistogramWrapper.java
rename to
agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusHistogramWrapper.java
index 27e70fc303f..73990c53494 100644
---
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/HistogramWrapper.java
+++
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusHistogramWrapper.java
@@ -19,13 +19,13 @@ package
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type;
import io.prometheus.client.Histogram;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.HistogramMetricsWrapper;
/**
* Prometheus histogram wrapper.
*/
@RequiredArgsConstructor
-public final class HistogramWrapper implements MetricsWrapper {
+public final class PrometheusHistogramWrapper implements
HistogramMetricsWrapper {
private final Histogram histogram;
diff --git
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/SummaryWrapper.java
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusSummaryWrapper.java
similarity index 87%
rename from
agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/SummaryWrapper.java
rename to
agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusSummaryWrapper.java
index f615172f8bf..ddb18cad8ff 100644
---
a/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/SummaryWrapper.java
+++
b/agent/plugins/metrics/type/prometheus/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusSummaryWrapper.java
@@ -19,13 +19,13 @@ package
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type;
import io.prometheus.client.Summary;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.wrapper.type.SummaryMetricsWrapper;
/**
* Prometheus summary wrapper.
*/
@RequiredArgsConstructor
-public final class SummaryWrapper implements MetricsWrapper {
+public final class PrometheusSummaryWrapper implements SummaryMetricsWrapper {
private final Summary summary;
diff --git
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/PrometheusWrapperFactoryTest.java
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/PrometheusWrapperFactoryTest.java
index 8275d92fe20..118260288db 100644
---
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/PrometheusWrapperFactoryTest.java
+++
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/PrometheusWrapperFactoryTest.java
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper;
-import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.CounterWrapper;
-import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.GaugeWrapper;
-import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.HistogramWrapper;
-import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.SummaryWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.PrometheusCounterWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.PrometheusGaugeWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.PrometheusHistogramWrapper;
+import
org.apache.shardingsphere.agent.plugin.metrics.prometheus.wrapper.type.PrometheusSummaryWrapper;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
@@ -31,10 +31,10 @@ public final class PrometheusWrapperFactoryTest {
@Test
public void assertCreate() {
PrometheusWrapperFactory factory = new PrometheusWrapperFactory();
- assertThat(factory.create("a"), instanceOf(CounterWrapper.class));
- assertThat(factory.create("b"), instanceOf(GaugeWrapper.class));
- assertThat(factory.create("c"), instanceOf(HistogramWrapper.class));
- assertThat(factory.create("d"), instanceOf(HistogramWrapper.class));
- assertThat(factory.create("e"), instanceOf(SummaryWrapper.class));
+ assertThat(factory.create("a"),
instanceOf(PrometheusCounterWrapper.class));
+ assertThat(factory.create("b"),
instanceOf(PrometheusGaugeWrapper.class));
+ assertThat(factory.create("c"),
instanceOf(PrometheusHistogramWrapper.class));
+ assertThat(factory.create("d"),
instanceOf(PrometheusHistogramWrapper.class));
+ assertThat(factory.create("e"),
instanceOf(PrometheusSummaryWrapper.class));
}
}
diff --git
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/CounterWrapperTest.java
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusCounterWrapperTest.java
similarity index 82%
rename from
agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/CounterWrapperTest.java
rename to
agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusCounterWrapperTest.java
index 2607f102fed..6e59186b0e3 100644
---
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/CounterWrapperTest.java
+++
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusCounterWrapperTest.java
@@ -24,14 +24,14 @@ import org.mockito.internal.configuration.plugins.Plugins;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-public final class CounterWrapperTest {
+public final class PrometheusCounterWrapperTest {
@Test
public void assertCreate() throws ReflectiveOperationException {
Counter counter = Counter.build().name("a").help("help").create();
- CounterWrapper counterWrapper = new CounterWrapper(counter);
+ PrometheusCounterWrapper counterWrapper = new
PrometheusCounterWrapper(counter);
counterWrapper.inc();
- counter = (Counter)
Plugins.getMemberAccessor().get(CounterWrapper.class.getDeclaredField("counter"),
counterWrapper);
+ counter = (Counter)
Plugins.getMemberAccessor().get(PrometheusCounterWrapper.class.getDeclaredField("counter"),
counterWrapper);
assertThat(counter.get(), is(1d));
}
}
diff --git
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/GaugeWrapperTest.java
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusGaugeWrapperTest.java
similarity index 83%
rename from
agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/GaugeWrapperTest.java
rename to
agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusGaugeWrapperTest.java
index c5a304cea82..44ada954f67 100644
---
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/GaugeWrapperTest.java
+++
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusGaugeWrapperTest.java
@@ -24,14 +24,14 @@ import org.mockito.internal.configuration.plugins.Plugins;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-public final class GaugeWrapperTest {
+public final class PrometheusGaugeWrapperTest {
@Test
public void assertCreate() throws ReflectiveOperationException {
Gauge gauge = Gauge.build().name("a").help("help").create();
- GaugeWrapper gaugeWrapper = new GaugeWrapper(gauge);
+ PrometheusGaugeWrapper gaugeWrapper = new
PrometheusGaugeWrapper(gauge);
gaugeWrapper.inc();
- gauge = (Gauge)
Plugins.getMemberAccessor().get(GaugeWrapper.class.getDeclaredField("gauge"),
gaugeWrapper);
+ gauge = (Gauge)
Plugins.getMemberAccessor().get(PrometheusGaugeWrapper.class.getDeclaredField("gauge"),
gaugeWrapper);
assertThat(gauge.get(), is(1d));
}
}
diff --git
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/HistogramWrapperTest.java
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusHistogramWrapperTest.java
similarity index 86%
rename from
agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/HistogramWrapperTest.java
rename to
agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusHistogramWrapperTest.java
index 0fef3b9e61d..64e865d98c7 100644
---
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/HistogramWrapperTest.java
+++
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusHistogramWrapperTest.java
@@ -24,14 +24,14 @@ import org.mockito.internal.configuration.plugins.Plugins;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-public final class HistogramWrapperTest {
+public final class PrometheusHistogramWrapperTest {
@Test
public void assertCreate() throws ReflectiveOperationException {
Histogram histogram =
Histogram.build().name("a").help("help").create();
- HistogramWrapper histogramWrapper = new HistogramWrapper(histogram);
+ PrometheusHistogramWrapper histogramWrapper = new
PrometheusHistogramWrapper(histogram);
histogramWrapper.observe(1);
- histogram = (Histogram)
Plugins.getMemberAccessor().get(HistogramWrapper.class.getDeclaredField("histogram"),
histogramWrapper);
+ histogram = (Histogram)
Plugins.getMemberAccessor().get(PrometheusHistogramWrapper.class.getDeclaredField("histogram"),
histogramWrapper);
assertThat(histogram.collect().size(), is(1));
}
}
diff --git
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/SummaryWrapperTest.java
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusSummaryWrapperTest.java
similarity index 83%
rename from
agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/SummaryWrapperTest.java
rename to
agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusSummaryWrapperTest.java
index b01975c7721..b0d514aeb41 100644
---
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/SummaryWrapperTest.java
+++
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/wrapper/type/PrometheusSummaryWrapperTest.java
@@ -24,13 +24,13 @@ import org.mockito.internal.configuration.plugins.Plugins;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-public final class SummaryWrapperTest {
+public final class PrometheusSummaryWrapperTest {
@Test
public void assertCreate() throws ReflectiveOperationException {
- SummaryWrapper summaryWrapper = new
SummaryWrapper(Summary.build().name("a").help("help").create());
+ PrometheusSummaryWrapper summaryWrapper = new
PrometheusSummaryWrapper(Summary.build().name("a").help("help").create());
summaryWrapper.observe(1);
- Summary summary = (Summary)
Plugins.getMemberAccessor().get(SummaryWrapper.class.getDeclaredField("summary"),
summaryWrapper);
+ Summary summary = (Summary)
Plugins.getMemberAccessor().get(PrometheusSummaryWrapper.class.getDeclaredField("summary"),
summaryWrapper);
assertThat(summary.collect().size(), is(1));
}
}