use of com.google.devtools.cloudtrace.v1.TraceSpan in project zipkin-gcp by openzipkin.
the class TraceTranslatorTest method testSinglehostClientRootSpan.
@Test
public void testSinglehostClientRootSpan() {
Span span1 = Span.newBuilder().traceId("1").id("1").name("/a?client").timestamp(// This is set because the client owns the span
1474488796000000L).duration(5000000L).build();
Span span2 = Span.newBuilder().traceId("1").parentId("1").id("2").name("/a?server").timestamp(1474488796000000L).duration(5000000L).build();
Span span3 = Span.newBuilder().traceId("1").parentId("2").id("3").name("/b?client").timestamp(// This is set because the client owns the span.
1474488797000000L).duration(1500000L).build();
Span span4 = Span.newBuilder().traceId("1").parentId("3").id("4").name("/b?server").timestamp(1474488797500000L).duration(800000L).build();
Span span5 = Span.newBuilder().traceId("1").parentId("4").id("5").name("custom-span").timestamp(1474488797600000L).duration(200000L).build();
Collection<Trace> traces = TraceTranslator.translateSpans("test-project", Arrays.asList(span1, span2, span3, span4, span5));
assertEquals(1, traces.size());
Trace trace = traces.iterator().next();
Map<String, TraceSpan> spansByName = getSpansByName(trace);
assertThat(spansByName).containsOnlyKeys("/a?client", "/a?server", "/b?client", "/b?server", "custom-span");
assertDistinctSpanIds(trace);
assertThat(spansByName.get("custom-span").getParentSpanId()).isEqualTo(spansByName.get("/b?server").getSpanId());
assertThat(spansByName.get("/b?server").getParentSpanId()).isEqualTo(spansByName.get("/b?client").getSpanId());
assertThat(spansByName.get("/b?client").getParentSpanId()).isEqualTo(spansByName.get("/a?server").getSpanId());
assertThat(spansByName.get("/a?server").getParentSpanId()).isEqualTo(spansByName.get("/a?client").getSpanId());
assertThat(spansByName.get("/a?client").getParentSpanId()).isEqualTo(0);
}
use of com.google.devtools.cloudtrace.v1.TraceSpan in project zipkin-gcp by openzipkin.
the class TraceTranslatorTest method testMultihostClientRootSpan.
@Test
public void testMultihostClientRootSpan() {
Span span1 = Span.newBuilder().kind(Kind.CLIENT).traceId("1").id("1").name("/a?client").timestamp(// This is set because the client owns the span
1474488796000000L).duration(5000000L).build();
Span span2 = Span.newBuilder().kind(Kind.SERVER).shared(true).traceId("1").id("1").name("/a?server").build();
Span span3 = Span.newBuilder().kind(Kind.CLIENT).traceId("1").parentId("1").id("2").name("/b?client").timestamp(// This is set because the client owns the span.
1474488797000000L).duration(1500000L).build();
Span span4 = Span.newBuilder().kind(Kind.SERVER).shared(true).traceId("1").parentId("1").id("2").name("/b?server").build();
Span span5 = Span.newBuilder().traceId("1").parentId("2").id("3").name("custom-span").timestamp(1474488797600000L).duration(200000L).build();
Collection<Trace> traces = TraceTranslator.translateSpans("test-project", Arrays.asList(span1, span2, span3, span4, span5));
assertEquals(1, traces.size());
Trace trace = traces.iterator().next();
Map<String, TraceSpan> spansByName = getSpansByName(trace);
assertThat(spansByName).containsOnlyKeys("/a?client", "/a?server", "/b?client", "/b?server", "custom-span");
assertDistinctSpanIds(trace);
assertThat(spansByName.get("custom-span").getParentSpanId()).isEqualTo(spansByName.get("/b?server").getSpanId());
assertThat(spansByName.get("/b?server").getParentSpanId()).isEqualTo(spansByName.get("/b?client").getSpanId());
assertThat(spansByName.get("/b?client").getParentSpanId()).isEqualTo(spansByName.get("/a?server").getSpanId());
assertThat(spansByName.get("/a?server").getParentSpanId()).isEqualTo(spansByName.get("/a?client").getSpanId());
assertThat(spansByName.get("/a?client").getParentSpanId()).isEqualTo(0);
}
use of com.google.devtools.cloudtrace.v1.TraceSpan in project zipkin-gcp by openzipkin.
the class TracesParser method nextSpan.
@Override
public void nextSpan(byte[] traceIdPrefixedSpan) {
TraceSpan traceSpan = parseTraceIdPrefixedSpan(traceIdPrefixedSpan);
currentTrace.addSpans(traceSpan);
}
use of com.google.devtools.cloudtrace.v1.TraceSpan in project spring-cloud-gcp by spring-cloud.
the class StackdriverTraceReporter method report.
@Override
public void report(Span span) {
TraceSpan traceSpan = this.spanTranslator.translate(span);
Traces traces = Traces.newBuilder().addTraces(Trace.newBuilder().setTraceId(padTraceId(span.traceId())).setProjectId(this.projectId).addSpans(traceSpan).build()).build();
this.traceConsumer.receive(traces);
}
use of com.google.devtools.cloudtrace.v1.TraceSpan in project spring-cloud-gcp by spring-cloud.
the class StackdriverTraceReporterTests method testSingleServerSpan.
@Test
public void testSingleServerSpan() {
Span parent = Span.newBuilder().traceId("123").id("9999").name("http:parent").timestamp(beginTime).duration(endTime - beginTime).kind(Span.Kind.SERVER).build();
this.reporter.report(parent);
Assert.assertEquals(1, this.test.traceSpans.size());
TraceSpan traceSpan = this.test.traceSpans.get(0);
Assert.assertEquals("http:parent", traceSpan.getName());
// Server Spans should use Span begin and end time, not SR or SS
Assert.assertEquals(this.spanTranslator.createTimestamp(beginTime), traceSpan.getStartTime());
Assert.assertEquals(this.spanTranslator.createTimestamp(endTime), traceSpan.getEndTime());
Assert.assertEquals(TraceSpan.SpanKind.RPC_SERVER, traceSpan.getKind());
}
Aggregations