use of zipkin2.Span.Kind in project zipkin by openzipkin.
the class TraceTest method cleanupComparator_transitiveKindComparison.
/**
* Comparators are meant to be transitive. This exploits edge cases to fool our comparator.
*/
@Test
public void cleanupComparator_transitiveKindComparison() {
List<Span> trace = new ArrayList<>();
Endpoint aEndpoint = Endpoint.newBuilder().serviceName("a").build();
Endpoint bEndpoint = Endpoint.newBuilder().serviceName("b").build();
Span template = Span.newBuilder().traceId("a").id("a").build();
// when there are at least 32 elements.
for (int i = 0, length = 7; i < length; i++) {
trace.add(template.toBuilder().shared(true).localEndpoint(bEndpoint).build());
trace.add(template.toBuilder().kind(Kind.CLIENT).localEndpoint(bEndpoint).build());
trace.add(template.toBuilder().localEndpoint(aEndpoint).build());
trace.add(template);
trace.add(template.toBuilder().kind(Kind.CLIENT).localEndpoint(aEndpoint).build());
}
Collections.sort(trace, Trace.CLEANUP_COMPARATOR);
assertThat(new LinkedHashSet<>(trace)).extracting(Span::shared, Span::kind, s -> s.localServiceName()).containsExactly(tuple(null, Kind.CLIENT, "a"), tuple(null, Kind.CLIENT, "b"), tuple(null, null, null), tuple(null, null, "a"), tuple(true, null, "b"));
}
use of zipkin2.Span.Kind in project zipkin by openzipkin.
the class InMemoryStorageTest method replayOverwrites.
/**
* It should be safe to run dependency link jobs twice
*/
@Test
public void replayOverwrites() throws IOException {
Span span = Span.newBuilder().traceId("10").id("10").name("receive").kind(Span.Kind.CONSUMER).localEndpoint(Endpoint.newBuilder().serviceName("app").build()).remoteEndpoint(Endpoint.newBuilder().serviceName("kafka").build()).timestamp(TODAY * 1000).build();
storage.accept(asList(span)).execute();
storage.accept(asList(span)).execute();
assertThat(storage.getDependencies(TODAY + 1000L, TODAY).execute()).containsOnly(DependencyLink.newBuilder().parent("kafka").child("app").callCount(1L).build());
}
use of zipkin2.Span.Kind in project zipkin by openzipkin.
the class SpanConverterTest method lateRemoteEndpoint_ss.
/**
* Late flushed data on a v2 span
*/
@Test
public void lateRemoteEndpoint_ss() {
Span v2 = Span.newBuilder().traceId("1").id("2").name("get").kind(Kind.SERVER).localEndpoint(BACKEND).remoteEndpoint(FRONTEND).addAnnotation(1472470996199000L, "ss").build();
V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).name("get").addAnnotation(1472470996199000L, "ss", BACKEND).addBinaryAnnotation("ca", FRONTEND).build();
assertThat(v2SpanConverter.convert(v2)).usingRecursiveComparison().isEqualTo(v1);
assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
use of zipkin2.Span.Kind in project zipkin by openzipkin.
the class SpanConverterTest method server_incomplete_shared.
@Test
public void server_incomplete_shared() {
Span v2 = Span.newBuilder().traceId("1").parentId('2').id("3").name("get").kind(Kind.SERVER).shared(true).localEndpoint(BACKEND).timestamp(1472470996199000L).build();
V1Span v1 = V1Span.newBuilder().traceId("1").parentId('2').id("3").name("get").addAnnotation(1472470996199000L, "sr", BACKEND).build();
assertThat(v2SpanConverter.convert(v2)).usingRecursiveComparison().isEqualTo(v1);
assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
use of zipkin2.Span.Kind in project zipkin by openzipkin.
the class SpanConverterTest method clientAndServer.
@Test
public void clientAndServer() {
V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996199000L, "cs", FRONTEND).addAnnotation(1472470996238000L, "ws", FRONTEND).addAnnotation(1472470996250000L, "sr", BACKEND).addAnnotation(1472470996350000L, "ss", BACKEND).addAnnotation(1472470996403000L, "wr", FRONTEND).addAnnotation(1472470996406000L, "cr", FRONTEND).addBinaryAnnotation("http.path", "/api", FRONTEND).addBinaryAnnotation("http.path", "/BACKEND", BACKEND).addBinaryAnnotation("clnt/finagle.version", "6.45.0", FRONTEND).addBinaryAnnotation("srv/finagle.version", "6.44.0", BACKEND).addBinaryAnnotation("ca", FRONTEND).addBinaryAnnotation("sa", BACKEND).build();
Span.Builder newBuilder = Span.newBuilder().traceId("1").parentId("2").id("3").name("get");
// the v1 side owns timestamp and duration
Span clientV2 = newBuilder.clone().kind(Kind.CLIENT).localEndpoint(FRONTEND).remoteEndpoint(BACKEND).timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996238000L, "ws").addAnnotation(1472470996403000L, "wr").putTag("http.path", "/api").putTag("clnt/finagle.version", "6.45.0").build();
// notice v1 tags are different than the v1, and the v1's annotations aren't here
Span serverV2 = newBuilder.clone().kind(Kind.SERVER).shared(true).localEndpoint(BACKEND).remoteEndpoint(FRONTEND).timestamp(1472470996250000L).duration(100000L).putTag("http.path", "/BACKEND").putTag("srv/finagle.version", "6.44.0").build();
assertThat(v1SpanConverter.convert(v1)).containsExactly(clientV2, serverV2);
}
Aggregations