StackdriverTraceSpanListenerTests.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:spring-cloud-gcp 作者:
@Test
public void testSingleClientRemoteSpan() {
    Span parent = Span.builder()
            .traceId(123L)
            .name("http:call")
            .begin(beginTime - 1)
            .end(endTime + 1)
            .log(new Log(beginTime, Span.CLIENT_SEND))
            .log(new Log(endTime, Span.CLIENT_RECV))
            .remote(true)
            .build();

    this.spanListener.report(parent);

    Assert.assertEquals(1, this.test.traceSpans.size());
    TraceSpan traceSpan = this.test.traceSpans.get(0);
    Assert.assertEquals("http:call", traceSpan.getName());
    // Client span chould use CS and CR time, not Span begin or end time.
    Assert.assertEquals(Timestamp.getDefaultInstance(), traceSpan.getStartTime());
    Assert.assertEquals(Timestamp.getDefaultInstance(), traceSpan.getEndTime());
    Assert.assertEquals(this.dateFormatter.format(new Date(beginTime)),
            traceSpan.getLabelsOrThrow("cloud.spring.io/cs"));
    Assert.assertEquals(this.dateFormatter.format(new Date(endTime)),
            traceSpan.getLabelsOrThrow("cloud.spring.io/cr"));
    Assert.assertEquals(TraceSpan.SpanKind.RPC_CLIENT, traceSpan.getKind());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号