Search in sources :

Example 6 with AggregateCall

use of zipkin2.internal.AggregateCall in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method serviceSpanKeys.

@Test
public void serviceSpanKeys() {
    Span span = spanWithoutAnnotationsOrTags;
    AggregateCall<?, Void> call = (AggregateCall<?, Void>) consumer.accept(singletonList(span));
    assertThat(call.delegate()).filteredOn(c -> c instanceof InsertEntry).extracting("input").containsExactly(entry(FRONTEND.serviceName(), span.name()));
}
Also used : AggregateCall(zipkin2.internal.AggregateCall) InsertEntry(zipkin2.storage.cassandra.internal.call.InsertEntry) Span(zipkin2.Span) Test(org.junit.Test)

Example 7 with AggregateCall

use of zipkin2.internal.AggregateCall in project zipkin by openzipkin.

the class ITSpanConsumer method insertEntry_niceToString.

/**
 * It is easier to use a real Cassandra connection than mock a prepared statement.
 */
@Test
public void insertEntry_niceToString() {
    // This test can use fake data as it is never written to cassandra
    Span clientSpan = CLIENT_SPAN;
    AggregateCall<?, ?> acceptCall = (AggregateCall<?, ?>) storage.spanConsumer().accept(asList(clientSpan));
    List<Call<?>> insertEntryCalls = acceptCall.delegate().stream().filter(c -> c instanceof InsertEntry).collect(Collectors.toList());
    assertThat(insertEntryCalls.get(0)).hasToString("INSERT INTO span_by_service (service, span) VALUES (frontend,get)");
    assertThat(insertEntryCalls.get(1)).hasToString("INSERT INTO remote_service_by_service (service, remote_service) VALUES (frontend,backend)");
}
Also used : AggregateCall(zipkin2.internal.AggregateCall) IntStream(java.util.stream.IntStream) TestObjects.spanBuilder(zipkin2.TestObjects.spanBuilder) TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) AggregateCall(zipkin2.internal.AggregateCall) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Span(zipkin2.Span) InsertEntry(zipkin2.storage.cassandra.internal.call.InsertEntry) CLIENT_SPAN(zipkin2.TestObjects.CLIENT_SPAN) Collectors(java.util.stream.Collectors) TestInfo(org.junit.jupiter.api.TestInfo) Test(org.junit.jupiter.api.Test) List(java.util.List) Arrays.asList(java.util.Arrays.asList) SERVER(zipkin2.Span.Kind.SERVER) StorageComponent(zipkin2.storage.StorageComponent) Call(zipkin2.Call) ITStorage(zipkin2.storage.ITStorage) AggregateCall(zipkin2.internal.AggregateCall) Call(zipkin2.Call) InsertEntry(zipkin2.storage.cassandra.internal.call.InsertEntry) TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 8 with AggregateCall

use of zipkin2.internal.AggregateCall in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method traceByServiceSpan_indexesDurationInMillis.

@Test
public void traceByServiceSpan_indexesDurationInMillis() {
    Span span = spanWithoutAnnotationsOrTags;
    AggregateCall<?, Void> call = (AggregateCall<?, Void>) consumer.accept(singletonList(span));
    assertThat(call.delegate()).filteredOn(c -> c instanceof InsertTraceByServiceSpan).extracting("input.duration").containsOnly(span.durationAsLong() / 1000L);
}
Also used : AggregateCall(zipkin2.internal.AggregateCall) Span(zipkin2.Span) Test(org.junit.Test)

Example 9 with AggregateCall

use of zipkin2.internal.AggregateCall in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method doesntSetTraceIdHigh_64.

@Test
public void doesntSetTraceIdHigh_64() {
    Span span = spanWithoutAnnotationsOrTags;
    AggregateCall<?, Void> call = (AggregateCall<?, Void>) consumer.accept(singletonList(span));
    assertThat(call.delegate()).filteredOn(c -> c instanceof InsertSpan).extracting("input.trace_id_high", "input.trace_id").containsExactly(tuple(null, span.traceId()));
}
Also used : AggregateCall(zipkin2.internal.AggregateCall) Span(zipkin2.Span) Test(org.junit.Test)

Example 10 with AggregateCall

use of zipkin2.internal.AggregateCall in project zipkin by openzipkin.

the class CassandraSpanConsumerTest method traceByServiceSpan_appendsEmptyWhenNoName.

@Test
public void traceByServiceSpan_appendsEmptyWhenNoName() {
    Span span = spanWithoutAnnotationsOrTags.toBuilder().name(null).build();
    AggregateCall<?, Void> call = (AggregateCall<?, Void>) consumer.accept(singletonList(span));
    assertThat(call.delegate()).filteredOn(c -> c instanceof InsertTraceByServiceSpan).extracting("input.service", "input.span").containsExactly(tuple(FRONTEND.serviceName(), ""));
}
Also used : AggregateCall(zipkin2.internal.AggregateCall) Span(zipkin2.Span) Test(org.junit.Test)

Aggregations

Span (zipkin2.Span)12 AggregateCall (zipkin2.internal.AggregateCall)12 Test (org.junit.Test)11 InsertEntry (zipkin2.storage.cassandra.internal.call.InsertEntry)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Call (zipkin2.Call)2 Arrays.asList (java.util.Arrays.asList)1 Collections (java.util.Collections)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Assertions.entry (org.assertj.core.api.Assertions.entry)1 Assertions.tuple (org.assertj.core.api.Assertions.tuple)1 Test (org.junit.jupiter.api.Test)1 TestInfo (org.junit.jupiter.api.TestInfo)1 SERVER (zipkin2.Span.Kind.SERVER)1 BACKEND (zipkin2.TestObjects.BACKEND)1 CLIENT_SPAN (zipkin2.TestObjects.CLIENT_SPAN)1 FRONTEND (zipkin2.TestObjects.FRONTEND)1