Search in sources :

Example 41 with AsyncContextAccessor

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

the class HttpClientHandlerRequestWithBodyInterceptor method doInBeforeTrace.

@Override
public void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContext, Object target, Object[] args) {
    if (ArrayUtils.isEmpty(args)) {
        // Skip
        return;
    }
    // Set HttpClientOptions
    if (args[0] instanceof AsyncContextAccessor) {
        ((AsyncContextAccessor) args[0])._$PINPOINT$_setAsyncContext(asyncContext);
    }
    // Set hostname
    if (args[0] instanceof ChannelOperations) {
        try {
            final ChannelOperations channelOperations = (ChannelOperations) args[0];
            final InetSocketAddress inetSocketAddress = (InetSocketAddress) channelOperations.channel().remoteAddress();
            if (inetSocketAddress != null) {
                final String hostName = SocketAddressUtils.getHostNameFirst(inetSocketAddress);
                if (hostName != null) {
                    recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, HostAndPort.toHostAndPortString(hostName, inetSocketAddress.getPort()));
                }
            }
        } catch (Exception ignore) {
        }
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) ChannelOperations(reactor.netty.channel.ChannelOperations)

Example 42 with AsyncContextAccessor

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

the class SchedulerAndWorkerScheduleMethodInterceptor method doInAfterTrace.

// Disposable schedule(Runnable task);
// Disposable schedule(Runnable task, long delay, TimeUnit unit)
// Disposable schedulePeriodically(Runnable task, long initialDelay, long period, TimeUnit unit)
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    recorder.recordApi(methodDescriptor);
    recorder.recordException(throwable);
    recorder.recordServiceType(ReactorConstants.REACTOR_NETTY);
    if (isAsynchronousInvocation(target, args, result, throwable)) {
        // Trace to Disposable object
        final AsyncContext asyncContext = recorder.recordNextAsyncContext();
        ((AsyncContextAccessor) (result))._$PINPOINT$_setAsyncContext(asyncContext);
    }
}
Also used : AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 43 with AsyncContextAccessor

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

the class LettuceMethodInterceptor method doInAfterTrace.

@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    final String endPoint = toEndPoint(target);
    recorder.recordApi(getMethodDescriptor());
    recorder.recordEndPoint(endPoint != null ? endPoint : "Unknown");
    recorder.recordDestinationId(LettuceConstants.REDIS_LETTUCE.getName());
    recorder.recordServiceType(LettuceConstants.REDIS_LETTUCE);
    recorder.recordException(throwable);
    if (result instanceof AsyncContextAccessor) {
        if (AsyncContextAccessorUtils.getAsyncContext(result) == null) {
            // Avoid duplicate async context
            final AsyncContext asyncContext = recorder.recordNextAsyncContext();
            ((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
        }
    }
}
Also used : AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 44 with AsyncContextAccessor

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

the class HttpTcpClientConnectInterceptor method doInAfterTrace.

@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) throws Exception {
    recorder.recordApi(methodDescriptor);
    recorder.recordException(throwable);
    recorder.recordServiceType(ReactorNettyConstants.REACTOR_NETTY_CLIENT_INTERNAL);
    if (result instanceof AsyncContextAccessor) {
        // Set MonoHttpConnect
        final AsyncContext asyncContext = recorder.recordNextAsyncContext();
        ((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
    }
}
Also used : AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 45 with AsyncContextAccessor

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

the class ParallelWorkerConstructorInterceptor method after.

public void after(Object target, Object[] arg, Object result, Throwable throwable) {
    AsyncContext asyncContext = (AsyncContext) scope.getCurrentInvocation().getAttachment();
    ((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
}
Also used : 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