use of zipkin.Span in project zipkin by openzipkin.
the class SpanStoreTest method traceWithManySpans.
// Bugs have happened in the past where trace limit was mistaken for span count.
@Test
public void traceWithManySpans() {
Span[] trace = new Span[101];
trace[0] = TestObjects.TRACE.get(0);
IntStream.range(0, 100).forEach(i -> {
Span s = TestObjects.TRACE.get(1);
trace[i + 1] = s.toBuilder().id(s.id + i).timestamp(s.timestamp + i).annotations(s.annotations.stream().map(a -> Annotation.create(a.timestamp + i, a.value, a.endpoint)).collect(toList())).build();
});
accept(trace);
String serviceName = trace[1].annotations.get(0).endpoint.serviceName;
assertThat(store().getTraces(QueryRequest.builder().serviceName(serviceName).build())).containsExactly(asList(trace));
assertThat(store().getTrace(trace[0].traceIdHigh, trace[0].traceId)).containsExactly(trace);
assertThat(store().getRawTrace(trace[0].traceIdHigh, trace[0].traceId)).containsAll(// order isn't guaranteed in raw trace
asList(trace));
}
use of zipkin.Span in project zipkin by openzipkin.
the class SpanStoreTest method getTraces_serviceNameInBinaryAnnotation.
@Test
public void getTraces_serviceNameInBinaryAnnotation() {
Span localTrace = Span.builder().traceId(1L).name("targz").id(1L).timestamp(today * 1000 + 100L).duration(200L).addBinaryAnnotation(BinaryAnnotation.create(LOCAL_COMPONENT, "archiver", ep)).build();
accept(localTrace);
assertThat(store().getTraces(QueryRequest.builder().serviceName("service").build())).containsExactly(asList(localTrace));
}
use of zipkin.Span in project zipkin by openzipkin.
the class InMemorySpanStore method getDependencies.
@Override
public List<DependencyLink> getDependencies(long endTs, @Nullable Long lookback) {
QueryRequest request = QueryRequest.builder().endTs(endTs).lookback(lookback).limit(Integer.MAX_VALUE).build();
DependencyLinker linksBuilder = new DependencyLinker();
for (Collection<Span> trace : getTraces(request)) {
linksBuilder.putTrace(trace);
}
return linksBuilder.link();
}
use of zipkin.Span in project zipkin by openzipkin.
the class JsonCodecTest method binaryAnnotation_long_max.
@Test
public void binaryAnnotation_long_max() {
String json = ("{" + " \"traceId\": \"6b221d5bc9e6496c\"," + " \"id\": \"6b221d5bc9e6496c\"," + " \"name\": \"get-traces\"," + " \"binaryAnnotations\": [" + " {" + " \"key\": \"num\"," + " \"value\": \"9223372036854775807\"," + " \"type\": \"I64\"" + " }" + " ]" + "}").replaceAll("\\s", "");
Span span = Codec.JSON.readSpan(json.getBytes(UTF_8));
assertThat(new String(Codec.JSON.writeSpan(span), UTF_8)).isEqualTo(json);
}
use of zipkin.Span in project zipkin by openzipkin.
the class JsonCodecTest method mappedIPv6toIPv4.
@Test
public void mappedIPv6toIPv4() {
String json = "{\n" + " \"traceId\": \"6b221d5bc9e6496c\",\n" + " \"name\": \"get-traces\",\n" + " \"id\": \"6b221d5bc9e6496c\",\n" + " \"binaryAnnotations\": [\n" + " {\n" + " \"key\": \"foo\",\n" + " \"value\": \"bar\",\n" + " \"endpoint\": {\n" + " \"serviceName\": \"service\",\n" + " \"port\": 65535,\n" + " \"ipv6\": \"::ffff:192.0.2.128\"\n" + " }\n" + " }\n" + " ]\n" + "}";
Span span = Codec.JSON.readSpan(json.getBytes(UTF_8));
assertThat(span.binaryAnnotations.get(0).endpoint.ipv6).isNull();
assertThat(span.binaryAnnotations.get(0).endpoint.ipv4).isEqualTo(// 192.0.2.128
(192 << 24) | (0 << 16) | (2 << 8) | 128);
}
Aggregations