Search in sources :

Example 36 with Span

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));
}
Also used : Span(zipkin.Span) Test(org.junit.Test)

Example 37 with Span

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));
}
Also used : Span(zipkin.Span) Test(org.junit.Test)

Example 38 with Span

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();
}
Also used : DependencyLinker(zipkin.internal.DependencyLinker) Span(zipkin.Span)

Example 39 with Span

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);
}
Also used : Span(zipkin.Span) CodecTest(zipkin.CodecTest) Test(org.junit.Test)

Example 40 with Span

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);
}
Also used : Span(zipkin.Span) CodecTest(zipkin.CodecTest) Test(org.junit.Test)

Aggregations

Span (zipkin.Span)104 Test (org.junit.Test)84 Endpoint (zipkin.Endpoint)21 BinaryAnnotation (zipkin.BinaryAnnotation)12 ArrayList (java.util.ArrayList)11 Annotation (zipkin.Annotation)10 CodecTest (zipkin.CodecTest)9 CorrectForClockSkew.isLocalSpan (zipkin.internal.CorrectForClockSkew.isLocalSpan)9 ByteBuffer (java.nio.ByteBuffer)8 List (java.util.List)8 Buffer (okio.Buffer)8 LinkedHashMap (java.util.LinkedHashMap)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 ImmutableList (com.google.common.collect.ImmutableList)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 LinkedList (java.util.LinkedList)4 Constants (zipkin.Constants)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 IOException (java.io.IOException)3 Arrays.asList (java.util.Arrays.asList)3