This is an automated email from the ASF dual-hosted git repository.

zhaojinchao 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 1bd9733b91f Rename CurrentConnectionsCountAdvice and 
TotalRequestsCountAdvice (#23451)
1bd9733b91f is described below

commit 1bd9733b91ff65c8582121ddf28dffb8e597208d
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jan 10 00:26:18 2023 +0800

    Rename CurrentConnectionsCountAdvice and TotalRequestsCountAdvice (#23451)
    
    * Move CurrentConnectionCountAdvice and RequestCountAdvice to proxy package
    
    * Rename CurrentConnectionsCountAdvice and TotalRequestsCountAdvice
---
 .../CurrentConnectionsCountAdvice.java}                      | 12 ++++++------
 .../TotalRequestsCountAdvice.java}                           | 10 +++++-----
 .../agent/plugin/metrics/core/constant/MetricIds.java        |  4 ++--
 .../plugin/metrics/core/advice/MetricsAdviceBaseTest.java    |  4 ++--
 .../CurrentConnectionsCountAdviceTest.java}                  | 12 +++++++-----
 .../TotalRequestsCountAdviceTest.java}                       | 12 +++++++-----
 .../resources/META-INF/conf/prometheus-proxy-advisors.yaml   |  4 ++--
 7 files changed, 31 insertions(+), 27 deletions(-)

diff --git 
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyConnectionCountAdvice.java
 
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdvice.java
similarity index 79%
rename from 
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyConnectionCountAdvice.java
rename to 
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdvice.java
index be903cf8af8..f408be825ff 100644
--- 
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyConnectionCountAdvice.java
+++ 
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdvice.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
+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;
@@ -26,22 +26,22 @@ import 
org.apache.shardingsphere.agent.plugin.metrics.core.constant.MetricIds;
 import java.lang.reflect.Method;
 
 /**
- * Proxy connection count advice.
+ * Current connections count advice for ShardingSphere-Proxy.
  */
-public final class ProxyConnectionCountAdvice implements InstanceMethodAdvice {
+public final class CurrentConnectionsCountAdvice implements 
InstanceMethodAdvice {
     
     static {
-        MetricsPool.create(MetricIds.PROXY_COLLECTION);
+        MetricsPool.create(MetricIds.CURRENT_PROXY_CONNECTIONS);
     }
     
     @Override
     public void beforeMethod(final TargetAdviceObject target, final Method 
method, final Object[] args) {
         switch (method.getName()) {
             case "channelActive":
-                
MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(MetricsWrapper::inc);
+                
MetricsPool.get(MetricIds.CURRENT_PROXY_CONNECTIONS).ifPresent(MetricsWrapper::inc);
                 break;
             case "channelInactive":
-                
MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(MetricsWrapper::dec);
+                
MetricsPool.get(MetricIds.CURRENT_PROXY_CONNECTIONS).ifPresent(MetricsWrapper::dec);
                 break;
             default:
                 break;
diff --git 
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyRequestCountAdvice.java
 
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/TotalRequestsCountAdvice.java
similarity index 83%
rename from 
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyRequestCountAdvice.java
rename to 
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/TotalRequestsCountAdvice.java
index 1c38f5898f0..dcf0f815703 100644
--- 
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyRequestCountAdvice.java
+++ 
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/TotalRequestsCountAdvice.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
+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;
@@ -26,16 +26,16 @@ import 
org.apache.shardingsphere.agent.plugin.metrics.core.constant.MetricIds;
 import java.lang.reflect.Method;
 
 /**
- * Proxy request count advice.
+ * Total requests count advice for ShardingSphere-Proxy.
  */
-public final class ProxyRequestCountAdvice implements InstanceMethodAdvice {
+public final class TotalRequestsCountAdvice implements InstanceMethodAdvice {
     
     static {
-        MetricsPool.create(MetricIds.PROXY_REQUEST);
+        MetricsPool.create(MetricIds.TOTAL_PROXY_REQUESTS);
     }
     
     @Override
     public void beforeMethod(final TargetAdviceObject target, final Method 
method, final Object[] args) {
-        
MetricsPool.get(MetricIds.PROXY_REQUEST).ifPresent(MetricsWrapper::inc);
+        
MetricsPool.get(MetricIds.TOTAL_PROXY_REQUESTS).ifPresent(MetricsWrapper::inc);
     }
 }
diff --git 
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/constant/MetricIds.java
 
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/constant/MetricIds.java
index 639c248a5fc..5694d68065a 100644
--- 
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/constant/MetricIds.java
+++ 
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/constant/MetricIds.java
@@ -22,9 +22,9 @@ package 
org.apache.shardingsphere.agent.plugin.metrics.core.constant;
  */
 public final class MetricIds {
     
-    public static final String PROXY_REQUEST = "proxy_request_total";
+    public static final String TOTAL_PROXY_REQUESTS = "proxy_request_total";
     
-    public static final String PROXY_COLLECTION = "proxy_connection_total";
+    public static final String CURRENT_PROXY_CONNECTIONS = 
"proxy_connection_total";
     
     public static final String PROXY_EXECUTE_LATENCY_MILLIS = 
"proxy_execute_latency_millis";
     
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 7690b63ee6e..dca0be3f61a 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
@@ -33,7 +33,7 @@ public abstract class MetricsAdviceBaseTest {
     
     @After
     public void reset() {
-        MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(optional -> 
((FixtureWrapper) optional).reset());
-        MetricsPool.get(MetricIds.PROXY_REQUEST).ifPresent(optional -> 
((FixtureWrapper) optional).reset());
+        
MetricsPool.get(MetricIds.CURRENT_PROXY_CONNECTIONS).ifPresent(optional -> 
((FixtureWrapper) optional).reset());
+        MetricsPool.get(MetricIds.TOTAL_PROXY_REQUESTS).ifPresent(optional -> 
((FixtureWrapper) optional).reset());
     }
 }
diff --git 
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyConnectionCountAdviceTest.java
 
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdviceTest.java
similarity index 77%
rename from 
agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyConnectionCountAdviceTest.java
rename to 
agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdviceTest.java
index 9b8b9a089f6..43e6544a172 100644
--- 
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyConnectionCountAdviceTest.java
+++ 
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/CurrentConnectionsCountAdviceTest.java
@@ -15,9 +15,11 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
+package org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
 
 import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsPool;
+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.constant.MetricIds;
 import 
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
 import org.junit.Test;
@@ -30,9 +32,9 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-public final class ProxyConnectionCountAdviceTest extends 
MetricsAdviceBaseTest {
+public final class CurrentConnectionsCountAdviceTest extends 
MetricsAdviceBaseTest {
     
-    private final ProxyConnectionCountAdvice advice = new 
ProxyConnectionCountAdvice();
+    private final CurrentConnectionsCountAdvice advice = new 
CurrentConnectionsCountAdvice();
     
     @Test
     public void assertBeforeMethod() {
@@ -40,8 +42,8 @@ public final class ProxyConnectionCountAdviceTest extends 
MetricsAdviceBaseTest
         advice.beforeMethod(targetObject, mockMethod("channelActive"), new 
Object[]{});
         advice.beforeMethod(targetObject, mockMethod("channelActive"), new 
Object[]{});
         advice.beforeMethod(targetObject, mockMethod("channelInactive"), new 
Object[]{});
-        assertTrue(MetricsPool.get(MetricIds.PROXY_COLLECTION).isPresent());
-        assertThat(((FixtureWrapper) 
MetricsPool.get(MetricIds.PROXY_COLLECTION).get()).getFixtureValue(), is(1d));
+        
assertTrue(MetricsPool.get(MetricIds.CURRENT_PROXY_CONNECTIONS).isPresent());
+        assertThat(((FixtureWrapper) 
MetricsPool.get(MetricIds.CURRENT_PROXY_CONNECTIONS).get()).getFixtureValue(), 
is(1d));
     }
     
     private Method mockMethod(final String methodName) {
diff --git 
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyRequestCountAdviceTest.java
 
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/TotalRequestsCountAdviceTest.java
similarity index 73%
rename from 
agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyRequestCountAdviceTest.java
rename to 
agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/TotalRequestsCountAdviceTest.java
index fcee052c439..4d1f263a7ff 100644
--- 
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ProxyRequestCountAdviceTest.java
+++ 
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/proxy/TotalRequestsCountAdviceTest.java
@@ -15,9 +15,11 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
+package org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy;
 
 import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsPool;
+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.constant.MetricIds;
 import 
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
 import org.junit.Test;
@@ -29,15 +31,15 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 
-public final class ProxyRequestCountAdviceTest extends MetricsAdviceBaseTest {
+public final class TotalRequestsCountAdviceTest extends MetricsAdviceBaseTest {
     
-    private final ProxyRequestCountAdvice advice = new 
ProxyRequestCountAdvice();
+    private final TotalRequestsCountAdvice advice = new 
TotalRequestsCountAdvice();
     
     @Test
     public void assertBeforeMethod() {
         MockTargetAdviceObject targetObject = new MockTargetAdviceObject();
         advice.beforeMethod(targetObject, mock(Method.class), new Object[]{});
-        assertTrue(MetricsPool.get(MetricIds.PROXY_REQUEST).isPresent());
-        assertThat(((FixtureWrapper) 
MetricsPool.get(MetricIds.PROXY_REQUEST).get()).getFixtureValue(), is(1d));
+        
assertTrue(MetricsPool.get(MetricIds.TOTAL_PROXY_REQUESTS).isPresent());
+        assertThat(((FixtureWrapper) 
MetricsPool.get(MetricIds.TOTAL_PROXY_REQUESTS).get()).getFixtureValue(), 
is(1d));
     }
 }
diff --git 
a/agent/plugins/metrics/type/prometheus/src/main/resources/META-INF/conf/prometheus-proxy-advisors.yaml
 
b/agent/plugins/metrics/type/prometheus/src/main/resources/META-INF/conf/prometheus-proxy-advisors.yaml
index ed2d1b18d82..d6af4833e7d 100644
--- 
a/agent/plugins/metrics/type/prometheus/src/main/resources/META-INF/conf/prometheus-proxy-advisors.yaml
+++ 
b/agent/plugins/metrics/type/prometheus/src/main/resources/META-INF/conf/prometheus-proxy-advisors.yaml
@@ -24,14 +24,14 @@ advisors:
       - name: processException
         type: method
   - target: 
org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler
-    advice: 
org.apache.shardingsphere.agent.plugin.metrics.core.advice.ProxyConnectionCountAdvice
+    advice: 
org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy.CurrentConnectionsCountAdvice
     pointcuts:
       - name: channelActive
         type: method
       - name: channelInactive
         type: method
   - target: 
org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler
-    advice: 
org.apache.shardingsphere.agent.plugin.metrics.core.advice.ProxyRequestCountAdvice
+    advice: 
org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy.TotalRequestsCountAdvice
     pointcuts:
       - name: channelRead
         type: method

Reply via email to