use of zipkin.Span in project zipkin by openzipkin.
the class ElasticsearchHttpSpanConsumerTest method spanGoesIntoADailyIndex_whenTimestampIsDerived.
@Test
public void spanGoesIntoADailyIndex_whenTimestampIsDerived() throws Exception {
long twoDaysAgo = (TODAY - 2 * DAY);
Span span = Span.builder().traceId(20L).id(20L).name("get").addAnnotation(Annotation.create(twoDaysAgo * 1000, SERVER_RECV, WEB_ENDPOINT)).addAnnotation(Annotation.create(TODAY * 1000, SERVER_SEND, WEB_ENDPOINT)).build();
accept(span);
// make sure the span went into an index corresponding to its first annotation timestamp
assertThat(findSpans(twoDaysAgo, span.traceId)).contains("\"hits\":{\"total\":1");
}
use of zipkin.Span in project zipkin by openzipkin.
the class CassandraSpanConsumerTest method skipsRedundantIndexingInATrace.
/**
* Simulates a trace with a step pattern, where each span starts a millisecond after the prior
* one. The consumer code optimizes index inserts to only represent the interval represented by
* the trace as opposed to each individual timestamp.
*/
@Test
public void skipsRedundantIndexingInATrace() {
Span[] trace = new Span[101];
trace[0] = TestObjects.TRACE.get(0);
IntStream.range(0, 100).forEach(i -> {
Span s = TestObjects.TRACE.get(1);
trace[i + 1] = s.toBuilder().id(s.id + i).timestamp(s.timestamp + i * 1000).annotations(s.annotations.stream().map(a -> Annotation.create(a.timestamp + i * 1000, a.value, a.endpoint)).collect(toList())).build();
});
accept(trace);
assertThat(rowCount(Schema.TABLE_TRACE_BY_SERVICE_SPAN)).isGreaterThanOrEqualTo(4L);
assertThat(rowCount(Schema.TABLE_TRACE_BY_SERVICE_SPAN)).isGreaterThanOrEqualTo(4L);
// sanity check base case
clear();
CassandraSpanConsumer withoutOptimization = new CassandraSpanConsumer(storage.session(), false);
Futures.getUnchecked(withoutOptimization.accept(ImmutableList.copyOf(trace)));
assertThat(rowCount(Schema.TABLE_TRACE_BY_SERVICE_SPAN)).isGreaterThanOrEqualTo(201L);
assertThat(rowCount(Schema.TABLE_TRACE_BY_SERVICE_SPAN)).isGreaterThanOrEqualTo(201L);
}
use of zipkin.Span in project zipkin by openzipkin.
the class CassandraSpanConsumerTest method logTimestampMissingOnClientSend.
@Test
public void logTimestampMissingOnClientSend() {
Span span = Span.builder().traceId(1L).parentId(1L).id(2L).name("query").addAnnotation(Annotation.create(0L, CLIENT_SEND, APP_ENDPOINT)).addAnnotation(Annotation.create(0L, CLIENT_RECV, APP_ENDPOINT)).build();
accept(span);
verify(mockAppender).doAppend(considerSwitchStrategyLog());
}
use of zipkin.Span in project zipkin by openzipkin.
the class CassandraSpanStoreTest method overFetchesToCompensateForDuplicateIndexData.
@Test
public void overFetchesToCompensateForDuplicateIndexData() {
int traceCount = 100;
List<Span> spans = new ArrayList<>();
for (int i = 0; i < traceCount; i++) {
// all timestamps happen a millisecond later
final long delta = i * 1000;
for (Span s : TestObjects.TRACE) {
spans.add(TestObjects.TRACE.get(0).toBuilder().traceId(s.traceId + i * 10).id(s.id + i * 10).timestamp(s.timestamp + delta).annotations(s.annotations.stream().map(a -> Annotation.create(a.timestamp + delta, a.value, a.endpoint)).collect(toList())).build());
}
}
accept(spans.toArray(new Span[spans.size()]));
// Index ends up containing more rows than services * trace count, and cannot be de-duped
// in a server-side query.
assertThat(rowCount(Schema.TABLE_TRACE_BY_SERVICE_SPAN)).isGreaterThan(traceCount * store().getServiceNames().size());
// Implementation over-fetches on the index to allow the user to receive unsurprising results.
assertThat(store().getTraces(QueryRequest.builder().lookback(86400000L).limit(traceCount).build())).hasSize(traceCount);
}
use of zipkin.Span in project zipkin by openzipkin.
the class CassandraUtilTest method annotationKeys_skipsBinaryAnnotationsLongerThan256chars.
@Test
public void annotationKeys_skipsBinaryAnnotationsLongerThan256chars() throws Exception {
// example long value
String arn = "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012";
// example too long value
String url = "http://webservices.amazon.com/onca/xml?AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE&AssociateTag=mytag-20&ItemId=0679722769&Operation=ItemLookup&ResponseGroup=Images%2CItemAttributes%2COffers%2CReviews&Service=AWSECommerceService&Timestamp=2014-08-18T12%3A00%3A00Z&Version=2013-08-01&Signature=j7bZM0LXZ9eXeZruTqWm2DIvDYVUU3wxPPpp%2BiXxzQc%3D";
Span span = TestObjects.TRACE.get(1).toBuilder().binaryAnnotations(ImmutableList.of(BinaryAnnotation.create("aws.arn", arn, TestObjects.WEB_ENDPOINT), BinaryAnnotation.create(TraceKeys.HTTP_URL, url, TestObjects.WEB_ENDPOINT))).build();
assertThat(CassandraUtil.annotationKeys(span)).containsOnly("web;aws.arn;" + arn);
}
Aggregations