Search in sources :

Example 6 with AsyncTraceIdAccessor

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

the class HttpRequestExecuteAsyncMethodInnerClassConstructorInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    try {
        if (!validate(target, args)) {
            return;
        }
        final InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
        if (transaction != null && transaction.getAttachment() != null) {
            final AsyncTraceId asyncTraceId = (AsyncTraceId) transaction.getAttachment();
            // type check validate();
            ((AsyncTraceIdAccessor) target)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
            // clear.
            transaction.removeAttachment();
        }
    } catch (Throwable t) {
        logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
    }
}
Also used : InterceptorScopeInvocation(com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation) AsyncTraceId(com.navercorp.pinpoint.bootstrap.context.AsyncTraceId) AsyncTraceIdAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor)

Example 7 with AsyncTraceIdAccessor

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

the class TAsyncClientManagerCallInterceptor method injectAsyncTraceId.

private AsyncTraceId injectAsyncTraceId(final Object asyncMethodCallObj, final Trace trace) {
    final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
    SpanEventRecorder recorder = trace.currentSpanEventRecorder();
    recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
    ((AsyncTraceIdAccessor) asyncMethodCallObj)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
    if (isDebug) {
        logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
    }
    return asyncTraceId;
}
Also used : AsyncTraceId(com.navercorp.pinpoint.bootstrap.context.AsyncTraceId) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncTraceIdAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor)

Example 8 with AsyncTraceIdAccessor

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

the class RequestStartAsyncInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, "", descriptor.getMethodName(), "", args);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    try {
        SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        if (validate(target, result, throwable)) {
            ((AsyncAccessor) target)._$PINPOINT$_setAsync(Boolean.TRUE);
            // make asynchronous trace-id
            final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
            recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
            // result is BasicFuture
            // type check validate()
            ((AsyncTraceIdAccessor) result)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
            if (isDebug) {
                logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
            }
        }
        recorder.recordServiceType(TomcatConstants.TOMCAT_METHOD);
        recorder.recordApi(descriptor);
        recorder.recordException(throwable);
    } catch (Throwable t) {
        logger.warn("Failed to AFTER process. {}", t.getMessage(), t);
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncTraceId(com.navercorp.pinpoint.bootstrap.context.AsyncTraceId) AsyncAccessor(com.navercorp.pinpoint.plugin.tomcat.AsyncAccessor) AsyncTraceIdAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor)

Example 9 with AsyncTraceIdAccessor

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

the class HttpClientImplDoRequestInterceptor 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;
    }
    HttpClientRequest request = null;
    if (validate(result)) {
        request = (HttpClientRequest) result;
    }
    if (!trace.canSampled()) {
        if (request != null) {
            request.putHeader(Header.HTTP_SAMPLED.toString(), SamplingFlagUtils.SAMPLING_RATE_FALSE);
        }
        return;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordApi(methodDescriptor);
        recorder.recordException(throwable);
        recorder.recordServiceType(VertxConstants.VERTX_HTTP_CLIENT_INTERNAL);
        if (request != null) {
            // make asynchronous trace-id
            final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
            recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
            ((AsyncTraceIdAccessor) request)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
            if (isDebug) {
                logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
            }
        }
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : HttpClientRequest(io.vertx.core.http.HttpClientRequest) AsyncTraceIdAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor)

Example 10 with AsyncTraceIdAccessor

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

the class HttpClientRequestImplDoHandleResponseInterceptor method doInBeforeTrace.

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

Aggregations

AsyncTraceIdAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor)12 AsyncTraceId (com.navercorp.pinpoint.bootstrap.context.AsyncTraceId)9 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)8 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)7 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1 InterceptorScopeInvocation (com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation)1 OperationAccessor (com.navercorp.pinpoint.plugin.arcus.OperationAccessor)1 ServiceCodeAccessor (com.navercorp.pinpoint.plugin.arcus.ServiceCodeAccessor)1 AsyncAccessor (com.navercorp.pinpoint.plugin.resin.AsyncAccessor)1 AsyncAccessor (com.navercorp.pinpoint.plugin.tomcat.AsyncAccessor)1 HttpClientRequest (io.vertx.core.http.HttpClientRequest)1 HttpClientResponseImpl (io.vertx.core.http.impl.HttpClientResponseImpl)1 HttpServerRequestImpl (io.vertx.core.http.impl.HttpServerRequestImpl)1 HttpServerResponseImpl (io.vertx.core.http.impl.HttpServerResponseImpl)1 Future (java.util.concurrent.Future)1 MemcachedNode (net.spy.memcached.MemcachedNode)1 Operation (net.spy.memcached.ops.Operation)1 HttpRequest (org.apache.http.HttpRequest)1