Search in sources :

Example 1 with ThriftHeader

use of com.navercorp.pinpoint.plugin.thrift.ThriftHeader in project pinpoint by naver.

the class TProtocolReadTTypeInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args, result, throwable);
    }
    if (!validate(target)) {
        return;
    }
    final boolean shouldTrace = ((ServerMarkerFlagFieldAccessor) target)._$PINPOINT$_getServerMarkerFlag();
    if (shouldTrace) {
        InterceptorScopeInvocation currentTransaction = this.scope.getCurrentInvocation();
        Object attachment = currentTransaction.getAttachment();
        if (attachment instanceof ThriftClientCallContext) {
            ThriftClientCallContext clientCallContext = (ThriftClientCallContext) attachment;
            ThriftHeader headerKeyToBeRead = clientCallContext.getTraceHeaderToBeRead();
            if (headerKeyToBeRead == NONE) {
                return;
            }
            ThriftRequestProperty parentTraceInfo = clientCallContext.getTraceHeader();
            if (parentTraceInfo == null) {
                parentTraceInfo = new ThriftRequestProperty();
                clientCallContext.setTraceHeader(parentTraceInfo);
            }
            try {
                parentTraceInfo.setTraceHeader(headerKeyToBeRead, result);
            } catch (Throwable t) {
                logger.warn("Error reading trace header.", t);
            } finally {
                clientCallContext.setTraceHeaderToBeRead(NONE);
            }
        }
    }
}
Also used : InterceptorScopeInvocation(com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation) ThriftClientCallContext(com.navercorp.pinpoint.plugin.thrift.ThriftClientCallContext) ThriftRequestProperty(com.navercorp.pinpoint.plugin.thrift.ThriftRequestProperty) ThriftHeader(com.navercorp.pinpoint.plugin.thrift.ThriftHeader) ServerMarkerFlagFieldAccessor(com.navercorp.pinpoint.plugin.thrift.field.accessor.ServerMarkerFlagFieldAccessor)

Aggregations

InterceptorScopeInvocation (com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation)1 ThriftClientCallContext (com.navercorp.pinpoint.plugin.thrift.ThriftClientCallContext)1 ThriftHeader (com.navercorp.pinpoint.plugin.thrift.ThriftHeader)1 ThriftRequestProperty (com.navercorp.pinpoint.plugin.thrift.ThriftRequestProperty)1 ServerMarkerFlagFieldAccessor (com.navercorp.pinpoint.plugin.thrift.field.accessor.ServerMarkerFlagFieldAccessor)1