use of com.alipay.common.tracer.core.context.trace.SofaTraceContext in project sofa-boot by sofastack.
the class ZipkinSofaTracerSpanRemoteReporterTest method testDoReport.
/**
* Method: doReport(SofaTracerSpan span)
*/
@Test
public void testDoReport() throws Exception {
SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext();
// sr TL
SofaTracerSpan sofaTracerServerSpan = this.remoteTracer.serverReceive();
sofaTracerServerSpan.setOperationName("ServerReveive0");
// assert
assertEquals(sofaTracerServerSpan, sofaTraceContext.getCurrentSpan());
// cs
SofaTracerSpan clientSpan = this.remoteTracer.clientSend("ClientSend0");
// assert
assertEquals(clientSpan, sofaTraceContext.getCurrentSpan());
// mock sync remote call
this.mockRemoteCall();
// cr
this.remoteTracer.clientReceive("0");
assertEquals(sofaTracerServerSpan, sofaTraceContext.getCurrentSpan());
// ss TL
this.remoteTracer.serverSend("0");
// 异步汇报,所以 sleep 1s
Thread.sleep(1000);
// assert
assertTrue(sofaTraceContext.isEmpty());
}
use of com.alipay.common.tracer.core.context.trace.SofaTraceContext in project sofa-boot by alipay.
the class ZipkinSofaTracerSpanRemoteReporterTest method testDoServerReport.
@Test
public void testDoServerReport() throws Exception {
// sr TL
SofaTracerSpan sofaTracerServerSpan = this.remoteTracer.serverReceive();
sofaTracerServerSpan.setOperationName("mockOperationName");
// ss TL
this.remoteTracer.serverSend("0");
// 异步汇报,所以 sleep 1s
Thread.sleep(1000);
// assert
SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext();
assertTrue(sofaTraceContext.isEmpty());
}
use of com.alipay.common.tracer.core.context.trace.SofaTraceContext in project sofa-boot by alipay.
the class ZipkinSofaTracerSpanRemoteReporterTest method testDoReport.
/**
* Method: doReport(SofaTracerSpan span)
*/
@Test
public void testDoReport() throws Exception {
SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext();
// sr TL
SofaTracerSpan sofaTracerServerSpan = this.remoteTracer.serverReceive();
sofaTracerServerSpan.setOperationName("ServerReveive0");
// assert
assertEquals(sofaTracerServerSpan, sofaTraceContext.getCurrentSpan());
// cs
SofaTracerSpan clientSpan = this.remoteTracer.clientSend("ClientSend0");
// assert
assertEquals(clientSpan, sofaTraceContext.getCurrentSpan());
// mock sync remote call
this.mockRemoteCall();
// cr
this.remoteTracer.clientReceive("0");
assertEquals(sofaTracerServerSpan, sofaTraceContext.getCurrentSpan());
// ss TL
this.remoteTracer.serverSend("0");
// 异步汇报,所以 sleep 1s
Thread.sleep(1000);
// assert
assertTrue(sofaTraceContext.isEmpty());
}
use of com.alipay.common.tracer.core.context.trace.SofaTraceContext in project sofa-boot by alipay.
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);
}
use of com.alipay.common.tracer.core.context.trace.SofaTraceContext in project sofa-boot by alipay.
the class ZipkinSofaTracerSpanRemoteReporterTest method testDoClientReport.
@Test
public void testDoClientReport() throws Exception {
SofaTraceContext sofaTraceContext = SofaTraceContextHolder.getSofaTraceContext();
sofaTraceContext.clear();
// cs
SofaTracerSpan clientSpan = this.remoteTracer.clientSend("testDoClientReport");
assertTrue(clientSpan != null);
// cr
this.remoteTracer.clientReceive("0");
// assert
assertTrue(sofaTraceContext.isEmpty());
}
Aggregations