Search in sources :

Example 1 with Continuation

use of kotlin.coroutines.Continuation in project pinpoint by naver.

the class ScheduleResumeInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, descriptor.getClassName(), descriptor.getMethodName(), descriptor.getParameterDescriptor(), args);
    }
    final Continuation continuation = getContinuation(args);
    if (continuation == null) {
        return;
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    final SpanEventRecorder recorder = trace.traceBlockBegin();
    final AsyncContextAccessor asyncContextAccessor = getAsyncContextAccessor(continuation);
    if (asyncContextAccessor != null) {
        final AsyncContext asyncContext = recorder.recordNextAsyncContext();
        asyncContextAccessor._$PINPOINT$_setAsyncContext(asyncContext);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) Continuation(kotlin.coroutines.Continuation) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 2 with Continuation

use of kotlin.coroutines.Continuation in project pinpoint by naver.

the class ScheduleResumeInterceptor method after.

@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);
    }
    final Continuation continuation = getContinuation(args);
    if (continuation == null) {
        return;
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordApi(descriptor);
        recorder.recordServiceType(serviceType);
        recorder.recordException(throwable);
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) Continuation(kotlin.coroutines.Continuation) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)

Example 3 with Continuation

use of kotlin.coroutines.Continuation in project pinpoint by naver.

the class ResumeWithInterceptor method getAsyncContext.

private AsyncContext getAsyncContext(Object object) {
    if (object instanceof Continuation) {
        CoroutineContext context = ((Continuation<?>) object).getContext();
        if (context instanceof AsyncContextAccessor) {
            AsyncContextAccessor accessor = (AsyncContextAccessor) context;
            AsyncContext asyncContext = accessor._$PINPOINT$_getAsyncContext();
            return asyncContext;
        }
    }
    return null;
}
Also used : Continuation(kotlin.coroutines.Continuation) CoroutineContext(kotlin.coroutines.CoroutineContext) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Aggregations

Continuation (kotlin.coroutines.Continuation)3 AsyncContextAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor)2 AsyncContext (com.navercorp.pinpoint.bootstrap.context.AsyncContext)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)2 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)2 CoroutineContext (kotlin.coroutines.CoroutineContext)1