Search in sources :

Example 11 with AsyncTraceIdAccessor

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

the class ServerConnectionHandleRequestInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    if (traceContext.currentRawTraceObject() != null) {
        // duplicate trace.
        return;
    }
    try {
        if (!validate(args)) {
            // invalid args.
            return;
        }
        final HttpServerRequestImpl request = (HttpServerRequestImpl) args[0];
        final HttpServerResponseImpl response = (HttpServerResponseImpl) args[1];
        // create trace for standalone entry point.
        final Trace trace = createTrace(request);
        if (trace == null) {
            return;
        }
        entryScope(trace);
        if (!trace.canSampled()) {
            return;
        }
        final SpanEventRecorder recorder = trace.traceBlockBegin();
        recorder.recordServiceType(VertxConstants.VERTX_HTTP_SERVER_INTERNAL);
        // make asynchronous trace-id
        final AsyncTraceId asyncTraceId = trace.getAsyncTraceId(true);
        recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
        ((AsyncTraceIdAccessor) request)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
        ((AsyncTraceIdAccessor) response)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
        if (isDebug) {
            logger.debug("Set closeable-asyncTraceId metadata {}", asyncTraceId);
        }
    } catch (Throwable t) {
        if (logger.isWarnEnabled()) {
            logger.warn("BEFORE. Caused:{}", t.getMessage(), t);
        }
    }
}
Also used : HttpServerResponseImpl(io.vertx.core.http.impl.HttpServerResponseImpl) HttpServerRequestImpl(io.vertx.core.http.impl.HttpServerRequestImpl) AsyncTraceIdAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor)

Example 12 with AsyncTraceIdAccessor

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

the class VertxImplExecuteBlockingInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    final SpanEventRecorder recorder = trace.traceBlockBegin();
    if (validate(args, 0) || validate(args, 2)) {
        // make asynchronous trace-id
        final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
        recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
        if (validate(args, 0)) {
            // args 0 'io.vertx.core.Handler'
            ((AsyncTraceIdAccessor) args[0])._$PINPOINT$_setAsyncTraceId(asyncTraceId);
        }
        if (validate(args, 2)) {
            // args 2 'io.vertx.core.Handler'
            ((AsyncTraceIdAccessor) args[2])._$PINPOINT$_setAsyncTraceId(asyncTraceId);
        }
        if (isDebug) {
            logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
        }
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncTraceId(com.navercorp.pinpoint.bootstrap.context.AsyncTraceId) 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