Search in sources :

Example 96 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class CorrectForClockSkewTest method clockSkewIsPropagatedToLocalSpans.

@Test
public void clockSkewIsPropagatedToLocalSpans() {
    long networkLatency = 10L;
    Span rootSpan = createRootSpan(WEB_ENDPOINT, now, 2000L);
    long skew = -50000L;
    Span rpcSpan = childSpan(rootSpan, APP_ENDPOINT, now + networkLatency, 1000L, skew);
    Span local = localSpan(rpcSpan, APP_ENDPOINT, rpcSpan.timestamp + 5, 200L);
    Span local2 = localSpan(local, APP_ENDPOINT, local.timestamp + 10, 100L);
    List<Span> adjustedSpans = CorrectForClockSkew.apply(asList(rpcSpan, rootSpan, local, local2));
    Span adjustedLocal = getById(adjustedSpans, local.id);
    assertThat(local.timestamp - skew).isEqualTo(adjustedLocal.timestamp.longValue());
    Span adjustedLocal2 = getById(adjustedSpans, local2.id);
    assertThat(local2.timestamp - skew).isEqualTo(adjustedLocal2.timestamp.longValue());
}
Also used : CorrectForClockSkew.isLocalSpan(zipkin.internal.CorrectForClockSkew.isLocalSpan) Span(zipkin.Span) Test(org.junit.Test)

Example 97 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class CorrectForClockSkewTest method getClockSkew_onlyWhenClientDurationIsLongerThanServer.

/** We can't currently correct async spans, where the server lets go early. */
@Test
public void getClockSkew_onlyWhenClientDurationIsLongerThanServer() {
    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(25, CLIENT_RECV, WEB_ENDPOINT)).build();
    assertThat(getClockSkew(span)).isNull();
}
Also used : CorrectForClockSkew.isLocalSpan(zipkin.internal.CorrectForClockSkew.isLocalSpan) Span(zipkin.Span) Test(org.junit.Test)

Example 98 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class CorrectForClockSkewTest method assertClockSkewIsCorrectlyApplied.

static void assertClockSkewIsCorrectlyApplied(long skew) {
    long rpcClientSendTs = now + 50L;
    long dbClientSendTimestamp = now + 60 + skew;
    long rootDuration = 350L;
    long rpcDuration = 250L;
    long dbDuration = 40L;
    Span rootSpan = createRootSpan(WEB_ENDPOINT, now, rootDuration);
    Span rpcSpan = childSpan(rootSpan, APP_ENDPOINT, rpcClientSendTs, rpcDuration, skew);
    Span tierSpan = childSpan(rpcSpan, DB_ENDPOINT, dbClientSendTimestamp, dbDuration, skew);
    List<Span> adjustedSpans = CorrectForClockSkew.apply(asList(rpcSpan, rootSpan, tierSpan));
    long id = rpcSpan.id;
    Span adjustedRpcSpan = getById(adjustedSpans, id);
    assertThat(annotationTimestamps(adjustedRpcSpan, Constants.SERVER_RECV)).containsExactly(rpcClientSendTs + networkLatency);
    assertThat(annotationTimestamps(adjustedRpcSpan, Constants.CLIENT_SEND)).containsExactly(adjustedRpcSpan.timestamp);
    Span adjustedTierSpan = getById(adjustedSpans, tierSpan.id);
    assertThat(annotationTimestamps(adjustedTierSpan, Constants.CLIENT_SEND)).containsExactly(adjustedTierSpan.timestamp);
}
Also used : CorrectForClockSkew.isLocalSpan(zipkin.internal.CorrectForClockSkew.isLocalSpan) Span(zipkin.Span)

Example 99 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class CorrectForClockSkewTest method getClockSkew_basedOnServer.

@Test
public void getClockSkew_basedOnServer() {
    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).endpoint).isEqualTo(APP_ENDPOINT);
}
Also used : CorrectForClockSkew.isLocalSpan(zipkin.internal.CorrectForClockSkew.isLocalSpan) Span(zipkin.Span) Test(org.junit.Test)

Example 100 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class SpanStoreTest method getTraces_binaryAnnotationWithEmptyValue.

/** Make sure empty binary annotation values don't crash */
@Test
public void getTraces_binaryAnnotationWithEmptyValue() {
    Span span = Span.builder().traceId(1).name("call1").id(1).timestamp((today + 1) * 1000).addBinaryAnnotation(BinaryAnnotation.create("empty", "", ep)).build();
    accept(span);
    assertThat(store().getTraces((QueryRequest.builder().serviceName("service").build()))).containsExactly(asList(span));
    assertThat(store().getTrace(span.traceIdHigh, span.traceId)).containsExactly(span);
}
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