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 b601ab3af2c Split ChannelHandlerAdvice to 3 advices (#23447)
b601ab3af2c is described below
commit b601ab3af2c69f9d3bce0b41a41e44d3c1d73c3c
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Jan 9 23:32:36 2023 +0800
Split ChannelHandlerAdvice to 3 advices (#23447)
* Refactor MetricsPool
* Split ChannelHandlerAdvice to 3 methods
---
.../agent/plugin/metrics/core/MetricsPool.java | 11 ++--
...dvice.java => FrontendChannelActiveAdvice.java} | 25 +-------
...ice.java => FrontendChannelInactiveAdvice.java} | 25 +-------
...rAdvice.java => FrontendChannelReadAdvice.java} | 25 +-------
.../core/advice/ChannelHandlerAdviceTest.java | 66 ----------------------
...t.java => FrontendChannelActiveAdviceTest.java} | 24 ++++++--
.../advice/FrontendChannelInactiveAdviceTest.java | 47 +++++++++++++++
...est.java => FrontendChannelReadAdviceTest.java} | 25 ++++++--
.../metrics/core/advice/MetricsAdviceBaseTest.java | 9 +++
.../metrics/core/fixture/FixtureWrapper.java | 11 +++-
.../META-INF/conf/prometheus-proxy-advisors.yaml | 8 ++-
11 files changed, 123 insertions(+), 153 deletions(-)
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsPool.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsPool.java
index 1cbdf6e4570..73f3dbd2b86 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsPool.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/MetricsPool.java
@@ -27,15 +27,15 @@ public final class MetricsPool {
private static final ConcurrentHashMap<String, MetricsWrapper>
METRICS_POOL = new ConcurrentHashMap<>();
- private static MetricsWrapperFactory wrapperFactory;
+ private static MetricsWrapperFactory metricsWrapperFactory;
/**
* Set metrics wrapper factory.
*
- * @param factory metrics wrapper factory
+ * @param metricsWrapperFactory metrics wrapper factory
*/
- public static void setMetricsFactory(final MetricsWrapperFactory factory) {
- wrapperFactory = factory;
+ public static void setMetricsFactory(final MetricsWrapperFactory
metricsWrapperFactory) {
+ MetricsPool.metricsWrapperFactory = metricsWrapperFactory;
}
/**
@@ -44,8 +44,7 @@ public final class MetricsPool {
* @param id metrics wrapper ID
*/
public static void create(final String id) {
- Optional<MetricsWrapper> wrapper = wrapperFactory.create(id);
- wrapper.ifPresent(optional -> METRICS_POOL.put(id, optional));
+ metricsWrapperFactory.create(id).ifPresent(optional ->
METRICS_POOL.putIfAbsent(id, optional));
}
/**
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelActiveAdvice.java
similarity index 62%
copy from
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdvice.java
copy to
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelActiveAdvice.java
index a497b39d79b..f61b4ba6165 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelActiveAdvice.java
@@ -26,35 +26,16 @@ import
org.apache.shardingsphere.agent.plugin.metrics.core.constant.MetricIds;
import java.lang.reflect.Method;
/**
- * Channel handler advice.
+ * Frontend channel active advice.
*/
-public final class ChannelHandlerAdvice implements InstanceMethodAdvice {
-
- public static final String CHANNEL_READ = "channelRead";
-
- public static final String CHANNEL_ACTIVE = "channelActive";
-
- public static final String CHANNEL_INACTIVE = "channelInactive";
+public final class FrontendChannelActiveAdvice implements InstanceMethodAdvice
{
static {
- MetricsPool.create(MetricIds.PROXY_REQUEST);
MetricsPool.create(MetricIds.PROXY_COLLECTION);
}
@Override
public void beforeMethod(final TargetAdviceObject target, final Method
method, final Object[] args) {
- switch (method.getName()) {
- case CHANNEL_READ:
-
MetricsPool.get(MetricIds.PROXY_REQUEST).ifPresent(MetricsWrapper::inc);
- break;
- case CHANNEL_ACTIVE:
-
MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(MetricsWrapper::inc);
- break;
- case CHANNEL_INACTIVE:
-
MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(MetricsWrapper::dec);
- break;
- default:
- break;
- }
+
MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(MetricsWrapper::inc);
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelInactiveAdvice.java
similarity index 62%
copy from
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdvice.java
copy to
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelInactiveAdvice.java
index a497b39d79b..e558f204964 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelInactiveAdvice.java
@@ -26,35 +26,16 @@ import
org.apache.shardingsphere.agent.plugin.metrics.core.constant.MetricIds;
import java.lang.reflect.Method;
/**
- * Channel handler advice.
+ * Frontend channel inactive advice.
*/
-public final class ChannelHandlerAdvice implements InstanceMethodAdvice {
-
- public static final String CHANNEL_READ = "channelRead";
-
- public static final String CHANNEL_ACTIVE = "channelActive";
-
- public static final String CHANNEL_INACTIVE = "channelInactive";
+public final class FrontendChannelInactiveAdvice implements
InstanceMethodAdvice {
static {
- MetricsPool.create(MetricIds.PROXY_REQUEST);
MetricsPool.create(MetricIds.PROXY_COLLECTION);
}
@Override
public void beforeMethod(final TargetAdviceObject target, final Method
method, final Object[] args) {
- switch (method.getName()) {
- case CHANNEL_READ:
-
MetricsPool.get(MetricIds.PROXY_REQUEST).ifPresent(MetricsWrapper::inc);
- break;
- case CHANNEL_ACTIVE:
-
MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(MetricsWrapper::inc);
- break;
- case CHANNEL_INACTIVE:
-
MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(MetricsWrapper::dec);
- break;
- default:
- break;
- }
+
MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(MetricsWrapper::dec);
}
}
diff --git
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdvice.java
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelReadAdvice.java
similarity index 62%
rename from
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdvice.java
rename to
agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelReadAdvice.java
index a497b39d79b..a112bc1f213 100644
---
a/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdvice.java
+++
b/agent/plugins/metrics/core/src/main/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelReadAdvice.java
@@ -26,35 +26,16 @@ import
org.apache.shardingsphere.agent.plugin.metrics.core.constant.MetricIds;
import java.lang.reflect.Method;
/**
- * Channel handler advice.
+ * Frontend channel read advice.
*/
-public final class ChannelHandlerAdvice implements InstanceMethodAdvice {
-
- public static final String CHANNEL_READ = "channelRead";
-
- public static final String CHANNEL_ACTIVE = "channelActive";
-
- public static final String CHANNEL_INACTIVE = "channelInactive";
+public final class FrontendChannelReadAdvice implements InstanceMethodAdvice {
static {
MetricsPool.create(MetricIds.PROXY_REQUEST);
- MetricsPool.create(MetricIds.PROXY_COLLECTION);
}
@Override
public void beforeMethod(final TargetAdviceObject target, final Method
method, final Object[] args) {
- switch (method.getName()) {
- case CHANNEL_READ:
-
MetricsPool.get(MetricIds.PROXY_REQUEST).ifPresent(MetricsWrapper::inc);
- break;
- case CHANNEL_ACTIVE:
-
MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(MetricsWrapper::inc);
- break;
- case CHANNEL_INACTIVE:
-
MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(MetricsWrapper::dec);
- break;
- default:
- break;
- }
+
MetricsPool.get(MetricIds.PROXY_REQUEST).ifPresent(MetricsWrapper::inc);
}
}
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdviceTest.java
deleted file mode 100644
index 76797df79e4..00000000000
---
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/ChannelHandlerAdviceTest.java
+++ /dev/null
@@ -1,66 +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.shardingsphere.agent.plugin.metrics.core.advice;
-
-import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsPool;
-import org.apache.shardingsphere.agent.plugin.metrics.core.constant.MetricIds;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.lang.reflect.Method;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class ChannelHandlerAdviceTest extends MetricsAdviceBaseTest {
-
- private final ChannelHandlerAdvice channelHandlerAdvice = new
ChannelHandlerAdvice();
-
- @Mock
- private Method channelRead;
-
- @Mock
- private Method channelActive;
-
- @Mock
- private Method channelInactive;
-
- @Test
- public void assertMethod() {
-
when(channelRead.getName()).thenReturn(ChannelHandlerAdvice.CHANNEL_READ);
-
when(channelActive.getName()).thenReturn(ChannelHandlerAdvice.CHANNEL_ACTIVE);
-
when(channelInactive.getName()).thenReturn(ChannelHandlerAdvice.CHANNEL_INACTIVE);
- MockTargetAdviceObject targetObject = new MockTargetAdviceObject();
- channelHandlerAdvice.beforeMethod(targetObject, channelRead, new
Object[]{});
- channelHandlerAdvice.beforeMethod(targetObject, channelActive, new
Object[]{});
- channelHandlerAdvice.beforeMethod(targetObject, channelActive, new
Object[]{});
- channelHandlerAdvice.beforeMethod(targetObject, channelInactive, new
Object[]{});
- FixtureWrapper requestWrapper = (FixtureWrapper)
MetricsPool.get(MetricIds.PROXY_REQUEST).get();
- assertTrue(MetricsPool.get(MetricIds.PROXY_REQUEST).isPresent());
- assertThat(requestWrapper.getFixtureValue(), is(1.0));
- FixtureWrapper connectionWrapper = (FixtureWrapper)
MetricsPool.get(MetricIds.PROXY_COLLECTION).get();
- assertTrue(MetricsPool.get(MetricIds.PROXY_COLLECTION).isPresent());
- assertThat(connectionWrapper.getFixtureValue(), is(1.0));
- }
-}
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/FrontendChannelActiveAdviceTest.java
similarity index 54%
copy from
agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/MetricsAdviceBaseTest.java
copy to
agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelActiveAdviceTest.java
index bbd6998a084..752a6105574 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/FrontendChannelActiveAdviceTest.java
@@ -18,13 +18,25 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsPool;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapperFactory;
-import org.junit.BeforeClass;
+import org.apache.shardingsphere.agent.plugin.metrics.core.constant.MetricIds;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
+import org.junit.Test;
-public abstract class MetricsAdviceBaseTest {
+import java.lang.reflect.Method;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public final class FrontendChannelActiveAdviceTest extends
MetricsAdviceBaseTest {
+
+ private final FrontendChannelActiveAdvice advice = new
FrontendChannelActiveAdvice();
- @BeforeClass
- public static void setup() {
- MetricsPool.setMetricsFactory(new FixtureWrapperFactory());
+ @Test
+ public void assertBeforeMethod() {
+ advice.beforeMethod(new MockTargetAdviceObject(), mock(Method.class),
new Object[]{});
+ assertTrue(MetricsPool.get(MetricIds.PROXY_COLLECTION).isPresent());
+ assertThat(((FixtureWrapper)
MetricsPool.get(MetricIds.PROXY_COLLECTION).get()).getFixtureValue(), is(1d));
}
}
diff --git
a/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelInactiveAdviceTest.java
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelInactiveAdviceTest.java
new file mode 100644
index 00000000000..87b68292c38
--- /dev/null
+++
b/agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelInactiveAdviceTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.shardingsphere.agent.plugin.metrics.core.advice;
+
+import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsPool;
+import org.apache.shardingsphere.agent.plugin.metrics.core.constant.MetricIds;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
+import org.junit.Test;
+
+import java.lang.reflect.Method;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public final class FrontendChannelInactiveAdviceTest extends
MetricsAdviceBaseTest {
+
+ private final FrontendChannelActiveAdvice activeAdvice = new
FrontendChannelActiveAdvice();
+
+ private final FrontendChannelInactiveAdvice inactiveAdvice = new
FrontendChannelInactiveAdvice();
+
+ @Test
+ public void assertBeforeMethod() {
+ MockTargetAdviceObject targetObject = new MockTargetAdviceObject();
+ activeAdvice.beforeMethod(targetObject, mock(Method.class), new
Object[]{});
+ activeAdvice.beforeMethod(targetObject, mock(Method.class), new
Object[]{});
+ inactiveAdvice.beforeMethod(targetObject, mock(Method.class), new
Object[]{});
+ assertTrue(MetricsPool.get(MetricIds.PROXY_COLLECTION).isPresent());
+ assertThat(((FixtureWrapper)
MetricsPool.get(MetricIds.PROXY_COLLECTION).get()).getFixtureValue(), is(1d));
+ }
+}
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/FrontendChannelReadAdviceTest.java
similarity index 53%
copy from
agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/MetricsAdviceBaseTest.java
copy to
agent/plugins/metrics/core/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/core/advice/FrontendChannelReadAdviceTest.java
index bbd6998a084..ed32b60f2de 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/FrontendChannelReadAdviceTest.java
@@ -18,13 +18,26 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsPool;
-import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapperFactory;
-import org.junit.BeforeClass;
+import org.apache.shardingsphere.agent.plugin.metrics.core.constant.MetricIds;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
+import org.junit.Test;
-public abstract class MetricsAdviceBaseTest {
+import java.lang.reflect.Method;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+public final class FrontendChannelReadAdviceTest extends MetricsAdviceBaseTest
{
+
+ private final FrontendChannelReadAdvice advice = new
FrontendChannelReadAdvice();
- @BeforeClass
- public static void setup() {
- MetricsPool.setMetricsFactory(new FixtureWrapperFactory());
+ @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));
}
}
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 bbd6998a084..7690b63ee6e 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
@@ -18,7 +18,10 @@
package org.apache.shardingsphere.agent.plugin.metrics.core.advice;
import org.apache.shardingsphere.agent.plugin.metrics.core.MetricsPool;
+import org.apache.shardingsphere.agent.plugin.metrics.core.constant.MetricIds;
+import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapper;
import
org.apache.shardingsphere.agent.plugin.metrics.core.fixture.FixtureWrapperFactory;
+import org.junit.After;
import org.junit.BeforeClass;
public abstract class MetricsAdviceBaseTest {
@@ -27,4 +30,10 @@ public abstract class MetricsAdviceBaseTest {
public static void setup() {
MetricsPool.setMetricsFactory(new FixtureWrapperFactory());
}
+
+ @After
+ public void reset() {
+ MetricsPool.get(MetricIds.PROXY_COLLECTION).ifPresent(optional ->
((FixtureWrapper) optional).reset());
+ MetricsPool.get(MetricIds.PROXY_REQUEST).ifPresent(optional ->
((FixtureWrapper) optional).reset());
+ }
}
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 acece0c8c43..095a96283d1 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
@@ -26,7 +26,7 @@ import
org.apache.shardingsphere.agent.plugin.metrics.core.MetricsWrapper;
@Getter
public final class FixtureWrapper implements MetricsWrapper {
- private Double fixtureValue = 0.0d;
+ private Double fixtureValue = 0d;
@Override
public void inc(final double value) {
@@ -55,6 +55,13 @@ public final class FixtureWrapper implements MetricsWrapper {
@Override
public void delegate(final Object object) {
- fixtureValue = -1.0;
+ fixtureValue = -1d;
+ }
+
+ /**
+ * Reset.
+ */
+ public void reset() {
+ fixtureValue = 0d;
}
}
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 551ae81a89e..542a7751b55 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,12 +24,18 @@ advisors:
- name: processException
type: method
- target:
org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler
- advice:
org.apache.shardingsphere.agent.plugin.metrics.core.advice.ChannelHandlerAdvice
+ advice:
org.apache.shardingsphere.agent.plugin.metrics.core.advice.FrontendChannelActiveAdvice
pointcuts:
- name: channelActive
type: method
+ - target:
org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler
+ advice:
org.apache.shardingsphere.agent.plugin.metrics.core.advice.FrontendChannelReadAdvice
+ pointcuts:
- name: channelRead
type: method
+ - target:
org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler
+ advice:
org.apache.shardingsphere.agent.plugin.metrics.core.advice.FrontendChannelInactiveAdvice
+ pointcuts:
- name: channelInactive
type: method
- target: org.apache.shardingsphere.infra.route.engine.SQLRouteEngine