This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 4e2a2695394 optimize proxy_requests_total metric (#24086)
4e2a2695394 is described below
commit 4e2a2695394b89c3f38d2302eb1d062317fe8540
Author: jiangML <[email protected]>
AuthorDate: Fri Feb 10 10:37:24 2023 +0800
optimize proxy_requests_total metric (#24086)
---
.../agent/plugin/metrics/core/advice/proxy/RequestsCountAdvice.java | 2 +-
.../plugin/metrics/core/advice/proxy/RequestsCountAdviceTest.java | 2 +-
.../src/main/resources/META-INF/conf/prometheus-proxy-advisors.yaml | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
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 fd5327f59b7..267bc99945b 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
@@ -36,7 +36,7 @@ public final class RequestsCountAdvice implements
InstanceMethodAdvice {
MetricCollectorType.COUNTER, "Total requests of
ShardingSphere-Proxy", Collections.emptyList(), Collections.emptyMap());
@Override
- public void beforeMethod(final TargetAdviceObject target, final Method
method, final Object[] args, final String pluginType) {
+ public void afterMethod(final TargetAdviceObject target, final Method
method, final Object[] args, final Object result, final String pluginType) {
MetricsCollectorRegistry.<CounterMetricsCollector>get(config,
pluginType).inc();
}
}
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 c2e1c8d8e77..f3654c5ed91 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
@@ -46,7 +46,7 @@ public final class RequestsCountAdviceTest {
@Test
public void assertCountRequests() {
TargetAdviceObjectFixture targetObject = new
TargetAdviceObjectFixture();
- advice.beforeMethod(targetObject, mock(Method.class), new Object[]{},
"FIXTURE");
+ advice.afterMethod(targetObject, mock(Method.class), new Object[]{},
null, "FIXTURE");
assertThat(MetricsCollectorRegistry.get(config, "FIXTURE").toString(),
is("1"));
}
}
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 3dc44bb73c5..d1828cdab7d 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
@@ -33,10 +33,10 @@ advisors:
type: method
- name: channelInactive
type: method
- - target:
org.apache.shardingsphere.proxy.frontend.netty.FrontendChannelInboundHandler
+ - target:
org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask
advice:
org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy.RequestsCountAdvice
pointcuts:
- - name: channelRead
+ - name: run
type: method
- target:
org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager
advice:
org.apache.shardingsphere.agent.plugin.metrics.core.advice.proxy.CommitTransactionsCountAdvice