Search in sources :

Example 21 with AsyncContext

use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.

the class ServerStreamCreatedInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    if (traceContext.currentTraceObject() != null) {
        return;
    }
    GrpcServerStreamRequest request = GrpcServerStreamRequest.create(args);
    if (request == null) {
        return;
    }
    final Trace trace = createTrace(request);
    if (trace == null || !trace.canSampled()) {
        return;
    }
    final SpanEventRecorder recorder = trace.traceBlockBegin();
    recorder.recordServiceType(GrpcConstants.SERVER_SERVICE_TYPE_INTERNAL);
    final AsyncContext asyncContext = recorder.recordNextAsyncContext(true);
    if (args[0] instanceof AsyncContextAccessor) {
        ((AsyncContextAccessor) args[0])._$PINPOINT$_setAsyncContext(asyncContext);
        logger.debug("Set closeable-AsyncContext {}", asyncContext);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 22 with AsyncContext

use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.

the class MongoCUDSessionInterceptor method doInAfterTrace.

@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    if (collectJson) {
        final boolean success = InterceptorUtils.isSuccess(throwable);
        if (success) {
            if (args != null) {
                NormalizedBson parsedBson = MongoUtil.parseBson(args, traceBsonBindValue);
                MongoUtil.recordParsedBson(recorder, parsedBson);
            }
        }
    }
    recorder.recordException(throwable);
    if (isAsynchronousInvocation(target, args, result, throwable)) {
        // Trace to Disposable object
        final AsyncContext asyncContext = recorder.recordNextAsyncContext();
        ((AsyncContextAccessor) (result))._$PINPOINT$_setAsyncContext(asyncContext);
        if (isDebug) {
            logger.debug("Set AsyncContext {}, result={}", asyncContext, result);
        }
    }
}
Also used : NormalizedBson(com.navercorp.pinpoint.plugin.mongo.NormalizedBson) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 23 with AsyncContext

use of com.navercorp.pinpoint.bootstrap.context.AsyncContext 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 24 with AsyncContext

use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.

the class BodyInserterRequestBuilderWriteToInterceptor method doInAfterTrace.

@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    recorder.recordApi(methodDescriptor);
    recorder.recordException(throwable);
    if (!validate(args)) {
        return;
    }
    final ClientHttpRequest request = (ClientHttpRequest) args[0];
    final ClientRequestWrapper clientRequestWrapper = new WebClientRequestWrapper(request);
    this.clientRequestRecorder.record(recorder, clientRequestWrapper, throwable);
    this.cookieRecorder.record(recorder, request, throwable);
    if (isAsync(result)) {
        // make asynchronous trace-id
        final AsyncContext asyncContext = recorder.recordNextAsyncContext();
        ((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
        if (isDebug) {
            logger.debug("Set closeable-AsyncContext {}", asyncContext);
        }
    }
}
Also used : ClientRequestWrapper(com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapper) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext) ClientHttpRequest(org.springframework.http.client.reactive.ClientHttpRequest)

Example 25 with AsyncContext

use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.

the class DefaultWebClientExchangeMethodInterceptor method doInAfterTrace.

@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    recorder.recordApi(methodDescriptor);
    recorder.recordException(throwable);
    recorder.recordServiceType(SpringWebFluxConstants.SPRING_WEBFLUX);
    if (isAsync(result)) {
        // make asynchronous trace-id
        final AsyncContext asyncContext = recorder.recordNextAsyncContext();
        ((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
        if (isDebug) {
            logger.debug("Set closeable-AsyncContext {}", asyncContext);
        }
    }
}
Also used : AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Aggregations

AsyncContext (com.navercorp.pinpoint.bootstrap.context.AsyncContext)68 AsyncContextAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor)44 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)31 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)28 Test (org.junit.Test)7 AsyncState (com.navercorp.pinpoint.bootstrap.context.AsyncState)2 InterceptorScopeInvocation (com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation)2 NormalizedBson (com.navercorp.pinpoint.plugin.mongo.NormalizedBson)2 HttpServerResponse (io.vertx.core.http.HttpServerResponse)2 Method (java.lang.reflect.Method)2 Continuation (kotlin.coroutines.Continuation)2 RequestContextImpl (akka.http.scaladsl.server.RequestContextImpl)1 AsyncStateSupport (com.navercorp.pinpoint.bootstrap.context.AsyncStateSupport)1 SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)1 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1 ClientRequestWrapper (com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapper)1 OperationAccessor (com.navercorp.pinpoint.plugin.arcus.OperationAccessor)1 ServiceCodeAccessor (com.navercorp.pinpoint.plugin.arcus.ServiceCodeAccessor)1 AsyncStartFlagFieldAccessor (com.navercorp.pinpoint.plugin.netty.field.accessor.AsyncStartFlagFieldAccessor)1 TraceFutureFlagAccessor (com.navercorp.pinpoint.plugin.resttemplate.field.accessor.TraceFutureFlagAccessor)1