You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "songxiaosheng (via GitHub)" <gi...@apache.org> on 2023/04/29 23:51:10 UTC

[GitHub] [dubbo] songxiaosheng commented on a diff in pull request #12206: refactor metrics defaultCollector&&agg

songxiaosheng commented on code in PR #12206:
URL: https://github.com/apache/dubbo/pull/12206#discussion_r1181141634


##########
dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/model/MetricsSupport.java:
##########
@@ -56,4 +73,120 @@ public static Map<String, String> serviceTags(String appAndServiceName) {
         tags.put(TAG_INTERFACE_KEY, keys[1]);
         return tags;
     }
+
+    public static Map<String, String> methodTags(String names) {
+        String[] keys = names.split("_");
+        if (keys.length != 3) {
+            throw new MetricsNeverHappenException("Error names: " + names);
+        }
+        Map<String, String> tags = applicationTags(keys[0]);
+        tags.put(TAG_INTERFACE_KEY, keys[1]);
+        tags.put(TAG_METHOD_KEY, keys[2]);
+        return tags;
+    }
+
+    public static MetricsKey getMetricsKey(RpcException e) {
+        MetricsKey targetKey;
+        targetKey = MetricsKey.METRIC_REQUESTS_FAILED;
+        if (e.isTimeout()) {
+            targetKey = MetricsKey.METRIC_REQUESTS_TIMEOUT;
+        }
+        if (e.isLimitExceed()) {
+            targetKey = MetricsKey.METRIC_REQUESTS_LIMIT;
+        }
+        if (e.isBiz()) {
+            targetKey = MetricsKey.METRIC_REQUEST_BUSINESS_FAILED;
+        }
+        if (e.isSerialization()) {
+            targetKey = MetricsKey.METRIC_REQUESTS_CODEC_FAILED;
+        }
+        if (e.isNetwork()) {
+            targetKey = MetricsKey.METRIC_REQUESTS_NETWORK_FAILED;
+        }
+        return targetKey;

Review Comment:
   in the future we also cloud use  map to  store  the  relation exception to metric key



-- 
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