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());
}
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);
}
}
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());
}
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");
}
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");
}
Aggregations