Search in sources :

Example 26 with SpanEventRecorder

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

the class HttpMethodBaseExecuteMethodInterceptor method recordEntity.

private void recordEntity(HttpMethod httpMethod, Trace trace) {
    if (httpMethod instanceof EntityEnclosingMethod) {
        final EntityEnclosingMethod entityEnclosingMethod = (EntityEnclosingMethod) httpMethod;
        final RequestEntity entity = entityEnclosingMethod.getRequestEntity();
        if (entity != null && entity.isRepeatable() && entity.getContentLength() > 0) {
            if (entitySampler.isSampling()) {
                try {
                    String entityValue;
                    String charSet = entityEnclosingMethod.getRequestCharSet();
                    if (charSet == null || charSet.isEmpty()) {
                        charSet = HttpConstants.DEFAULT_CONTENT_CHARSET;
                    }
                    if (entity instanceof ByteArrayRequestEntity || entity instanceof StringRequestEntity) {
                        entityValue = entityUtilsToString(entity, charSet);
                    } else {
                        entityValue = entity.getClass() + " (ContentType:" + entity.getContentType() + ")";
                    }
                    final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
                    recorder.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, entityValue);
                } catch (Exception e) {
                    logger.debug("HttpEntityEnclosingRequest entity record fail. Caused:{}", e.getMessage(), e);
                }
            }
        }
    }
}
Also used : StringRequestEntity(org.apache.commons.httpclient.methods.StringRequestEntity) EntityEnclosingMethod(org.apache.commons.httpclient.methods.EntityEnclosingMethod) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) ByteArrayRequestEntity(org.apache.commons.httpclient.methods.ByteArrayRequestEntity) StringRequestEntity(org.apache.commons.httpclient.methods.StringRequestEntity) RequestEntity(org.apache.commons.httpclient.methods.RequestEntity) URIException(org.apache.commons.httpclient.URIException) ByteArrayRequestEntity(org.apache.commons.httpclient.methods.ByteArrayRequestEntity)

Example 27 with SpanEventRecorder

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

the class HttpMethodBaseExecuteMethodInterceptor method recordCookie.

private void recordCookie(HttpMethod httpMethod, Trace trace) {
    org.apache.commons.httpclient.Header cookie = httpMethod.getRequestHeader("Cookie");
    if (cookie == null) {
        return;
    }
    final String value = cookie.getValue();
    if (value != null && !value.isEmpty()) {
        if (cookieSampler.isSampling()) {
            final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
            recorder.recordAttribute(AnnotationKey.HTTP_COOKIE, StringUtils.abbreviate(value, MAX_READ_SIZE));
        }
    }
}
Also used : SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)

Example 28 with SpanEventRecorder

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

the class HttpRequestExecuteAsyncMethodInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    SpanEventRecorder recorder = trace.traceBlockBegin();
    try {
        // set asynchronous trace
        final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
        recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
        // set async id.
        InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
        if (transaction != null) {
            transaction.setAttachment(asyncTraceId);
            if (isDebug) {
                logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
            }
        }
    } catch (Throwable t) {
        logger.warn("Failed to before process. {}", t.getMessage(), t);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) InterceptorScopeInvocation(com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncTraceId(com.navercorp.pinpoint.bootstrap.context.AsyncTraceId)

Example 29 with SpanEventRecorder

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

the class ToJsonInterceptor method after.

@Override
public void after(Object target, Object result, Throwable throwable) {
    if (logger.isDebugEnabled()) {
        logger.afterInterceptor(target, null, 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 (result != null && result instanceof String) {
            recorder.recordAttribute(GsonPlugin.GSON_ANNOTATION_KEY_JSON_LENGTH, ((String) result).length());
        }
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)

Example 30 with SpanEventRecorder

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

the class StandardHostValveInvokeInterceptor method before.

/*
     * (non-Javadoc)
     * 
     * @see com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor#before(java.lang.Object, java.lang.Object[])
     */
@Override
public void before(final Object target, final Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    try {
        final Trace trace = createTrace(target, args);
        if (trace == null) {
            return;
        }
        // TODO STATDISABLE this logic was added to disable statistics tracing
        if (!trace.canSampled()) {
            return;
        }
        // ------------------------------------------------------
        final SpanEventRecorder recorder = trace.traceBlockBegin();
        recorder.recordServiceType(JbossConstants.JBOSS_METHOD);
    } catch (final Throwable th) {
        if (logger.isWarnEnabled()) {
            logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
        }
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)

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