Search in sources :

Example 41 with Span

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

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

Example 43 with Span

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

Example 44 with 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);
}
Also used : CorrectForClockSkew.isLocalSpan(zipkin.internal.CorrectForClockSkew.isLocalSpan) Span(zipkin.Span) Test(org.junit.Test)

Example 45 with Span

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