ganpengyu opened a new issue #3154: Why the plugin do not generate a traceid URL: https://github.com/apache/skywalking/issues/3154 - Why do you submit this issue? - Question or discussion ___ ### Question - What do you want to know? I try to enhance my custom class as below: ```java public abstract class TopJobHandler extends IJobHandler { @Override public ReturnT<String> execute(String s) throws Exception { ReturnT<String> result = run(s); return result; } public abstract ReturnT<String> run(String s) throws Exception; } ``` My every job should extends TopJobHandler,Usage Example: ```java @Component @Slf4j @JobHandler(value = "mockJobHandler") public class MockJobHandler extends TopJobHandler { @Autowired private MockService mockService; @Override public ReturnT<String> run(String s) throws Exception { for (int i = 0; i < 5; i++) { log.info("任务被执行,输出:{}", mockService.mock()); } return ReturnT.SUCCESS; } } ``` So I add a plugin to enhance it. ```java public class XxlJobExecutorInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { private static final String ENHANCE_CLASS = "com.ganpengyu.mock.xxljobtracemock.config.TopJobHandler"; private static final String JOB_EXECUTOR_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.xxljob.XxlJobExecutorInterceptor"; @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() { return new ConstructorInterceptPoint[0]; } @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { return new InstanceMethodsInterceptPoint[]{ new InstanceMethodsInterceptPoint() { @Override public ElementMatcher<MethodDescription> getMethodsMatcher() { return named("execute"); } @Override public String getMethodsInterceptor() { return JOB_EXECUTOR_INTERCEPTOR_CLASS; } @Override public boolean isOverrideArgs() { return false; } } }; } @Override protected ClassMatch enhanceClass() { return byName(ENHANCE_CLASS); } } ``` Then I write an interceptor as below ( beforeMethod()) ```java @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable { String param = (String) allArguments[0]; LOGGER.info("Executor param is {}", param); final ContextCarrier contextCarrier = new ContextCarrier(); AbstractSpan span = ContextManager.createEntrySpan("executor_instance_name", contextCarrier); span.tag("execute_param", param); span.setComponent(ComponentsDefine.XXL_JOB); } ``` Now my question is the log in my example codes printed without traceId, ``` [TID: N/A] 10:39:48.202 logback [Thread-27] INFO c.g.m.x.job.MockJobHandler - 任务被执行,输出:Hello XXL JOB ``` Plugin Interceptor is work well, but do not generate traceId. So, how should I do to solve it. Thk!
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
