use of zipkin.Span in project zipkin by openzipkin.
the class CassandraSpanConsumerTest method dontLogTimestampMissingOnMidTierServerSpan.
@Test
public void dontLogTimestampMissingOnMidTierServerSpan() {
Span span = TestObjects.TRACE.get(0);
accept(span);
verify(mockAppender, never()).doAppend(considerSwitchStrategyLog());
}
use of zipkin.Span in project zipkin by openzipkin.
the class CassandraSpanConsumerTest method doesntIndexCoreOrNonStringAnnotations.
/**
* Core/Boundary annotations like "sr" aren't queryable, and don't add value to users. Address
* annotations, like "sa", don't have string values, so are similarly not queryable. Skipping
* indexing of such annotations dramatically reduces the load on cassandra and size of indexes.
*/
@Test
public void doesntIndexCoreOrNonStringAnnotations() {
Span span = TestObjects.TRACE.get(1);
assertThat(span.annotations).extracting(a -> a.value).matches(Constants.CORE_ANNOTATIONS::containsAll);
assertThat(span.binaryAnnotations).extracting(b -> b.key).containsOnly(Constants.SERVER_ADDR, Constants.CLIENT_ADDR);
accept(span);
assertThat(rowCount(Tables.ANNOTATIONS_INDEX)).isZero();
}
use of zipkin.Span in project zipkin by openzipkin.
the class ZipkinRuleTest method readSpans_gzippedResponse.
@Test
public void readSpans_gzippedResponse() throws Exception {
char[] annotation2K = new char[2048];
Arrays.fill(annotation2K, 'a');
List<Span> trace = asList(TRACE.get(0).toBuilder().addAnnotation(Annotation.create(System.currentTimeMillis(), new String(annotation2K), null)).build());
zipkin.storeSpans(trace);
Response response = client.newCall(new Request.Builder().url(format("%s/api/v1/trace/%016x", zipkin.httpUrl(), traceId)).addHeader("Accept-Encoding", "gzip").build()).execute();
assertThat(response.code()).isEqualTo(200);
assertThat(response.body().contentLength()).isLessThan(annotation2K.length);
Buffer result = new Buffer();
GzipSource source = new GzipSource(response.body().source());
while (source.read(result, Integer.MAX_VALUE) != -1) ;
byte[] unzipped = result.readByteArray();
assertThat(Codec.JSON.readSpans(unzipped)).isEqualTo(trace);
}
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[0]));
// Index ends up containing more rows than services * trace count, and cannot be de-duped
// in a server-side query.
assertThat(rowCount(Tables.SERVICE_NAME_INDEX)).isGreaterThan(traceCount * store().getServiceNames().size());
// Implementation over-fetches on the index to allow the user to receive unsurprising results.
assertThat(store().getTraces(QueryRequest.builder().limit(traceCount).build())).hasSize(traceCount);
}
use of zipkin.Span in project zipkin by openzipkin.
the class CassandraSpanStoreTest method rawTraceStoredWithoutAdjustments.
/** Cassandra indexing is performed separately, allowing the raw span to be stored unaltered. */
@Test
public void rawTraceStoredWithoutAdjustments() {
Span rawSpan = TestObjects.TRACE.get(0).toBuilder().timestamp(null).duration(null).build();
accept(rawSpan);
// At query time, timestamp and duration are added.
assertThat(store().getTrace(rawSpan.traceIdHigh, rawSpan.traceId)).containsExactly(ApplyTimestampAndDuration.apply(rawSpan));
// Unlike other stores, Cassandra can show that timestamp and duration weren't reported
assertThat(store().getRawTrace(rawSpan.traceIdHigh, rawSpan.traceId)).containsExactly(rawSpan);
}
Aggregations