Search in sources :

Example 6 with AsyncContextAccessor

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

the class TransactionIdFailedInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    AsyncContextAccessor accessor = ArrayArgumentUtils.getArgument(args, 2, AsyncContextAccessor.class);
    AsyncContext asyncContext = accessor._$PINPOINT$_getAsyncContext();
    final Trace trace = ((PinpointTraceAccessor) accessor)._$PINPOINT$_getPinpointTrace();
    if (asyncContext == null || trace == null) {
        return;
    }
    // set error message
    String message = ((Function0) args[3]).apply().toString();
    SpanEventRecorder recorder = trace.currentSpanEventRecorder();
    recorder.recordException(new Throwable(message));
    logger.debug("Record failed message : {}", message);
    // close trace block and context
    trace.traceBlockEnd();
    trace.close();
    asyncContext.close();
}
Also used : AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) PinpointTraceAccessor(com.navercorp.pinpoint.plugin.openwhisk.accessor.PinpointTraceAccessor)

Example 7 with AsyncContextAccessor

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

the class QueueingConsumerHandleInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (ArrayUtils.isEmpty(args)) {
        return;
    }
    if (!(args[0] instanceof AsyncContextAccessor)) {
        return;
    }
    if (!(result instanceof AsyncContextAccessor)) {
        return;
    }
    AsyncContext asyncContext = ((AsyncContextAccessor) args[0])._$PINPOINT$_getAsyncContext();
    ((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
}
Also used : AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 8 with AsyncContextAccessor

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

the class HttpClientImplDoRequestInterceptorV4 method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args, result, throwable);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    if (!trace.canSampled()) {
        return;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordApi(methodDescriptor);
        recorder.recordException(throwable);
        recorder.recordServiceType(VertxConstants.VERTX_HTTP_CLIENT_INTERNAL);
        final String hostAndPort = toHostAndPort(args);
        if (hostAndPort != null) {
            recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, hostAndPort);
            if (isDebug) {
                logger.debug("Set hostAndPort {}", hostAndPort);
            }
        }
        if (target instanceof AsyncContextAccessor) {
            // make asynchronous trace-id
            final AsyncContext asyncContext = recorder.recordNextAsyncContext();
            ((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
        }
    } finally {
        trace.traceBlockEnd();
    }
}
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 9 with AsyncContextAccessor

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

the class HttpClientRequestImplConstructorInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args, result, throwable);
    }
    if (ArrayUtils.getLength(args) < 1) {
        return;
    }
    final Object arg = args[0];
    final AsyncContext asyncContext = AsyncContextAccessorUtils.getAsyncContext(arg);
    if (asyncContext != null) {
        ((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
    }
    if (arg instanceof SamplingRateFlag) {
        final Boolean samplingRateFlag = ((SamplingRateFlag) (args[0]))._$PINPOINT$_getSamplingRateFlag();
        ((SamplingRateFlag) target)._$PINPOINT$_setSamplingRateFlag(samplingRateFlag);
    }
}
Also used : SamplingRateFlag(com.navercorp.pinpoint.plugin.vertx.SamplingRateFlag) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) AsyncContext(com.navercorp.pinpoint.bootstrap.context.AsyncContext)

Example 10 with AsyncContextAccessor

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

the class HttpClientRequestImplDoHandleResponseInterceptor method doInBeforeTrace.

@Override
public void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContext, Object target, Object[] args) {
    if (!validate(args)) {
        return;
    }
    final HttpClientResponseImpl response = (HttpClientResponseImpl) args[0];
    if (statusCode) {
        recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, response.statusCode());
    }
    ((AsyncContextAccessor) response)._$PINPOINT$_setAsyncContext(asyncContext);
}
Also used : HttpClientResponseImpl(io.vertx.core.http.impl.HttpClientResponseImpl) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor)

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