Search in sources :

Example 66 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class JsonAdaptersTest method binaryAnnotation_double_read.

@Test
public void binaryAnnotation_double_read() throws IOException {
    String json = "{\n" + "  \"traceId\": \"6b221d5bc9e6496c\",\n" + "  \"name\": \"get-traces\",\n" + "  \"id\": \"6b221d5bc9e6496c\",\n" + "  \"binaryAnnotations\": [\n" + "    {\n" + "      \"key\": \"num\",\n" + "      \"value\": 1.23456789,\n" + "      \"type\": \"DOUBLE\"\n" + "    }\n" + "  ]\n" + "}";
    Span span = SPAN_ADAPTER.fromJson(new Buffer().writeUtf8(json));
    assertThat(span.binaryAnnotations).containsExactly(BinaryAnnotation.builder().key("num").type(BinaryAnnotation.Type.DOUBLE).value(new Buffer().writeLong(Double.doubleToRawLongBits(1.23456789)).readByteArray()).build());
}
Also used : Buffer(okio.Buffer) ByteBuffer(java.nio.ByteBuffer) Span(zipkin.Span) Test(org.junit.Test)

Example 67 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class JsonAdaptersTest method spanRoundTrip.

@Test
public void spanRoundTrip() throws IOException {
    for (Span span : TestObjects.TRACE) {
        Buffer bytes = new Buffer();
        bytes.write(Codec.JSON.writeSpan(span));
        assertThat(SPAN_ADAPTER.fromJson(bytes)).isEqualTo(span);
    }
}
Also used : Buffer(okio.Buffer) ByteBuffer(java.nio.ByteBuffer) Span(zipkin.Span) Test(org.junit.Test)

Example 68 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class JsonAdaptersTest method binaryAnnotation_long_read.

@Test
public void binaryAnnotation_long_read() throws IOException {
    String json = "{\n" + "  \"traceId\": \"6b221d5bc9e6496c\",\n" + "  \"name\": \"get-traces\",\n" + "  \"id\": \"6b221d5bc9e6496c\",\n" + "  \"binaryAnnotations\": [\n" + "    {\n" + "      \"key\": \"num\",\n" + "      \"value\": 123456789,\n" + "      \"type\": \"I64\"\n" + "    }\n" + "  ]\n" + "}";
    Span span = SPAN_ADAPTER.fromJson(new Buffer().writeUtf8(json));
    assertThat(span.binaryAnnotations).containsExactly(BinaryAnnotation.builder().key("num").type(BinaryAnnotation.Type.I64).value(new Buffer().writeLong(123456789).readByteArray()).build());
}
Also used : Buffer(okio.Buffer) ByteBuffer(java.nio.ByteBuffer) Span(zipkin.Span) Test(org.junit.Test)

Example 69 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class ElasticsearchHttpSpanConsumerTest method searchByTimestampMillis.

@Test
public void searchByTimestampMillis() throws Exception {
    Span span = Span.builder().timestamp(TODAY * 1000).traceId(20L).id(20L).name("get").build();
    accept(span);
    Call searchRequest = new OkHttpClient().newCall(new Request.Builder().url(HttpUrl.parse(baseUrl()).newBuilder().addPathSegment(INDEX + "-*").addPathSegment("span").addPathSegment("_search").addQueryParameter("q", "timestamp_millis:" + TODAY).build()).get().tag("search-terms").build());
    assertThat(searchRequest.execute().body().string()).contains("\"hits\":{\"total\":1");
}
Also used : Call(okhttp3.Call) OkHttpClient(okhttp3.OkHttpClient) Request(okhttp3.Request) Span(zipkin.Span) Test(org.junit.Test)

Example 70 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class ElasticsearchHttpSpanConsumerTest method spanGoesIntoADailyIndex_whenTimestampIsExplicit.

@Test
public void spanGoesIntoADailyIndex_whenTimestampIsExplicit() throws Exception {
    long twoDaysAgo = (TODAY - 2 * DAY);
    Span span = Span.builder().traceId(20L).id(20L).name("get").timestamp(twoDaysAgo * 1000).build();
    accept(span);
    // make sure the span went into an index corresponding to its timestamp, not collection time
    assertThat(findSpans(twoDaysAgo, span.traceId)).contains("\"hits\":{\"total\":1");
}
Also used : Span(zipkin.Span) 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