Search in sources :

Example 56 with SpanEventRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.

the class ApiInterceptor 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;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        if (traceKey) {
            final Object recordObject = args[keyIndex];
            recorder.recordApi(methodDescriptor, recordObject, keyIndex);
        } else {
            recorder.recordApi(methodDescriptor);
        }
        recorder.recordException(throwable);
        // find the target node
        if (result instanceof Future && result instanceof OperationAccessor) {
            final Operation op = ((OperationAccessor) result)._$PINPOINT$_getOperation();
            if (op != null) {
                final MemcachedNode handlingNode = op.getHandlingNode();
                if (handlingNode != null) {
                    final String endPoint = getEndPoint(handlingNode);
                    if (endPoint != null) {
                        recorder.recordEndPoint(endPoint);
                    }
                }
            } else {
                logger.info("operation not found");
            }
        }
        if (target instanceof ServiceCodeAccessor) {
            // determine the service type
            String serviceCode = ((ServiceCodeAccessor) target)._$PINPOINT$_getServiceCode();
            if (serviceCode != null) {
                recorder.recordDestinationId(serviceCode);
                recorder.recordServiceType(ArcusConstants.ARCUS);
            } else {
                recorder.recordDestinationId("MEMCACHED");
                recorder.recordServiceType(ArcusConstants.MEMCACHED);
            }
        } else {
            recorder.recordDestinationId("MEMCACHED");
            recorder.recordServiceType(ArcusConstants.MEMCACHED);
        }
        try {
            if (isAsynchronousInvocation(target, args, result, throwable)) {
                // set asynchronous trace
                this.traceContext.getAsyncId();
                final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
                recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
                // type check isAsynchronousInvocation
                ((AsyncTraceIdAccessor) result)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
                if (isDebug) {
                    logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
                }
            }
        } catch (Throwable t) {
            logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
        }
    } catch (Throwable th) {
        if (logger.isWarnEnabled()) {
            logger.warn("AFTER error. Caused:{}", th.getMessage(), th);
        }
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) OperationAccessor(com.navercorp.pinpoint.plugin.arcus.OperationAccessor) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncTraceId(com.navercorp.pinpoint.bootstrap.context.AsyncTraceId) Future(java.util.concurrent.Future) MemcachedNode(net.spy.memcached.MemcachedNode) Operation(net.spy.memcached.ops.Operation) AsyncTraceIdAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor) ServiceCodeAccessor(com.navercorp.pinpoint.plugin.arcus.ServiceCodeAccessor)

Example 57 with SpanEventRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.

the class FrontCacheGetFutureGetInterceptor 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;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordApi(methodDescriptor);
        if (target instanceof CacheNameAccessor) {
            final String cacheName = ((CacheNameAccessor) target)._$PINPOINT$_getCacheName();
            if (cacheName != null) {
                recorder.recordDestinationId(cacheName);
            }
        }
        recorder.recordServiceType(ArcusConstants.ARCUS_EHCACHE_FUTURE_GET);
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) CacheNameAccessor(com.navercorp.pinpoint.plugin.arcus.CacheNameAccessor) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)

Example 58 with SpanEventRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.

the class HttpRequestExecuteAsyncMethodInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    try {
        SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordApi(methodDescriptor);
        recorder.recordServiceType(HttpClientConstants.HTTP_CLIENT_INTERNAL);
        recorder.recordException(throwable);
        // remove async id.
        InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
        if (transaction != null) {
            // clear
            transaction.removeAttachment();
        }
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) InterceptorScopeInvocation(com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)

Example 59 with SpanEventRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.

the class FromJsonInterceptor method after.

@Override
public void after(Object target, Object arg0, Object arg1, Object result, Throwable throwable) {
    if (logger.isDebugEnabled()) {
        logger.afterInterceptor(target, new Object[] { arg0, arg1 }, result, throwable);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    try {
        SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordServiceType(GsonPlugin.GSON_SERVICE_TYPE);
        recorder.recordApi(descriptor);
        recorder.recordException(throwable);
        if (arg0 != null && arg0 instanceof String) {
            recorder.recordAttribute(GsonPlugin.GSON_ANNOTATION_KEY_JSON_LENGTH, ((String) arg0).length());
        }
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)

Example 60 with SpanEventRecorder

use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.

the class HttpMethodBaseExecuteMethodInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        if (target instanceof HttpMethod) {
            HttpMethod httpMethod = (HttpMethod) target;
            recordDestination(trace, httpMethod, args);
            recordRequest(trace, httpMethod, throwable);
        }
        if (result != null) {
            recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, result);
        }
        recorder.recordApi(descriptor);
        recorder.recordException(throwable);
        final HttpClient3CallContext callContext = getAndCleanAttachment();
        if (callContext != null) {
            recordIo(recorder, callContext);
        }
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) HttpClient3CallContext(com.navercorp.pinpoint.plugin.httpclient3.HttpClient3CallContext) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) HttpMethod(org.apache.commons.httpclient.HttpMethod)

Aggregations

SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)86 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)75 AsyncTraceId (com.navercorp.pinpoint.bootstrap.context.AsyncTraceId)12 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)9 AsyncTraceIdAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor)8 InterceptorScopeInvocation (com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation)8 DatabaseInfoAccessor (com.navercorp.pinpoint.bootstrap.plugin.jdbc.DatabaseInfoAccessor)5 DatabaseInfo (com.navercorp.pinpoint.bootstrap.context.DatabaseInfo)4 Socket (java.net.Socket)3 HttpRequest (org.apache.http.HttpRequest)3 Test (org.junit.Test)3 MethodDescriptor (com.navercorp.pinpoint.bootstrap.context.MethodDescriptor)2 ParsingResult (com.navercorp.pinpoint.bootstrap.context.ParsingResult)2 SpanRecorder (com.navercorp.pinpoint.bootstrap.context.SpanRecorder)2 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)2 BindValueAccessor (com.navercorp.pinpoint.bootstrap.plugin.jdbc.BindValueAccessor)2 DefaultDatabaseInfo (com.navercorp.pinpoint.bootstrap.plugin.jdbc.DefaultDatabaseInfo)2 JdbcUrlParser (com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParser)2 ParsingResultAccessor (com.navercorp.pinpoint.bootstrap.plugin.jdbc.ParsingResultAccessor)2 UnKnownDatabaseInfo (com.navercorp.pinpoint.bootstrap.plugin.jdbc.UnKnownDatabaseInfo)2