-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#9522] Support URI statistics for Spring Webflux
- Loading branch information
Showing
12 changed files
with
220 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.82 KB
agent-testweb/spring-webflux-plugin-testweb/src/main/resources/static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...p/pinpoint/plugin/spring/webflux/interceptor/AbstractHandlerMethodMappingInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.navercorp.pinpoint.plugin.spring.webflux.interceptor; | ||
|
||
import com.navercorp.pinpoint.bootstrap.context.SpanRecorder; | ||
import com.navercorp.pinpoint.bootstrap.context.Trace; | ||
import com.navercorp.pinpoint.bootstrap.context.TraceContext; | ||
import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor; | ||
import com.navercorp.pinpoint.common.util.ArrayArgumentUtils; | ||
import com.navercorp.pinpoint.common.util.StringUtils; | ||
import com.navercorp.pinpoint.plugin.spring.webflux.SpringWebFluxConstants; | ||
import org.springframework.web.server.ServerWebExchange; | ||
import org.springframework.web.util.pattern.PathPattern; | ||
|
||
public class AbstractHandlerMethodMappingInterceptor implements AroundInterceptor { | ||
private final TraceContext traceContext; | ||
|
||
public AbstractHandlerMethodMappingInterceptor(final TraceContext traceContext) { | ||
this.traceContext = traceContext; | ||
} | ||
|
||
@Override | ||
public void before(Object target, Object[] args) { | ||
|
||
} | ||
|
||
@Override | ||
public void after(Object target, Object[] args, Object result, Throwable throwable) { | ||
final Trace trace = traceContext.currentRawTraceObject(); | ||
if (trace != null) { | ||
ServerWebExchange webExchange = ArrayArgumentUtils.getArgument(args, 0, ServerWebExchange.class); | ||
String uri = extractAttribute(webExchange, SpringWebFluxConstants.SPRING_WEBFLUX_DEFAULT_URI_ATTRIBUTE_KEYS); | ||
if (uri != null) { | ||
SpanRecorder spanRecorder = trace.getSpanRecorder(); | ||
spanRecorder.recordUriTemplate(uri, false); | ||
} | ||
} | ||
} | ||
|
||
private String extractAttribute(ServerWebExchange webExchange, String[] keys) { | ||
for (String attributeName : keys) { | ||
Object uriMapping = webExchange.getAttribute(attributeName); | ||
if (!(uriMapping instanceof PathPattern)) { | ||
continue; | ||
} | ||
|
||
String uriTemplate = ((PathPattern) uriMapping).getPatternString(); | ||
if (StringUtils.hasLength(uriTemplate)) { | ||
return uriTemplate; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...corp/pinpoint/plugin/spring/webflux/interceptor/AbstractUrlHandlerMappingInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.navercorp.pinpoint.plugin.spring.webflux.interceptor; | ||
|
||
import com.navercorp.pinpoint.bootstrap.context.SpanRecorder; | ||
import com.navercorp.pinpoint.bootstrap.context.Trace; | ||
import com.navercorp.pinpoint.bootstrap.context.TraceContext; | ||
import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor; | ||
import com.navercorp.pinpoint.common.util.ArrayArgumentUtils; | ||
import com.navercorp.pinpoint.common.util.StringUtils; | ||
import com.navercorp.pinpoint.plugin.spring.webflux.SpringWebFluxConstants; | ||
import org.springframework.web.server.ServerWebExchange; | ||
import org.springframework.web.util.pattern.PathPattern; | ||
|
||
public class AbstractUrlHandlerMappingInterceptor implements AroundInterceptor { | ||
private final TraceContext traceContext; | ||
|
||
public AbstractUrlHandlerMappingInterceptor(TraceContext traceContext) { | ||
this.traceContext = traceContext; | ||
} | ||
|
||
@Override | ||
public void before(Object target, Object[] args) { | ||
|
||
} | ||
|
||
@Override | ||
public void after(Object target, Object[] args, Object result, Throwable throwable) { | ||
final Trace trace = traceContext.currentRawTraceObject(); | ||
if (trace != null) { | ||
ServerWebExchange webExchange = ArrayArgumentUtils.getArgument(args, 1, ServerWebExchange.class); | ||
String uri = extractAttribute(webExchange, SpringWebFluxConstants.SPRING_WEBFLUX_DEFAULT_URI_ATTRIBUTE_KEYS); | ||
if (uri != null) { | ||
SpanRecorder spanRecorder = trace.getSpanRecorder(); | ||
spanRecorder.recordUriTemplate(uri, false); | ||
} | ||
} | ||
} | ||
|
||
private String extractAttribute(ServerWebExchange webExchange, String[] keys) { | ||
for (String attributeName : keys) { | ||
Object uriMapping = webExchange.getAttribute(attributeName); | ||
if (!(uriMapping instanceof PathPattern)) { | ||
continue; | ||
} | ||
|
||
String uriTemplate = ((PathPattern) uriMapping).getPatternString(); | ||
if (StringUtils.hasLength(uriTemplate)) { | ||
return uriTemplate; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters