public void beforeMethod()

in apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/java/org/apache/skywalking/apm/plugin/light4j/HandleRequestInterceptor.java [54:99]


    public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
                             MethodInterceptResult result) {
        if (isExceptionHandler(objInst)) {
            HttpServerExchange exchange = (HttpServerExchange) allArguments[0];

            if (exchange.isInIoThread()) {

                String operationName = exchange.getRequestPath() + "@" + exchange.getRequestMethod();
                final HeaderMap headers = exchange.getRequestHeaders();
                final ContextCarrier contextCarrier = new ContextCarrier();

                CarrierItem next = contextCarrier.items();
                while (next.hasNext()) {
                    next = next.next();
                    next.setHeadValue(headers.getFirst(next.getHeadKey()));
                }

                AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier);
                Tags.URL.set(span, exchange.getRequestURL());
                Tags.HTTP.METHOD.set(span, exchange.getRequestMethod().toString());
                span.setComponent(ComponentsDefine.LIGHT_4J);
                SpanLayer.asHttp(span);

                Tags.HTTP_RESPONSE_STATUS_CODE.set(span, exchange.getStatusCode());
                if (exchange.getStatusCode() >= 400) {
                    span.errorOccurred();
                }

                ContextManager.stopSpan(span);

                objInst.setSkyWalkingDynamicField(ContextManager.capture());
            } else if (Light4JPluginConfig.Plugin.Light4J.TRACE_HANDLER_CHAIN) {
                String operationName = objInst.getClass().getName() + "." + method.getName();

                ContextSnapshot snapshot = (ContextSnapshot) objInst.getSkyWalkingDynamicField();
                ContextManager.createLocalSpan(operationName).setComponent(ComponentsDefine.LIGHT_4J);

                ContextManager.continued(snapshot);
            }
        } else if (Light4JPluginConfig.Plugin.Light4J.TRACE_HANDLER_CHAIN && (isMiddlewareHandler(
            objInst) || isBusinessHandler(objInst))) {
            String operationName = objInst.getClass().getName() + "." + method.getName();

            ContextManager.createLocalSpan(operationName).setComponent(ComponentsDefine.LIGHT_4J);
        }
    }