Search in sources :

Example 26 with SofaTraceContext

use of com.alipay.common.tracer.core.context.trace.SofaTraceContext in project sofa-boot by sofastack.

the class ZipkinSofaTracerSpanRemoteReporterTest method mockRemoteCall.

public void mockRemoteCall() throws Exception {
    SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext();
    SofaTracerSpan originSofaTracerSpan = sofaTraceContext.getCurrentSpan();
    SofaTracerSpanContext spanContext = originSofaTracerSpan.getSofaTracerSpanContext();
    sofaTraceContext.clear();
    // sr
    SofaTracerSpan srSpan = this.remoteTracer.serverReceive(spanContext);
    srSpan.setOperationName("ServerReceive1");
    assertEquals(srSpan, sofaTraceContext.getCurrentSpan());
    // ss
    this.remoteTracer.serverSend("0");
    assertTrue(sofaTraceContext.getThreadLocalSpanSize() == 0);
    // mock restore
    sofaTraceContext.push(originSofaTracerSpan);
}
Also used : SofaTracerSpan(com.alipay.common.tracer.core.span.SofaTracerSpan) SofaTraceContext(com.alipay.common.tracer.core.context.trace.SofaTraceContext) SofaTracerSpanContext(com.alipay.common.tracer.core.context.span.SofaTracerSpanContext)

Aggregations

SofaTraceContext (com.alipay.common.tracer.core.context.trace.SofaTraceContext)26 SofaTracerSpan (com.alipay.common.tracer.core.span.SofaTracerSpan)25 RpcInternalContext (com.alipay.sofa.rpc.context.RpcInternalContext)13 Test (org.junit.Test)7 SofaTracerSpanContext (com.alipay.common.tracer.core.context.span.SofaTracerSpanContext)6 HashMap (java.util.HashMap)6 RpcInvokeContext (com.alipay.sofa.rpc.context.RpcInvokeContext)4 SofaRequest (com.alipay.sofa.rpc.core.request.SofaRequest)3 ProviderInfo (com.alipay.sofa.rpc.client.ProviderInfo)2 SofaRpcException (com.alipay.sofa.rpc.core.exception.SofaRpcException)2 SofaResponse (com.alipay.sofa.rpc.core.response.SofaResponse)2 InetSocketAddress (java.net.InetSocketAddress)2 ProviderConfig (com.alipay.sofa.rpc.config.ProviderConfig)1 RpcRuntimeContext (com.alipay.sofa.rpc.context.RpcRuntimeContext)1 ServerReceiveEvent (com.alipay.sofa.rpc.event.ServerReceiveEvent)1 SofaResourceFactory (com.alipay.sofa.rpc.server.rest.SofaResourceFactory)1 SofaResourceMethodInvoker (com.alipay.sofa.rpc.server.rest.SofaResourceMethodInvoker)1 Context (io.grpc.Context)1 ForwardingServerCall (io.grpc.ForwardingServerCall)1 ForwardingServerCallListener (io.grpc.ForwardingServerCallListener)1