use of com.navercorp.pinpoint.plugin.thrift.ThriftClientCallContext in project pinpoint by naver.
the class TProtocolReadMessageBeginInterceptor 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 = ((AsyncMarkerFlagFieldAccessor) target)._$PINPOINT$_getAsyncMarkerFlag();
if (shouldTrace) {
String methodName = ThriftConstants.UNKNOWN_METHOD_NAME;
if (result instanceof TMessage) {
TMessage message = (TMessage) result;
methodName = message.name;
}
ThriftClientCallContext clientCallContext = new ThriftClientCallContext(methodName);
InterceptorScopeInvocation currentTransaction = this.scope.getCurrentInvocation();
currentTransaction.setAttachment(clientCallContext);
}
}
use of com.navercorp.pinpoint.plugin.thrift.ThriftClientCallContext 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);
}
}
}
}
Aggregations