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