Skip to content

Commit

Permalink
Avoid webflux plugin generating many endpoints & optimization http pl…
Browse files Browse the repository at this point in the history
…ugin toPath method (apache#2718)

* Avoid webflux plugin generating many endpoints
  • Loading branch information
zhaoyuguang authored and wu-sheng committed May 20, 2019
1 parent 7b21c33 commit 90fe05b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
}

if (allArguments[1] instanceof HttpRequest) {
AbstractSpan span = ContextManager.createEntrySpan(request.uri(), contextCarrier);
AbstractSpan span = ContextManager.createEntrySpan(toPath(request.uri()), contextCarrier);
Tags.URL.set(span, request.uri());
Tags.HTTP.METHOD.set(span, request.method().name());
span.setComponent(ComponentsDefine.SPRING_MVC_ANNOTATION);
Expand All @@ -65,4 +65,13 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA
Class<?>[] argumentsTypes, Throwable t) {
ContextManager.activeSpan().errorOccurred().log(t);
}

private static String toPath(String uri) {
int index = uri.indexOf("?");
if (index > -1) {
return uri.substring(0, index);
} else {
return uri;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA
}

private static String toPath(String uri) {
if (uri.contains("?")) {
return uri.substring(0, uri.indexOf("?"));
int index = uri.indexOf("?");
if (index > -1) {
return uri.substring(0, index);
} else {
return uri;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA
}

private static String toPath(String uri) {
if (uri.contains("?")) {
return uri.substring(0, uri.indexOf("?"));
int index = uri.indexOf("?");
if (index > -1) {
return uri.substring(0, index);
} else {
return uri;
}
Expand Down

0 comments on commit 90fe05b

Please sign in to comment.