asafm commented on code in PR #21772: URL: https://github.com/apache/pulsar/pull/21772#discussion_r1521106317
########## 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: BTW: I got a response from Jersey DEV mailing list: I got a reply from the Jersey DEV mailing list. They say we can do `(ExtendedUriInfo) ContainerRequestContext#getUriInfo`. Not sure it's needed. I haven't tested it yet. -- 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