use of zipkin.Span in project zipkin by openzipkin.
the class SpanStoreTest method whenSpanTimestampIsMissingClientSendIsPreferred.
/**
* Spans report depth-first. Make sure the client timestamp is preferred when instrumentation
* don't add a timestamp.
*/
@Test
public void whenSpanTimestampIsMissingClientSendIsPreferred() {
Endpoint frontend = Endpoint.create("frontend", 192 << 24 | 168 << 16 | 2);
Annotation cs = Annotation.create((today + 50) * 1000, CLIENT_SEND, frontend);
Annotation cr = Annotation.create((today + 150) * 1000, CLIENT_RECV, frontend);
Endpoint backend = Endpoint.create("backend", 192 << 24 | 168 << 16 | 2);
Annotation sr = Annotation.create((today + 95) * 1000, SERVER_RECV, backend);
Annotation ss = Annotation.create((today + 100) * 1000, SERVER_SEND, backend);
Span span = Span.builder().traceId(1).name("method1").id(666).build();
// Simulate the server-side of a shared span arriving first
accept(span.toBuilder().addAnnotation(sr).addAnnotation(ss).build());
accept(span.toBuilder().addAnnotation(cs).addAnnotation(cr).build());
// Make sure that the client's timestamp won
assertThat(store().getTrace(span1.traceIdHigh, span.traceId)).containsExactly(span.toBuilder().timestamp(cs.timestamp).duration(cr.timestamp - cs.timestamp).annotations(asList(cs, sr, ss, cr)).build());
}
use of zipkin.Span in project zipkin by openzipkin.
the class JsonCodecTest method binaryAnnotation_long.
@Test
public void binaryAnnotation_long() {
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 = Codec.JSON.readSpan(json.getBytes(UTF_8));
assertThat(span.binaryAnnotations).containsExactly(BinaryAnnotation.builder().key("num").type(BinaryAnnotation.Type.I64).value(toBytes(123456789)).build());
assertThat(Codec.JSON.readSpan(Codec.JSON.writeSpan(span))).isEqualTo(span);
}
use of zipkin.Span in project zipkin by openzipkin.
the class JsonCodecTest method writesTraceIdHighIntoTraceIdField.
@Test
public void writesTraceIdHighIntoTraceIdField() {
Span with128BitTraceId = Span.builder().traceIdHigh(Util.lowerHexToUnsignedLong("48485a3953bb6124")).traceId(Util.lowerHexToUnsignedLong("6b221d5bc9e6496c")).id(1).name("").build();
assertThat(new String(Codec.JSON.writeSpan(with128BitTraceId), Util.UTF_8)).startsWith("{\"traceId\":\"48485a3953bb61246b221d5bc9e6496c\"");
}
use of zipkin.Span in project zipkin by openzipkin.
the class ThriftCodecTest method sizeInBytes_span.
@Test
public void sizeInBytes_span() throws IOException {
Span span = TestObjects.LOTS_OF_SPANS[0];
assertThat(ThriftCodec.SPAN_ADAPTER.sizeInBytes(span)).isEqualTo(codec().writeSpan(span).length);
}
use of zipkin.Span in project zipkin by openzipkin.
the class ThriftCodecTest method readSpanFromByteBuffer.
@Test
public void readSpanFromByteBuffer() throws IOException {
for (Span span : TestObjects.TRACE) {
byte[] bytes = codec().writeSpan(span);
assertThat(codec().readSpan(ByteBuffer.wrap(bytes))).isEqualTo(span);
}
}
Aggregations