in apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouteStateInterceptor.java [63:103]
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
RoutingContextImplBase routingContext = (RoutingContextImplBase) allArguments[0];
List<Handler<RoutingContext>> contextHandlers = (List<Handler<RoutingContext>>) objInst.getSkyWalkingDynamicField();
AtomicInteger currentContextIndex = (AtomicInteger) ((EnhancedInstance) routingContext).getSkyWalkingDynamicField();
int handlerContextIndex = currentContextIndex.get();
if (VertxContext.VERTX_VERSION >= 35 && contextHandlers.size() > 1) {
currentContextIndex.getAndIncrement(); //3.5+ has possibility for multiple handlers
}
String contextName = contextHandlers.get(handlerContextIndex).getClass().getCanonicalName();
int lambdaOffset = contextName.indexOf("$$Lambda$");
if (lambdaOffset > 0) contextName = contextName.substring(0, lambdaOffset + 9);
AbstractSpan span = ContextManager.createLocalSpan(String.format("%s.handle(RoutingContext)", contextName));
Object connection = ((EnhancedInstance) routingContext.request()).getSkyWalkingDynamicField();
VertxContext vertxContext = (VertxContext) ((EnhancedInstance) connection).getSkyWalkingDynamicField();
String routeMethods = null;
if (VertxContext.VERTX_VERSION >= 37.1) {
if (routingContext.currentRoute().methods() != null) {
routeMethods = "{" +
routingContext.currentRoute().methods()
.stream().map(Enum::toString)
.collect(Collectors.joining(","))
+ "}";
}
} else {
//no methods() method; have to strip from toString()
Matcher matcher = HTTP_METHOD_PATTERN.matcher(routingContext.currentRoute().toString());
if (matcher.find()) {
routeMethods = "{" + matcher.group(1) + "}";
}
}
if (routeMethods != null && routingContext.currentRoute().getPath() != null) {
vertxContext.getSpan().setOperationName(routeMethods + routingContext.currentRoute().getPath());
}
ContextManager.continued(vertxContext.getContextSnapshot());
span.setComponent(ComponentsDefine.VERTX);
SpanLayer.asHttp(span);
}