@Override
    public void before(Object target, Object[] args) {
        if (isDebug) {
            logger.beforeInterceptor(target, args);
        }
        if (target instanceof TServiceClient) {
            TServiceClient client = (TServiceClient)target;
            TProtocol oprot = client.getOutputProtocol();
            TTransport transport = oprot.getTransport();
            final Trace trace = traceContext.currentRawTraceObject();
            if (trace == null) {
                return;
            }

            final boolean shouldSample = trace.canSampled();
            if (!shouldSample) {
                if (transport instanceof THttpClient) {
                    return;
                }
                ThriftRequestProperty parentTraceInfo = new ThriftRequestProperty();
                if (isDebug) {
                    logger.debug("set Sampling flag=false");
                }
                parentTraceInfo.setShouldSample(false);
                InterceptorScopeInvocation currentTransaction = this.scope.getCurrentInvocation();
                currentTransaction.setAttachment(parentTraceInfo);
                return;
            }

            SpanEventRecorder recorder = trace.traceBlockBegin();
            String remoteAddress = ThriftConstants.UNKNOWN_ADDRESS;

            // If we're writing to THttpClient, http client plugin will handle trace propagation.
            // We simply record as basic method.
            if (transport instanceof THttpClient) {
                recorder.recordServiceType(ThriftConstants.THRIFT_CLIENT_INTERNAL);
                remoteAddress = getRemoteAddressForTHttpClient((THttpClient) transport);
            } else {
                recorder.recordServiceType(ThriftConstants.THRIFT_CLIENT);
                remoteAddress = getRemoteAddress(transport);
                recorder.recordDestinationId(remoteAddress);

                TraceId nextId = trace.getTraceId().getNextTraceId();
                recorder.recordNextSpanId(nextId.getSpanId());

                ThriftRequestProperty parentTraceInfo = new ThriftRequestProperty();
                parentTraceInfo.setTraceId(nextId.getTransactionId());
                parentTraceInfo.setSpanId(nextId.getSpanId());
                parentTraceInfo.setParentSpanId(nextId.getParentSpanId());

                parentTraceInfo.setFlags(nextId.getFlags());
                parentTraceInfo.setParentApplicationName(traceContext.getApplicationName());
                parentTraceInfo.setParentApplicationType(traceContext.getServerTypeCode());
                parentTraceInfo.setAcceptorHost(remoteAddress);

                InterceptorScopeInvocation currentTransaction = this.scope.getCurrentInvocation();
                currentTransaction.setAttachment(parentTraceInfo);

            }

            String methodName = ThriftConstants.UNKNOWN_METHOD_NAME;
            if (args[0] instanceof String) {
                methodName = (String)args[0];
            }
            String serviceName = ThriftUtils.getClientServiceName(client);
            String thriftUrl = getServiceUrl(remoteAddress, serviceName, methodName);
            recorder.recordAttribute(ThriftConstants.THRIFT_URL, thriftUrl);
        }
    }
Starting point for tracing synchronous client calls for Thrift services.
<p>
Note that in order to trace remote agents, trace data must be sent to them. These data are serialized as Thrift fields and attached to the body of the Thrift
message by other interceptors down the chain.
<p>
<b><tt>TServiceClientSendBaseInterceptor</tt></b> -> <tt>TProtocolWriteFieldStopInterceptor</tt>
<p>
Based on Thrift 0.8.0+

@author HyunGil Jeong

@see com.navercorp.pinpoint.plugin.thrift.interceptor.tprotocol.client.TProtocolWriteFieldStopInterceptor TProtocolWriteFieldStopInterceptor
agent-module/plugins/thrift/src/main/java/com/navercorp/pinpoint/plugin/thrift/interceptor/client/TServiceClientSendBaseInterceptor.java