use of zipkin.Span in project zipkin by openzipkin.
the class JsonCodecTest method binaryAnnotation_double.
@Test
public void binaryAnnotation_double() {
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 = Codec.JSON.readSpan(json.getBytes(UTF_8));
assertThat(span.binaryAnnotations).containsExactly(BinaryAnnotation.builder().key("num").type(BinaryAnnotation.Type.DOUBLE).value(toBytes(Double.doubleToRawLongBits(1.23456789))).build());
assertThat(Codec.JSON.readSpan(Codec.JSON.writeSpan(span))).isEqualTo(span);
}
use of zipkin.Span in project zipkin by openzipkin.
the class JsonCodecTest method sizeInBytes_span.
@Test
public void sizeInBytes_span() throws IOException {
Span span = TestObjects.LOTS_OF_SPANS[0];
assertThat(JsonCodec.SPAN_ADAPTER.sizeInBytes(span)).isEqualTo(codec().writeSpan(span).length);
}
use of zipkin.Span in project zipkin by openzipkin.
the class JsonCodecTest method endpointHighPort.
@Test
public void endpointHighPort() {
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" + " }\n" + " }\n" + " ]\n" + "}";
Span span = Codec.JSON.readSpan(json.getBytes(UTF_8));
assertThat(span.binaryAnnotations).containsExactly(BinaryAnnotation.create("foo", "bar", Endpoint.builder().serviceName("service").port(65535).build()));
assertThat(Codec.JSON.readSpan(Codec.JSON.writeSpan(span))).isEqualTo(span);
}
use of zipkin.Span in project zipkin by openzipkin.
the class CorrectForClockSkewTest method getClockSkew_includesSplitTheLatency.
/**
* Skew is relative to the server receive and centered by the difference between the server
* duration and the client duration.
*/
@Test
public void getClockSkew_includesSplitTheLatency() {
Span span = Span.builder().traceId(1L).parentId(2L).id(3L).name("").addAnnotation(Annotation.create(20, CLIENT_SEND, WEB_ENDPOINT)).addAnnotation(Annotation.create(10, /* skew */
SERVER_RECV, APP_ENDPOINT)).addAnnotation(Annotation.create(20, SERVER_SEND, APP_ENDPOINT)).addAnnotation(Annotation.create(40, CLIENT_RECV, WEB_ENDPOINT)).build();
assertThat(getClockSkew(span).skew).isEqualTo(-15);
}
use of zipkin.Span in project zipkin by openzipkin.
the class CorrectForClockSkewTest method getClockSkew_mustBeOnDifferentHosts.
/**
* Instrumentation bugs might result in spans that look like clock skew is at play. When skew
* appears on the same host, we assume it is an instrumentation bug (rather than make it worse
* by adjusting it!)
*/
@Test
public void getClockSkew_mustBeOnDifferentHosts() {
Span span = Span.builder().traceId(1L).parentId(2L).id(3L).name("").addAnnotation(Annotation.create(20, CLIENT_SEND, WEB_ENDPOINT)).addAnnotation(Annotation.create(10, /* skew */
SERVER_RECV, WEB_ENDPOINT)).addAnnotation(Annotation.create(20, SERVER_SEND, WEB_ENDPOINT)).addAnnotation(Annotation.create(40, CLIENT_RECV, WEB_ENDPOINT)).build();
assertThat(getClockSkew(span)).isNull();
}
Aggregations