wu-sheng commented on a change in pull request #3323: Add Light4j plugin
URL: https://github.com/apache/skywalking/pull/3323#discussion_r325494885
 
 

 ##########
 File path: 
apm-sniffer/apm-sdk-plugin/light4j-plugins/light4j-plugin/src/main/java/org/apache/skywalking/apm/plugin/light4j/HandleRequestInterceptor.java
 ##########
 @@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.light4j;
+
+import com.networknt.exception.ExceptionHandler;
+import com.networknt.handler.MiddlewareHandler;
+import com.networknt.handler.OrchestrationHandler;
+import io.undertow.server.HttpServerExchange;
+import io.undertow.util.HeaderMap;
+import org.apache.skywalking.apm.agent.core.conf.Config;
+import org.apache.skywalking.apm.agent.core.context.CarrierItem;
+import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+import java.lang.reflect.Method;
+
+/**
+ * {@link HandleRequestInterceptor} creates an entry span before the execution 
of
+ * {@link 
com.networknt.exception.ExceptionHandler#handleRequest(HttpServerExchange)} in 
the I/O thread.
+ *
+ * If the {@link Config.Plugin.Light4J#TRACE_HANDLER_CHAIN} flag is set, 
additionally a local span is produced for each
+ * {@link com.networknt.handler.MiddlewareHandler} and business handler before 
their respective
+ * {@link 
com.networknt.handler.LightHttpHandler#handleRequest(HttpServerExchange)} 
method executes.
+ * Since {@link com.networknt.handler.LightHttpHandler} is implemented by 
various middleware and business handlers and
+ * the Light4J framework delegates to these in succession, a chain of
+ * {@link org.apache.skywalking.apm.agent.core.context.trace.LocalSpan}s will 
be produced.
+ *
+ * @author tsuilouis
+ */
+public class HandleRequestInterceptor implements 
InstanceMethodsAroundInterceptor {
+
+    @Override
+    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();
 
 Review comment:
   If you are sure your(light4j) users are familiar with the current 
format(with `@`), I am OK to don't change it to SpringMVC's. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to