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:
There might be cases where the regex rule can change (algorithm doesn't know
before hand what future uris will look like).
So 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.
--
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]