make xxl-job indy-ready (#14571)
This commit is contained in:
		
							parent
							
								
									b3df63556e
								
							
						
					
					
						commit
						14a536051a
					
				|  | @ -5,18 +5,17 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v1_9_2; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.v1_9_2.XxlJobSingletons.helper; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.isPublic; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.takesArguments; | ||||
| 
 | ||||
| import com.xxl.job.core.handler.IJobHandler; | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
|  | @ -39,29 +38,20 @@ public class GlueJobHandlerInstrumentation implements TypeInstrumentation { | |||
|   @SuppressWarnings("unused") | ||||
|   public static class ScheduleAdvice { | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|         @Advice.FieldValue("jobHandler") IJobHandler handler, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createGlueJobRequest(handler); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule( | ||||
|         @Advice.FieldValue("jobHandler") IJobHandler handler) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createGlueJobRequest(handler)); | ||||
|     } | ||||
| 
 | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) Object result, | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(result, request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) @Nullable Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
| 
 | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v1_9_2; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.v1_9_2.XxlJobSingletons.helper; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.isPublic; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||||
|  | @ -13,11 +12,11 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument; | |||
| import static net.bytebuddy.matcher.ElementMatchers.takesArguments; | ||||
| 
 | ||||
| import com.xxl.job.core.glue.GlueTypeEnum; | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
|  | @ -40,30 +39,20 @@ public class ScriptJobHandlerInstrumentation implements TypeInstrumentation { | |||
|   @SuppressWarnings("unused") | ||||
|   public static class ScheduleAdvice { | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule( | ||||
|         @Advice.FieldValue("glueType") GlueTypeEnum glueType, | ||||
|         @Advice.FieldValue("jobId") int jobId, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createScriptJobRequest(glueType, jobId); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|         @Advice.FieldValue("jobId") int jobId) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createScriptJobRequest(glueType, jobId)); | ||||
|     } | ||||
| 
 | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) Object result, | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(result, request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) @Nullable Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v1_9_2; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobConstants.XXL_GLUE_JOB_HANDLER; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobConstants.XXL_METHOD_JOB_HANDLER; | ||||
|  | @ -19,11 +18,11 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArgument; | |||
| import static net.bytebuddy.matcher.ElementMatchers.takesArguments; | ||||
| 
 | ||||
| import com.xxl.job.core.handler.IJobHandler; | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
|  | @ -44,33 +43,21 @@ public class SimpleJobHandlerInstrumentation implements TypeInstrumentation { | |||
|         SimpleJobHandlerInstrumentation.class.getName() + "$ScheduleAdvice"); | ||||
|   } | ||||
| 
 | ||||
|   @SuppressWarnings("unused") | ||||
|   public static class ScheduleAdvice { | ||||
| 
 | ||||
|     @SuppressWarnings("unused") | ||||
|     @Nullable | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|         @Advice.This IJobHandler handler, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createSimpleJobRequest(handler); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule(@Advice.This IJobHandler handler) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createSimpleJobRequest(handler)); | ||||
|     } | ||||
| 
 | ||||
|     @SuppressWarnings("unused") | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) Object result, | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(result, request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) @Nullable Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -12,11 +12,13 @@ import static net.bytebuddy.matcher.ElementMatchers.not; | |||
| import com.google.auto.service.AutoService; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule; | ||||
| import java.util.List; | ||||
| import net.bytebuddy.matcher.ElementMatcher; | ||||
| 
 | ||||
| @AutoService(InstrumentationModule.class) | ||||
| public class XxlJobInstrumentationModule extends InstrumentationModule { | ||||
| public class XxlJobInstrumentationModule extends InstrumentationModule | ||||
|     implements ExperimentalInstrumentationModule { | ||||
| 
 | ||||
|   public XxlJobInstrumentationModule() { | ||||
|     super("xxl-job", "xxl-job-1.9.2"); | ||||
|  | @ -35,4 +37,9 @@ public class XxlJobInstrumentationModule extends InstrumentationModule { | |||
|         new SimpleJobHandlerInstrumentation(), | ||||
|         new GlueJobHandlerInstrumentation()); | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   public boolean isIndyReady() { | ||||
|     return true; | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -5,17 +5,16 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v2_1_2; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.v2_1_2.XxlJobSingletons.helper; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.isPublic; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||||
| 
 | ||||
| import com.xxl.job.core.handler.IJobHandler; | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
|  | @ -37,29 +36,19 @@ public class GlueJobHandlerInstrumentation implements TypeInstrumentation { | |||
| 
 | ||||
|   @SuppressWarnings("unused") | ||||
|   public static class ScheduleAdvice { | ||||
|     @Nullable | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|         @Advice.FieldValue("jobHandler") IJobHandler handler, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createGlueJobRequest(handler); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule( | ||||
|         @Advice.FieldValue("jobHandler") IJobHandler handler) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createGlueJobRequest(handler)); | ||||
|     } | ||||
| 
 | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) Object result, | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(result, request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) @Nullable Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -5,17 +5,16 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v2_1_2; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.v2_1_2.XxlJobSingletons.helper; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.isPublic; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||||
| 
 | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import java.lang.reflect.Method; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
|  | @ -38,29 +37,17 @@ public class MethodJobHandlerInstrumentation implements TypeInstrumentation { | |||
|   @SuppressWarnings("unused") | ||||
|   public static class ScheduleAdvice { | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|         @Advice.FieldValue("target") Object target, | ||||
|         @Advice.FieldValue("method") Method method, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createMethodJobRequest(target, method); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule( | ||||
|         @Advice.FieldValue("target") Object target, @Advice.FieldValue("method") Method method) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createMethodJobRequest(target, method)); | ||||
|     } | ||||
| 
 | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) Object result, | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(result, request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) @Nullable Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -5,17 +5,16 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v2_1_2; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.v2_1_2.XxlJobSingletons.helper; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.isPublic; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||||
| 
 | ||||
| import com.xxl.job.core.glue.GlueTypeEnum; | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
|  | @ -37,30 +36,21 @@ public class ScriptJobHandlerInstrumentation implements TypeInstrumentation { | |||
| 
 | ||||
|   @SuppressWarnings("unused") | ||||
|   public static class ScheduleAdvice { | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule( | ||||
|         @Advice.FieldValue("glueType") GlueTypeEnum glueType, | ||||
|         @Advice.FieldValue("jobId") int jobId, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createScriptJobRequest(glueType, jobId); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|         @Advice.FieldValue("jobId") int jobId) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createScriptJobRequest(glueType, jobId)); | ||||
|     } | ||||
| 
 | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) Object result, | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(result, request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) @Nullable Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v2_1_2; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobConstants.XXL_GLUE_JOB_HANDLER; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobConstants.XXL_METHOD_JOB_HANDLER; | ||||
|  | @ -17,11 +16,11 @@ import static net.bytebuddy.matcher.ElementMatchers.namedOneOf; | |||
| import static net.bytebuddy.matcher.ElementMatchers.not; | ||||
| 
 | ||||
| import com.xxl.job.core.handler.IJobHandler; | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
|  | @ -42,33 +41,20 @@ public class SimpleJobHandlerInstrumentation implements TypeInstrumentation { | |||
|         SimpleJobHandlerInstrumentation.class.getName() + "$ScheduleAdvice"); | ||||
|   } | ||||
| 
 | ||||
|   @SuppressWarnings("unused") | ||||
|   public static class ScheduleAdvice { | ||||
| 
 | ||||
|     @SuppressWarnings("unused") | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|         @Advice.This IJobHandler handler, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createSimpleJobRequest(handler); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule(@Advice.This IJobHandler handler) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createSimpleJobRequest(handler)); | ||||
|     } | ||||
| 
 | ||||
|     @SuppressWarnings("unused") | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) Object result, | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(result, request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) @Nullable Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -12,11 +12,13 @@ import static net.bytebuddy.matcher.ElementMatchers.not; | |||
| import com.google.auto.service.AutoService; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule; | ||||
| import java.util.List; | ||||
| import net.bytebuddy.matcher.ElementMatcher; | ||||
| 
 | ||||
| @AutoService(InstrumentationModule.class) | ||||
| public class XxlJobInstrumentationModule extends InstrumentationModule { | ||||
| public class XxlJobInstrumentationModule extends InstrumentationModule | ||||
|     implements ExperimentalInstrumentationModule { | ||||
| 
 | ||||
|   public XxlJobInstrumentationModule() { | ||||
|     super("xxl-job", "xxl-job-2.1.2"); | ||||
|  | @ -37,4 +39,9 @@ public class XxlJobInstrumentationModule extends InstrumentationModule { | |||
|         new SimpleJobHandlerInstrumentation(), | ||||
|         new GlueJobHandlerInstrumentation()); | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   public boolean isIndyReady() { | ||||
|     return true; | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -5,20 +5,20 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v2_3_0; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.v2_3_0.XxlJobSingletons.helper; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.isPublic; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.takesNoArguments; | ||||
| 
 | ||||
| import com.xxl.job.core.handler.IJobHandler; | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
| import net.bytebuddy.matcher.ElementMatcher; | ||||
| 
 | ||||
| public class GlueJobHandlerInstrumentation implements TypeInstrumentation { | ||||
|  | @ -38,28 +38,19 @@ public class GlueJobHandlerInstrumentation implements TypeInstrumentation { | |||
|   @SuppressWarnings("unused") | ||||
|   public static class ScheduleAdvice { | ||||
| 
 | ||||
|     @Nullable | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|         @Advice.FieldValue("jobHandler") IJobHandler handler, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createGlueJobRequest(handler); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule( | ||||
|         @Advice.FieldValue("jobHandler") IJobHandler handler) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createGlueJobRequest(handler)); | ||||
|     } | ||||
| 
 | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) @Nullable Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -5,20 +5,20 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v2_3_0; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.v2_3_0.XxlJobSingletons.helper; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.isPublic; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.takesNoArguments; | ||||
| 
 | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import java.lang.reflect.Method; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
| import net.bytebuddy.matcher.ElementMatcher; | ||||
| 
 | ||||
| public class MethodJobHandlerInstrumentation implements TypeInstrumentation { | ||||
|  | @ -38,28 +38,17 @@ public class MethodJobHandlerInstrumentation implements TypeInstrumentation { | |||
|   @SuppressWarnings("unused") | ||||
|   public static class ScheduleAdvice { | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|         @Advice.FieldValue("target") Object target, | ||||
|         @Advice.FieldValue("method") Method method, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createMethodJobRequest(target, method); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule( | ||||
|         @Advice.FieldValue("target") Object target, @Advice.FieldValue("method") Method method) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createMethodJobRequest(target, method)); | ||||
|     } | ||||
| 
 | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) @Nullable Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -5,20 +5,20 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v2_3_0; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.v2_3_0.XxlJobSingletons.helper; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.isPublic; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||||
| import static net.bytebuddy.matcher.ElementMatchers.takesNoArguments; | ||||
| 
 | ||||
| import com.xxl.job.core.glue.GlueTypeEnum; | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
| import net.bytebuddy.matcher.ElementMatcher; | ||||
| 
 | ||||
| public class ScriptJobHandlerInstrumentation implements TypeInstrumentation { | ||||
|  | @ -39,28 +39,18 @@ public class ScriptJobHandlerInstrumentation implements TypeInstrumentation { | |||
|   public static class ScheduleAdvice { | ||||
| 
 | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule( | ||||
|         @Advice.FieldValue("glueType") GlueTypeEnum glueType, | ||||
|         @Advice.FieldValue("jobId") int jobId, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createScriptJobRequest(glueType, jobId); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|         @Advice.FieldValue("jobId") int jobId) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createScriptJobRequest(glueType, jobId)); | ||||
|     } | ||||
| 
 | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -5,7 +5,6 @@ | |||
| 
 | ||||
| package io.opentelemetry.javaagent.instrumentation.xxljob.v2_3_0; | ||||
| 
 | ||||
| import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext; | ||||
| import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.hasSuperType; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobConstants.XXL_GLUE_JOB_HANDLER; | ||||
| import static io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobConstants.XXL_METHOD_JOB_HANDLER; | ||||
|  | @ -18,13 +17,14 @@ import static net.bytebuddy.matcher.ElementMatchers.not; | |||
| import static net.bytebuddy.matcher.ElementMatchers.takesNoArguments; | ||||
| 
 | ||||
| import com.xxl.job.core.handler.IJobHandler; | ||||
| import io.opentelemetry.context.Context; | ||||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobHelper; | ||||
| import io.opentelemetry.javaagent.instrumentation.xxljob.common.XxlJobProcessRequest; | ||||
| import javax.annotation.Nullable; | ||||
| import net.bytebuddy.asm.Advice; | ||||
| import net.bytebuddy.description.type.TypeDescription; | ||||
| import net.bytebuddy.implementation.bytecode.assign.Assigner; | ||||
| import net.bytebuddy.matcher.ElementMatcher; | ||||
| 
 | ||||
| public class SimpleJobHandlerInstrumentation implements TypeInstrumentation { | ||||
|  | @ -42,32 +42,20 @@ public class SimpleJobHandlerInstrumentation implements TypeInstrumentation { | |||
|         SimpleJobHandlerInstrumentation.class.getName() + "$ScheduleAdvice"); | ||||
|   } | ||||
| 
 | ||||
|   @SuppressWarnings("unused") | ||||
|   public static class ScheduleAdvice { | ||||
| 
 | ||||
|     @SuppressWarnings("unused") | ||||
|     @Advice.OnMethodEnter(suppress = Throwable.class) | ||||
|     public static void onSchedule( | ||||
|         @Advice.This IJobHandler handler, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       Context parentContext = currentContext(); | ||||
|       request = XxlJobProcessRequest.createSimpleJobRequest(handler); | ||||
|       context = helper().startSpan(parentContext, request); | ||||
|       if (context == null) { | ||||
|         return; | ||||
|       } | ||||
|       scope = context.makeCurrent(); | ||||
|     public static XxlJobHelper.XxlJobScope onSchedule(@Advice.This IJobHandler handler) { | ||||
|       return helper().startSpan(XxlJobProcessRequest.createSimpleJobRequest(handler)); | ||||
|     } | ||||
| 
 | ||||
|     @SuppressWarnings("unused") | ||||
|     @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||||
|     public static void stopSpan( | ||||
|         @Advice.Thrown Throwable throwable, | ||||
|         @Advice.Local("otelRequest") XxlJobProcessRequest request, | ||||
|         @Advice.Local("otelContext") Context context, | ||||
|         @Advice.Local("otelScope") Scope scope) { | ||||
|       helper().stopSpan(request, throwable, scope, context); | ||||
|         @Advice.Return(typing = Assigner.Typing.DYNAMIC) @Nullable Object result, | ||||
|         @Advice.Thrown @Nullable Throwable throwable, | ||||
|         @Advice.Enter @Nullable XxlJobHelper.XxlJobScope scope) { | ||||
|       helper().endSpan(scope, result, throwable); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -11,11 +11,13 @@ import static java.util.Arrays.asList; | |||
| import com.google.auto.service.AutoService; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||||
| import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule; | ||||
| import java.util.List; | ||||
| import net.bytebuddy.matcher.ElementMatcher; | ||||
| 
 | ||||
| @AutoService(InstrumentationModule.class) | ||||
| public class XxlJobInstrumentationModule extends InstrumentationModule { | ||||
| public class XxlJobInstrumentationModule extends InstrumentationModule | ||||
|     implements ExperimentalInstrumentationModule { | ||||
| 
 | ||||
|   public XxlJobInstrumentationModule() { | ||||
|     super("xxl-job", "xxl-job-2.3.0"); | ||||
|  | @ -35,4 +37,9 @@ public class XxlJobInstrumentationModule extends InstrumentationModule { | |||
|         new SimpleJobHandlerInstrumentation(), | ||||
|         new GlueJobHandlerInstrumentation()); | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   public boolean isIndyReady() { | ||||
|     return true; | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -9,11 +9,24 @@ import io.opentelemetry.context.Context; | |||
| import io.opentelemetry.context.Scope; | ||||
| import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||||
| import java.util.function.Predicate; | ||||
| import javax.annotation.Nullable; | ||||
| 
 | ||||
| public final class XxlJobHelper { | ||||
|   private final Instrumenter<XxlJobProcessRequest, Void> instrumenter; | ||||
|   private final Predicate<Object> failedStatusPredicate; | ||||
| 
 | ||||
|   public static class XxlJobScope { | ||||
|     private final XxlJobProcessRequest request; | ||||
|     private final Context context; | ||||
|     private final Scope scope; | ||||
| 
 | ||||
|     private XxlJobScope(XxlJobProcessRequest request, Context context, Scope scope) { | ||||
|       this.request = request; | ||||
|       this.context = context; | ||||
|       this.scope = scope; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   private XxlJobHelper( | ||||
|       Instrumenter<XxlJobProcessRequest, Void> instrumenter, | ||||
|       Predicate<Object> failedStatusPredicate) { | ||||
|  | @ -27,31 +40,25 @@ public final class XxlJobHelper { | |||
|     return new XxlJobHelper(instrumenter, failedStatusPredicate); | ||||
|   } | ||||
| 
 | ||||
|   public Context startSpan(Context parentContext, XxlJobProcessRequest request) { | ||||
|   @Nullable | ||||
|   public XxlJobScope startSpan(XxlJobProcessRequest request) { | ||||
|     Context parentContext = Context.current(); | ||||
|     if (!instrumenter.shouldStart(parentContext, request)) { | ||||
|       return null; | ||||
|     } | ||||
|     return instrumenter.start(parentContext, request); | ||||
|     Context context = instrumenter.start(parentContext, request); | ||||
|     return new XxlJobScope(request, context, context.makeCurrent()); | ||||
|   } | ||||
| 
 | ||||
|   public void stopSpan( | ||||
|       Object result, | ||||
|       XxlJobProcessRequest request, | ||||
|       Throwable throwable, | ||||
|       Scope scope, | ||||
|       Context context) { | ||||
|   public void endSpan( | ||||
|       @Nullable XxlJobScope scope, @Nullable Object result, @Nullable Throwable throwable) { | ||||
|     if (scope == null) { | ||||
|       return; | ||||
|     } | ||||
|     if (failedStatusPredicate.test(result)) { | ||||
|       request.setFailed(); | ||||
|       scope.request.setFailed(); | ||||
|     } | ||||
|     scope.close(); | ||||
|     instrumenter.end(context, request, null, throwable); | ||||
|   } | ||||
| 
 | ||||
|   public void stopSpan( | ||||
|       XxlJobProcessRequest request, Throwable throwable, Scope scope, Context context) { | ||||
|     stopSpan(null, request, throwable, scope, context); | ||||
|     scope.scope.close(); | ||||
|     instrumenter.end(scope.context, scope.request, null, throwable); | ||||
|   } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue