dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

apache-dubbo2.7+later conflict with pinpoint

Open feixueck opened this issue 6 years ago • 2 comments

when a dubbo call chain like : a->b->c ,pinpoint will lose data. when i checked the dubbo code ,i found the change between 2.5+ and 2.7+ in the class : org.apache.dubbo.rpc.protocol.AbstractInvoker

public abstract class AbstractInvoker<T> implements Invoker<T> {
//....
@Override
    public Result invoke(Invocation inv) throws RpcException {
        // if invoker is destroyed due to address refresh from registry, let's allow the current invoke to proceed
        if (destroyed.get()) {
            logger.warn("Invoker for service " + this + " on consumer " + NetUtils.getLocalHost() + " is destroyed, "
                    + ", dubbo version is " + Version.getVersion() + ", this invoker should not be used any longer");
        }
        RpcInvocation invocation = (RpcInvocation) inv;
        invocation.setInvoker(this);
        if (CollectionUtils.isNotEmptyMap(attachment)) {
            invocation.addAttachmentsIfAbsent(attachment);
        }
        Map<String, String> contextAttachments = RpcContext.getContext().getAttachments();
        if (CollectionUtils.isNotEmptyMap(contextAttachments)) {
            /**
             * invocation.addAttachmentsIfAbsent(context){@link RpcInvocation#addAttachmentsIfAbsent(Map)}should not be used here,
             * because the {@link RpcContext#setAttachment(String, String)} is passed in the Filter when the call is triggered
             * by the built-in retry mechanism of the Dubbo. The attachment to update RpcContext will no longer work, which is
             * a mistake in most cases (for example, through Filter to RpcContext output traceId and spanId and other information).
             */
            //<1>
            invocation.addAttachments(contextAttachments);
        }
//................

notice <1>: when 2.5+ the code is :addAttachmentsIfAbsent ,when 2.7+ is addAttachments so ,when the call chain from a->b->c ,the pinpoint span data will be override by this add operation in b interface. the pinpoint only can show a->b ,and c with it's later call is lost. // is therer any solutions?

feixueck avatar Jul 08 '20 11:07 feixueck

让我告诉为什么,某次commiter为了简单解决问题,在某一次改动中改了,详情见#5908

CodeIngL avatar Jul 10 '20 03:07 CodeIngL

原来如此.感谢

feixueck avatar Jul 10 '20 05:07 feixueck