dao-jun commented on code in PR #21772:
URL: https://github.com/apache/pulsar/pull/21772#discussion_r1521307530


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/web/RestEndpointMetricsFilter.java:
##########
@@ -114,40 +89,25 @@ public void filter(ContainerRequestContext req) throws 
IOException {
     }
 
 
-    private void recordSuccess(Attributes attrs, long duration) {
+    private void recordLatency(Attributes attrs, int code, long duration) {
+        attrs = attrs.toBuilder().put(CODE, (long) code).build();
         latency.record(duration, attrs);
     }
 
-    private void recordFailure(Attributes attrs, long code) {
-        Attributes attributes = attrs.toBuilder().put(CODE, code).build();
-        failed.add(1, attributes);
-    }
-
-    private static String getRestPath(ResourceMethod method) {
-        try {
-            StringBuilder fullPath = new StringBuilder();
-            Stack<String> pathStack = new Stack<>();
-            Resource parent = method.getParent();
-
-            while (true) {
-                String path = parent.getPath();
-                parent = parent.getParent();
-                if (parent == null) {
-                    if (!path.endsWith("/") && 
!pathStack.peek().startsWith("/")) {
-                        pathStack.push("/");
-                    }
-                    pathStack.push(path);
-                    break;
-                }
-                pathStack.push(path);
-
-            }
-            while (!pathStack.isEmpty()) {
-                fullPath.append(pathStack.pop().replace("{", ":").replace("}", 
""));
-            }
-            return fullPath.toString();
-        } catch (Exception ex) {
-            return "UNKNOWN";
+    private static Attributes getRequestAttributes(UriRoutingContext ctx) {
+        List<UriTemplate> templates = ctx.getMatchedTemplates();

Review Comment:
   I've seen it, my current implementation is reference to it. 



-- 
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: commits-unsubscr...@pulsar.apache.org

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

Reply via email to