Superskyyy commented on code in PR #10884:
URL: https://github.com/apache/skywalking/pull/10884#discussion_r1220306811


##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/group/EndpointNameGrouping.java:
##########
@@ -69,6 +113,40 @@ private String formatByOpenapi(String serviceName, String 
endpointName) {
                 log.trace("Endpoint {} of Service {} keeps unchanged.", 
endpointName, serviceName);
             }
         }
-        return formatResult.getName();
+        return new Tuple2<>(formatResult.getName(), formatResult.isMatch());
+    }
+
+    public void setHttpUriRecognitionSvr(final HttpUriRecognition 
httpUriRecognitionSvr) {
+        this.httpUriRecognitionSvr = httpUriRecognitionSvr;
+        Executors.newSingleThreadScheduledExecutor()
+                 .scheduleWithFixedDelay(
+                     new RunnableWithExceptionProtection(
+                         () -> {
+                             cachedHttpUris.forEach((serviceName, httpUris) -> 
{
+                                 List<HttpUriRecognition.HTTPUri> uris
+                                     = httpUris.keySet()
+                                               .stream()
+                                               .map(
+                                                   uri -> new 
HttpUriRecognition.HTTPUri(
+                                                       uri, 
httpUris.get(uri).get()
+                                                   ))
+                                               .collect(Collectors.toList());
+                                 // Reset the cache once the URIs are sent to 
the recognition server.
+                                 httpUris.clear();
+                                 httpUriRecognitionSvr
+                                     .recognize(serviceName, uris,
+                                                (service, patterns) -> {
+                                                    StringFormatGroup group = 
new StringFormatGroup(patterns.size());
+                                                    patterns.forEach(
+                                                        p -> 
group.addRule(p.getFormattedUri(), p.getPattern()));

Review Comment:
   I'm not sure yet but there might be cases where the regex rule can change 
(algorithm doesn't know before hand what future uris will look like).
   
   For example: /order/123/refund -> in future there might be something called 
/order/134b/refund -> I will just assume them to be two patterns to simplify 
algorithm and avoid updating exsiting rules.
   
   The generated pattern will always start from minimal scope, if theres only 
INT between / /, it will be only int, not a var. this is to prevent algorithm 
sort everything into a general regex and nothing makes sense anymore.
   



##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/config/group/EndpointNameGrouping.java:
##########
@@ -69,6 +113,40 @@ private String formatByOpenapi(String serviceName, String 
endpointName) {
                 log.trace("Endpoint {} of Service {} keeps unchanged.", 
endpointName, serviceName);
             }
         }
-        return formatResult.getName();
+        return new Tuple2<>(formatResult.getName(), formatResult.isMatch());
+    }
+
+    public void setHttpUriRecognitionSvr(final HttpUriRecognition 
httpUriRecognitionSvr) {
+        this.httpUriRecognitionSvr = httpUriRecognitionSvr;
+        Executors.newSingleThreadScheduledExecutor()
+                 .scheduleWithFixedDelay(
+                     new RunnableWithExceptionProtection(
+                         () -> {
+                             cachedHttpUris.forEach((serviceName, httpUris) -> 
{
+                                 List<HttpUriRecognition.HTTPUri> uris
+                                     = httpUris.keySet()
+                                               .stream()
+                                               .map(
+                                                   uri -> new 
HttpUriRecognition.HTTPUri(
+                                                       uri, 
httpUris.get(uri).get()
+                                                   ))
+                                               .collect(Collectors.toList());
+                                 // Reset the cache once the URIs are sent to 
the recognition server.
+                                 httpUris.clear();
+                                 httpUriRecognitionSvr
+                                     .recognize(serviceName, uris,
+                                                (service, patterns) -> {
+                                                    StringFormatGroup group = 
new StringFormatGroup(patterns.size());
+                                                    patterns.forEach(
+                                                        p -> 
group.addRule(p.getFormattedUri(), p.getPattern()));

Review Comment:
   Is the results for this already processed batch used somewhere else to 
update the 2Tuples for the cachedURIs? 
   
   In other words, does the updated rule only work for future URIs, not the 
currently just analyzed batch(since its async) and they already received a 
non-formated tuple after .format?



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