Search in sources :

Example 76 with Span

use of zipkin2.proto3.Span in project zipkin by openzipkin.

the class BulkIndexWriterTest method spanSearchFields_addsQueryFieldForTags.

@Test
public void spanSearchFields_addsQueryFieldForTags() {
    Span span = Span.newBuilder().traceId("20").id("22").parentId("21").localEndpoint(FRONTEND).putTag("\"foo", "\"bar").build();
    BulkIndexWriter.SPAN.writeDocument(span, buffer);
    assertThat(buffer.buffer().toString(StandardCharsets.UTF_8)).startsWith("{\"_q\":[\"\\\"foo\",\"\\\"foo=\\\"bar\"],\"traceId");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 77 with Span

use of zipkin2.proto3.Span in project zipkin by openzipkin.

the class BulkIndexWriterTest method spanSearchFields_readableByNormalJsonCodec.

@Test
public void spanSearchFields_readableByNormalJsonCodec() {
    Span span = Span.newBuilder().traceId("20").id("20").name("get").timestamp(TODAY * 1000).build();
    BulkIndexWriter.SPAN.writeDocument(span, buffer);
    assertThat(SpanBytesDecoder.JSON_V2.decodeOne(ByteBufUtil.getBytes(buffer.buffer()))).isEqualTo(// ignores timestamp_millis field
    span);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 78 with Span

use of zipkin2.proto3.Span in project zipkin by openzipkin.

the class BulkIndexWriterTest method spanSearchFields_addsQueryFieldForAnnotations.

@Test
public void spanSearchFields_addsQueryFieldForAnnotations() {
    Span span = Span.newBuilder().traceId("20").id("22").name("").parentId("21").localEndpoint(FRONTEND).addAnnotation(1L, "\"foo").build();
    BulkIndexWriter.SPAN.writeDocument(span, buffer);
    assertThat(buffer.buffer().toString(StandardCharsets.UTF_8)).startsWith("{\"_q\":[\"\\\"foo\"],\"traceId");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 79 with Span

use of zipkin2.proto3.Span 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 80 with Span

use of zipkin2.proto3.Span in project zipkin by openzipkin.

the class TraceTest method cleanupComparator_transitiveKindComparison.

/**
 * Comparators are meant to be transitive. This exploits edge cases to fool our comparator.
 */
@Test
public void cleanupComparator_transitiveKindComparison() {
    List<Span> trace = new ArrayList<>();
    Endpoint aEndpoint = Endpoint.newBuilder().serviceName("a").build();
    Endpoint bEndpoint = Endpoint.newBuilder().serviceName("b").build();
    Span template = Span.newBuilder().traceId("a").id("a").build();
    // when there are at least 32 elements.
    for (int i = 0, length = 7; i < length; i++) {
        trace.add(template.toBuilder().shared(true).localEndpoint(bEndpoint).build());
        trace.add(template.toBuilder().kind(Kind.CLIENT).localEndpoint(bEndpoint).build());
        trace.add(template.toBuilder().localEndpoint(aEndpoint).build());
        trace.add(template);
        trace.add(template.toBuilder().kind(Kind.CLIENT).localEndpoint(aEndpoint).build());
    }
    Collections.sort(trace, Trace.CLEANUP_COMPARATOR);
    assertThat(new LinkedHashSet<>(trace)).extracting(Span::shared, Span::kind, s -> s.localServiceName()).containsExactly(tuple(null, Kind.CLIENT, "a"), tuple(null, Kind.CLIENT, "b"), tuple(null, null, null), tuple(null, null, "a"), tuple(true, null, "b"));
}
Also used : List(java.util.List) Endpoint(zipkin2.Endpoint) Assertions.tuple(org.assertj.core.api.Assertions.tuple) Arrays.asList(java.util.Arrays.asList) Kind(zipkin2.Span.Kind) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Span(zipkin2.Span) Test(org.junit.Test) Collections(java.util.Collections) LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) Endpoint(zipkin2.Endpoint) ArrayList(java.util.ArrayList) Span(zipkin2.Span) Endpoint(zipkin2.Endpoint) Test(org.junit.Test)

Aggregations

Span (zipkin2.Span)290 Test (org.junit.Test)203 Test (org.junit.jupiter.api.Test)69 Endpoint (zipkin2.Endpoint)62 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)41 ArrayList (java.util.ArrayList)29 V1Span (zipkin2.v1.V1Span)23 List (java.util.List)19 Map (java.util.Map)18 Annotation (zipkin2.Annotation)13 AggregateCall (zipkin2.internal.AggregateCall)13 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)12 IOException (java.io.IOException)10 LinkedHashMap (java.util.LinkedHashMap)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 Arrays.asList (java.util.Arrays.asList)9 Span (com.google.devtools.cloudtrace.v2.Span)8 Trace (com.google.devtools.cloudtrace.v1.Trace)7 Call (zipkin2.Call)7 Span (zipkin2.proto3.Span)7