songxiaosheng commented on code in PR #11452:
URL: https://github.com/apache/dubbo/pull/11452#discussion_r1101558766
##########
dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/DefaultMetricsCollector.java:
##########
@@ -63,100 +64,123 @@ public Boolean isCollectEnabled() {
}
public void increaseTotalRequests(String applicationName, Invocation
invocation) {
- increaseAndPublishEvent(applicationName, MetricsEvent.Type.TOTAL,
invocation);
+ increaseAndPublishEvent(applicationName, RequestEvent.Type.TOTAL,
invocation);
}
public void increaseSucceedRequests(String applicationName, Invocation
invocation) {
- increaseAndPublishEvent(applicationName, MetricsEvent.Type.SUCCEED,
invocation);
+ increaseAndPublishEvent(applicationName, RequestEvent.Type.SUCCEED,
invocation);
}
public void increaseUnknownFailedRequests(String applicationName,
Invocation invocation) {
- increaseAndPublishEvent(applicationName,
MetricsEvent.Type.UNKNOWN_FAILED, invocation);
+ increaseAndPublishEvent(applicationName,
RequestEvent.Type.UNKNOWN_FAILED, invocation);
}
public void businessFailedRequests(String applicationName, Invocation
invocation) {
- increaseAndPublishEvent(applicationName,
MetricsEvent.Type.BUSINESS_FAILED, invocation);
+ increaseAndPublishEvent(applicationName,
RequestEvent.Type.BUSINESS_FAILED, invocation);
}
public void timeoutRequests(String applicationName, Invocation invocation)
{
-
increaseAndPublishEvent(applicationName,MetricsEvent.Type.REQUEST_TIMEOUT,
invocation);
+
increaseAndPublishEvent(applicationName,RequestEvent.Type.REQUEST_TIMEOUT,
invocation);
}
public void limitRequests(String applicationName, Invocation invocation) {
-
increaseAndPublishEvent(applicationName,MetricsEvent.Type.REQUEST_LIMIT,
invocation);
+
increaseAndPublishEvent(applicationName,RequestEvent.Type.REQUEST_LIMIT,
invocation);
}
public void increaseProcessingRequests(String applicationName, Invocation
invocation) {
- increaseAndPublishEvent(applicationName,MetricsEvent.Type.PROCESSING,
invocation);
+ increaseAndPublishEvent(applicationName,RequestEvent.Type.PROCESSING,
invocation);
}
public void decreaseProcessingRequests(String applicationName, Invocation
invocation) {
- decreaseAndPublishEvent(applicationName,MetricsEvent.Type.PROCESSING,
invocation);
+ decreaseAndPublishEvent(applicationName,RequestEvent.Type.PROCESSING,
invocation);
}
public void totalFailedRequests(String applicationName, Invocation
invocation) {
-
increaseAndPublishEvent(applicationName,MetricsEvent.Type.TOTAL_FAILED,
invocation);
+
increaseAndPublishEvent(applicationName,RequestEvent.Type.TOTAL_FAILED,
invocation);
}
- private void increaseAndPublishEvent(String applicationName,
MetricsEvent.Type total, Invocation invocation) {
+ private void increaseAndPublishEvent(String applicationName,
RequestEvent.Type total, Invocation invocation) {
this.eventMulticaster.publishEvent(doExecute(total, statHandler ->
statHandler.increase(applicationName,invocation)));
}
- private void decreaseAndPublishEvent(String applicationName,
MetricsEvent.Type type, Invocation invocation) {
- this.eventMulticaster.publishEvent(doExecute(type, statHandler ->
statHandler.decrease(applicationName,invocation)));
+ private void decreaseAndPublishEvent(String applicationName,
RequestEvent.Type total, Invocation invocation) {
+ this.eventMulticaster.publishEvent(doExecute(total, statHandler ->
statHandler.decrease(applicationName,invocation)));
}
public void addRT(String applicationName,Invocation invocation, Long
responseTime) {
this.eventMulticaster.publishEvent(stats.addRtAndRetrieveEvent(applicationName,invocation,
responseTime));
}
- public void addApplicationInfo(String applicationName, String version) {
- doExecute(MetricsEvent.Type.APPLICATION_INFO, statHandler ->
statHandler.addApplication(applicationName,version));
- }
+
@Override
public List<MetricSample> collect() {
List<MetricSample> list = new ArrayList<>();
- collectApplication(list);
- collectRequests(list);
- collectRT(list);
+ if(RpcContext.getContext().isProviderSide()){
+ collectRequests(list);
+ collectRT(list);
+ }else {
+ collectConsumerRequests(list);
+ collectConsumerRT(list);
- return list;
- }
-
- private void collectApplication(List<MetricSample> list) {
- doCollect(MetricsEvent.Type.APPLICATION_INFO,
MetricsStatHandler::get).filter(e -> !e.isEmpty())
- .ifPresent(map -> map.forEach((k, v) -> list.add(new
GaugeMetricSample(MetricsKey.APPLICATION_METRIC_INFO, k.getTags(),
- APPLICATION, v::get))));
+ }
+ return list;
}
private void collectRequests(List<MetricSample> list) {
- doCollect(MetricsEvent.Type.TOTAL, MetricsStatHandler::get).filter(e
-> !e.isEmpty())
+ doCollect(RequestEvent.Type.TOTAL, MetricsStatHandler::get).filter(e
-> !e.isEmpty())
Review Comment:
please use MetricsEvent
##########
dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/filter/ClusterFilter.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.dubbo.metrics.filter;
+
+import org.apache.dubbo.common.extension.Activate;
+
+import org.apache.dubbo.metrics.collector.DefaultMetricsCollector;
+import org.apache.dubbo.rpc.BaseFilter;
+import org.apache.dubbo.rpc.Filter;
+import org.apache.dubbo.rpc.Invocation;
+import org.apache.dubbo.rpc.Invoker;
+import org.apache.dubbo.rpc.Result;
+import org.apache.dubbo.rpc.RpcException;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.ScopeModelAware;
+
+import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;
+
+
+@Activate(group = CONSUMER, order = -1)
+public class ClusterFilter implements Filter, BaseFilter.Listener,
ScopeModelAware {
Review Comment:
please rename ClusterFilter to ConsumerMetricsFilter
##########
dubbo-rpc/dubbo-rpc-triple/pom.xml:
##########
@@ -113,6 +118,7 @@
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
+ <!--suppress UnresolvedMavenProperty -->
Review Comment:
remove this comment
##########
dubbo-test/dubbo-test-check/pom.xml:
##########
@@ -83,6 +83,12 @@
<artifactId>async-http-client</artifactId>
<version>${async.http.client.version}</version>
</dependency>
+ <dependency>
Review Comment:
remove this dependency
##########
dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/DefaultMetricsCollector.java:
##########
@@ -63,100 +64,123 @@ public Boolean isCollectEnabled() {
}
public void increaseTotalRequests(String applicationName, Invocation
invocation) {
- increaseAndPublishEvent(applicationName, MetricsEvent.Type.TOTAL,
invocation);
+ increaseAndPublishEvent(applicationName, RequestEvent.Type.TOTAL,
invocation);
Review Comment:
please use MetricsEvent
##########
dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/AggregateMetricsCollector.java:
##########
@@ -143,9 +144,17 @@ private void onRequestEvent(RequestEvent event) {
@Override
public List<MetricSample> collect() {
List<MetricSample> list = new ArrayList<>();
- collectRequests(list);
- collectQPS(list);
- collectRT(list);
+
+ if(RpcContext.getContext().isConsumerSide()){
Review Comment:
This method is used to report and collect all data without if filtering
##########
dubbo-rpc/dubbo-rpc-triple/pom.xml:
##########
@@ -92,6 +92,11 @@
<version>${reactor.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
Review Comment:
remove this dependency
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]