Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[#10630] Backport: Fix kotlin coroutines dispatch interceptor #10631

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,21 @@ public DispatchInterceptor(TraceContext traceContext, MethodDescriptor descripto
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, descriptor.getClassName(), descriptor.getMethodName(), descriptor.getParameterDescriptor(), args);
logger.beforeInterceptor(target, args);
}

Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}

if (isCompletedContinuation(args)) {
return;
}

final SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(serviceType);
AsyncContextAccessor accessor = ArrayArgumentUtils.getArgument(args, 0, AsyncContextAccessor.class);
if (accessor != null) {
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
accessor._$PINPOINT$_setAsyncContext(asyncContext);
if (Boolean.FALSE == isCompletedContinuation(args)) {
AsyncContextAccessor accessor = ArrayArgumentUtils.getArgument(args, 0, AsyncContextAccessor.class);
if (accessor != null) {
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
accessor._$PINPOINT$_setAsyncContext(asyncContext);
}
}
}

Expand All @@ -90,18 +87,14 @@ private boolean isCompletedContinuation(final Object[] args) {
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, descriptor.getClassName(), descriptor.getMethodName(), descriptor.getParameterDescriptor(), args, result, throwable);
logger.afterInterceptor(target, args);
}

Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}

if (isCompletedContinuation(args)) {
return;
}

try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
Expand All @@ -110,7 +103,5 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
} finally {
trace.traceBlockEnd();
}

}

}