Search in sources :

Example 51 with Span

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));
}
Also used : Span(zipkin.Span) Test(org.junit.Test)

Example 52 with 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);
}
Also used : Span(zipkin.Span) Test(org.junit.Test)

Example 53 with Span

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);
}
Also used : Span(zipkin.Span) Test(org.junit.Test)

Example 54 with Span

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);
}
Also used : Span(zipkin.Span) Test(org.junit.Test)

Example 55 with Span

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