wu-sheng commented on code in PR #10884:
URL: https://github.com/apache/skywalking/pull/10884#discussion_r1223976922


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/group/EndpointNameGrouping.java:
##########
@@ -18,32 +18,91 @@
 
 package org.apache.skywalking.oap.server.core.config.group;
 
+import io.vavr.Tuple2;
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
 import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.skywalking.oap.server.library.util.StringFormatGroup;
+import 
org.apache.skywalking.oap.server.ai.pipeline.services.api.HttpUriPattern;
+import 
org.apache.skywalking.oap.server.ai.pipeline.services.api.HttpUriRecognition;
 import 
org.apache.skywalking.oap.server.core.config.group.openapi.EndpointGroupingRule4Openapi;
+import 
org.apache.skywalking.oap.server.core.config.group.uri.quickmatch.QuickUriGroupingRule;
+import org.apache.skywalking.oap.server.core.query.MetadataQueryService;
+import org.apache.skywalking.oap.server.library.util.CollectionUtils;
+import 
org.apache.skywalking.oap.server.library.util.RunnableWithExceptionProtection;
+import org.apache.skywalking.oap.server.library.util.StringFormatGroup;
 
 @Slf4j
 public class EndpointNameGrouping {
     @Setter
-    private volatile EndpointGroupingRule endpointGroupingRule;
+    private volatile QuickUriGroupingRule endpointGroupingRule;
     @Setter
     private volatile EndpointGroupingRule4Openapi endpointGroupingRule4Openapi;
+    @Setter
+    private volatile QuickUriGroupingRule quickUriGroupingRule;
+    /**
+     * Cache the HTTP URIs which are not formatted by the rules per service.
+     * Level one map key is service name, the value is a map of HTTP URI and 
its count.
+     * Multiple matches will be counted, because it is the pattern that the 
endpoint is already formatted,
+     * or doesn't need to be formatted.
+     * The repeatable URI is a pattern already.
+     */
+    private ConcurrentHashMap<String, ConcurrentHashMap<String, 
AtomicInteger>> cachedHttpUris = new ConcurrentHashMap<>();
+    private final AtomicInteger aiPipelineExecutionCounter = new 
AtomicInteger(0);
+    /**
+     * The max number of HTTP URIs per service for further URI pattern 
recognition.
+     */
+    private int maxHttpUrisNumberPerService = 3000;
 
-    public String format(String serviceName, String endpointName) {
-        String formattedName = endpointName;
+    /**
+     * Format the endpoint name according to the API patterns.
+     *
+     * @param serviceName  service name
+     * @param endpointName endpoint name to be formatted.
+     * @return Tuple2 where the first element is the formatted name and the 
second element is a boolean
+     * represented the endpoint name is formatted or not.
+     */
+    public Tuple2<String, Boolean> format(String serviceName, String 
endpointName) {
+        Tuple2<String, Boolean> formattedName = new Tuple2<>(endpointName, 
Boolean.FALSE);
         if (endpointGroupingRule4Openapi != null) {
-            formattedName = formatByOpenapi(serviceName, formattedName);
+            formattedName = formatByOpenapi(serviceName, endpointName);
+        }
+
+        if (!formattedName._2() && endpointGroupingRule != null) {
+            formattedName = formatByCustom(serviceName, endpointName);
+        }
+
+        if (!formattedName._2() && quickUriGroupingRule != null) {
+            formattedName = formatByQuickUriPattern(serviceName, endpointName);
         }
 
-        if (endpointGroupingRule != null) {
-            formattedName = formatByCustom(serviceName, formattedName);
+        if (!formattedName._2()) {
+            // Only URI starts with '/' will be cached and formatted later.
+            if (endpointName.indexOf("/") > -1) {

Review Comment:
   Let me fix codes. start with is wrong. Get and Post are prefix, not /. That 
was a legacy comment.



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

Reply via email to