Search in sources :

Example 1 with AsyncContextAccessor

use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor 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 2 with AsyncContextAccessor

use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor 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 3 with AsyncContextAccessor

use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.

the class DefaultClientExchangeHandlerImplStartMethodInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    final Trace trace = traceContext.currentRawTraceObject();
    if (trace == null) {
        return;
    }
    final HttpRequest httpRequest = getHttpRequest(target);
    final NameIntValuePair<String> host = getHost(target);
    final boolean sampling = trace.canSampled();
    if (!sampling) {
        if (httpRequest != null) {
            this.requestTraceWriter.write(httpRequest);
        }
        return;
    }
    final SpanEventRecorder recorder = trace.traceBlockBegin();
    // set remote trace
    final TraceId nextId = trace.getTraceId().getNextTraceId();
    recorder.recordNextSpanId(nextId.getSpanId());
    recorder.recordServiceType(HttpClient4Constants.HTTP_CLIENT_4);
    if (httpRequest != null) {
        final String hostString = getHostString(host.getName(), host.getValue());
        this.requestTraceWriter.write(httpRequest, nextId, hostString);
    }
    try {
        if (isAsynchronousInvocation(target, args)) {
            // set asynchronous trace
            final AsyncContext asyncContext = recorder.recordNextAsyncContext();
            // check type isAsynchronousInvocation()
            ((AsyncContextAccessor) ((ResultFutureGetter) target)._$PINPOINT$_getResultFuture())._$PINPOINT$_setAsyncContext(asyncContext);
            if (isDebug) {
                logger.debug("Set AsyncContext {}", asyncContext);
            }
        }
    } catch (Throwable t) {
        logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) HttpRequest(org.apache.http.HttpRequest) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 4 with AsyncContextAccessor

use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.

the class HystrixObservableTimeoutOperatorCallInterceptor method doInBeforeTrace.

@Override
protected void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) {
    if (target instanceof AsyncContextAccessor) {
        AsyncContext asyncContext = recorder.recordNextAsyncContext();
        ((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
    }
}
Also used : AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 5 with AsyncContextAccessor

use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.

the class RabbitMQConsumerDispatchInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (!validate(target, args)) {
        return;
    }
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    try {
        final Trace trace = createTrace(target, args);
        if (trace == null) {
            return;
        }
        if (!trace.canSampled()) {
            return;
        }
        SpanEventRecorder recorder = trace.traceBlockBegin();
        recorder.recordServiceType(RabbitMQClientConstants.RABBITMQ_CLIENT_INTERNAL);
        // args[2] would be com.rabbitmq.client.Envelope, implementing AsyncContextAccessor via plugin
        AsyncContextAccessor accessor = ArrayArgumentUtils.getArgument(args, 2, AsyncContextAccessor.class);
        if (accessor != null) {
            AsyncContext asyncContext = recorder.recordNextAsyncContext();
            accessor._$PINPOINT$_setAsyncContext(asyncContext);
        }
    } catch (Throwable th) {
        if (logger.isWarnEnabled()) {
            logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
        }
    }
}
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)

Aggregations

AsyncContextAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor)54 AsyncContext (com.navercorp.pinpoint.bootstrap.context.AsyncContext)44 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)16 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)16 NormalizedBson (com.navercorp.pinpoint.plugin.mongo.NormalizedBson)2 PinpointTraceAccessor (com.navercorp.pinpoint.plugin.openwhisk.accessor.PinpointTraceAccessor)2 Continuation (kotlin.coroutines.Continuation)2 RequestContextImpl (akka.http.scaladsl.server.RequestContextImpl)1 AsyncState (com.navercorp.pinpoint.bootstrap.context.AsyncState)1 AsyncStateSupport (com.navercorp.pinpoint.bootstrap.context.AsyncStateSupport)1 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1 InterceptorScopeInvocation (com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation)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 LogMarkerMethodDescriptor (com.navercorp.pinpoint.plugin.openwhisk.descriptor.LogMarkerMethodDescriptor)1 TraceFutureFlagAccessor (com.navercorp.pinpoint.plugin.resttemplate.field.accessor.TraceFutureFlagAccessor)1 SamplingRateFlag (com.navercorp.pinpoint.plugin.vertx.SamplingRateFlag)1 Channel (io.netty.channel.Channel)1