Search in sources :

Example 11 with Span

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

Example 12 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method doesntIndexSpansMissingDuration.

/**
   * {@link Span#duration} == 0 is likely to be a mistake, and coerces to null. It is not helpful to
   * index rows who have no duration.
   */
@Test
public void doesntIndexSpansMissingDuration() {
    Span span = Span.builder().traceId(1L).id(1L).name("get").duration(0L).build();
    accept(span);
    assertThat(rowCount(Schema.TABLE_TRACE_BY_SERVICE_SPAN)).isZero();
}
Also used : Span(zipkin.Span) Test(org.junit.Test)

Example 13 with Span

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

Example 14 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class CassandraUtilTest method annotationKeys_skipsCoreAndAddressAnnotations.

@Test
public void annotationKeys_skipsCoreAndAddressAnnotations() throws Exception {
    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);
    assertThat(CassandraUtil.annotationKeys(span)).isEmpty();
}
Also used : TraceKeys(zipkin.TraceKeys) Rule(org.junit.Rule) ImmutableList(com.google.common.collect.ImmutableList) Span(zipkin.Span) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Constants(zipkin.Constants) QueryRequest(zipkin.storage.QueryRequest) Test(org.junit.Test) BinaryAnnotation(zipkin.BinaryAnnotation) TestObjects(zipkin.TestObjects) ExpectedException(org.junit.rules.ExpectedException) Span(zipkin.Span) Test(org.junit.Test)

Example 15 with Span

use of zipkin.Span in project zipkin by openzipkin.

the class ElasticsearchSpanConsumer method indexSpans.

BulkSpanIndexer indexSpans(BulkSpanIndexer indexer, List<Span> spans) throws IOException {
    for (Span span : spans) {
        Long timestamp = guessTimestamp(span);
        Long timestampMillis;
        // which index to store this span into
        String index;
        if (timestamp != null) {
            timestampMillis = TimeUnit.MICROSECONDS.toMillis(timestamp);
            index = indexNameFormatter.indexNameForTimestamp(timestampMillis);
        } else {
            timestampMillis = null;
            index = indexNameFormatter.indexNameForTimestamp(System.currentTimeMillis());
        }
        indexer.add(index, span, timestampMillis);
    }
    return indexer;
}
Also used : Span(zipkin.Span)

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