Skip to content

Project brave-instrumentation-dubbo miss fresh spanId and parentSpanId in Dubbo 2.7 #1454

@xiaoduanayu

Description

@xiaoduanayu

Describe the Bug

I have three dubbo project, to make it simple, their names are A, B and C. A is a consumer, B is both a provider and a consumer, and C is a provider, so the call chain is like this:
A-->B-->C

when I start a request, it pass through the whole chain, after finishing the request, I find the trace info in last project(i.e. project C) is error, the following trace info indicates the error:
A
kind CLIENT: traceId:70d0 spanId:9340 parentId:70d0
B
kind SERVER: traceId:70d0 spanId:9340 parentId:70d0
kind CLIENT: traceId:70d0 spanId:4211 parentId:9340
C
kind SERVER: traceId:70d0 spanId:9340 parentId:70d0

there is an obvious error in this trace info, the info of C kind SERVER should be spanId:4211 parentId:9340

The cause of the Bug

Perhaps this code in org.apache.dubbo.rpc.protocol.AbstractInvoker line 160 causes the error, the code context as follows:

        Map<String, Object> contextAttachments = RpcContext.getContext().getObjectAttachments();
        if (CollectionUtils.isNotEmptyMap(contextAttachments)) {
            invocation.addObjectAttachments(contextAttachments);
        }

this code indicates that before B makes an invocation to C, trace info in Invocation object is fresh, but it is old in RpcContext, and this code replace fresh trace info with old one! so the error happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions