use of zipkin.Span in project zipkin by openzipkin.
the class SpanStoreTest method getTraces_128BitTraceId.
/** This tests that the 128bit trace id is read back from storage. */
@Test
public void getTraces_128BitTraceId() {
Span span = span1.toBuilder().traceIdHigh(1).build();
accept(span);
assertThat(store().getTraces(QueryRequest.builder().build())).containsExactly(asList(span));
}
use of zipkin.Span in project zipkin by openzipkin.
the class ElasticsearchSpanConsumerTest method spanGoesIntoADailyIndex_whenTimestampIsExplicit.
@Test
public void spanGoesIntoADailyIndex_whenTimestampIsExplicit() throws Exception {
long twoDaysAgo = (TODAY - 2 * DAY);
Span span = Span.builder().traceId(20L).id(20L).name("get").timestamp(twoDaysAgo * 1000).build();
accept(span);
List<Span> indexFromTwoDaysAgo = storage().client().findSpans(new String[] { storage().indexNameFormatter.indexNameForTimestamp(twoDaysAgo) }, matchAllQuery()).get();
// make sure the span went into an index corresponding to its timestamp, not collection time
assertThat(indexFromTwoDaysAgo.size()).isEqualTo(1);
}
use of zipkin.Span in project zipkin by openzipkin.
the class ElasticsearchSpanConsumerTest 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);
List<Span> indexFromTwoDaysAgo = storage().client().findSpans(new String[] { storage().indexNameFormatter.indexNameForTimestamp(twoDaysAgo) }, matchAllQuery()).get();
// make sure the span went into an index corresponding to its first annotation timestamp
assertThat(indexFromTwoDaysAgo.size()).isEqualTo(1);
}
use of zipkin.Span in project zipkin by openzipkin.
the class ElasticsearchSpanConsumerTest method spanGoesIntoADailyIndex_fallsBackToTodayWhenNoTimestamps.
@Test
public void spanGoesIntoADailyIndex_fallsBackToTodayWhenNoTimestamps() throws Exception {
Span span = Span.builder().traceId(20L).id(20L).name("get").build();
accept(span);
List<Span> indexFromToday = storage().client().findSpans(new String[] { storage().indexNameFormatter.indexNameForTimestamp(TODAY) }, matchAllQuery()).get();
// make sure the span went into an index corresponding to collection time
assertThat(indexFromToday.size()).isEqualTo(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(Tables.SERVICE_SPAN_NAME_INDEX)).isEqualTo(4L);
assertThat(rowCount(Tables.SERVICE_NAME_INDEX)).isEqualTo(4L);
// sanity check base case
clear();
CassandraSpanConsumer withoutOptimization = new CassandraSpanConsumer(storage.session(), storage.bucketCount, storage.spanTtl, storage.indexTtl, null);
Futures.getUnchecked(withoutOptimization.accept(ImmutableList.copyOf(trace)));
assertThat(rowCount(Tables.SERVICE_SPAN_NAME_INDEX)).isEqualTo(201L);
assertThat(rowCount(Tables.SERVICE_NAME_INDEX)).isEqualTo(201L);
}
Aggregations