You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "robin977 (via GitHub)" <gi...@apache.org> on 2023/08/24 01:11:05 UTC

[GitHub] [dubbo] robin977 commented on a diff in pull request #12892: Adds metrics initialization metrics for the service interface(#12850)

robin977 commented on code in PR #12892:
URL: https://github.com/apache/dubbo/pull/12892#discussion_r1303680558


##########
dubbo-metrics/dubbo-metrics-default/src/main/java/org/apache/dubbo/metrics/collector/AggregateMetricsCollector.java:
##########
@@ -123,12 +124,56 @@ public boolean isSupport(MetricsEvent event) {
     public void onEvent(RequestEvent event) {
         if (enableQps) {
             MethodMetric metric = calcWindowCounter(event, MetricsKey.METRIC_REQUESTS);
+            if(event instanceof RequestInitEvent) {
+                onInitMetricRequest(event);
+                onInitQpsRequest(metric);
+                onInitRtRequest(metric);
+                onInitRtAgrRequest(metric);
+                return;
+            }
             TimeWindowCounter qpsCounter = ConcurrentHashMapUtils.computeIfAbsent(qps, metric,
                 methodMetric -> new TimeWindowCounter(bucketNum, qpsTimeWindowMillSeconds));
             qpsCounter.increment();
         }
     }
 
+    public void onInitMetricRequest(RequestEvent event){
+        initWindowCounter(event,MetricsKey.METRIC_REQUESTS_TOTAL_AGG);
+        initWindowCounter(event,MetricsKey.METRIC_REQUESTS_SUCCEED_AGG);
+        initWindowCounter(event,MetricsKey.METRIC_REQUESTS_FAILED_AGG);
+        initWindowCounter(event,MetricsKey.METRIC_REQUEST_BUSINESS_FAILED_AGG);
+        initWindowCounter(event,MetricsKey.METRIC_REQUESTS_TIMEOUT_AGG);
+        initWindowCounter(event,MetricsKey.METRIC_REQUESTS_LIMIT_AGG);
+        initWindowCounter(event,MetricsKey.METRIC_REQUESTS_TOTAL_FAILED_AGG);
+        initWindowCounter(event,MetricsKey.METRIC_REQUESTS_NETWORK_FAILED_AGG);
+        initWindowCounter(event,MetricsKey.METRIC_REQUESTS_CODEC_FAILED_AGG);
+        initWindowCounter(event,MetricsKey.METRIC_REQUESTS_TOTAL_SERVICE_UNAVAILABLE_FAILED_AGG);
+    }

Review Comment:
   ok



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org