Search in sources :

Example 66 with Span

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

the class ElasticsearchSpanConsumerTest method addsTimestamp_millisIntoJson.

@Test
void addsTimestamp_millisIntoJson() throws Exception {
    server.enqueue(SUCCESS_RESPONSE);
    Span span = Span.newBuilder().traceId("20").id("20").name("get").timestamp(TODAY * 1000).build();
    accept(span);
    assertThat(server.takeRequest().request().contentUtf8()).contains("\n{\"timestamp_millis\":" + TODAY + ",\"traceId\":");
}
Also used : Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 67 with Span

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

the class ElasticsearchSpanConsumerTest method traceIsSearchableByServerServiceName.

@Test
void traceIsSearchableByServerServiceName() throws Exception {
    server.enqueue(SUCCESS_RESPONSE);
    Span clientSpan = Span.newBuilder().traceId("20").id("22").name("").parentId("21").timestamp(1000L).kind(Kind.CLIENT).localEndpoint(WEB_ENDPOINT).build();
    Span serverSpan = Span.newBuilder().traceId("20").id("22").name("get").parentId("21").timestamp(2000L).kind(Kind.SERVER).localEndpoint(APP_ENDPOINT).build();
    accept(serverSpan, clientSpan);
    // make sure that both timestamps are in the index
    assertThat(server.takeRequest().request().contentUtf8()).contains("{\"timestamp_millis\":2").contains("{\"timestamp_millis\":1");
}
Also used : Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 68 with Span

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

the class ElasticsearchSpanConsumerTest method choosesTypeSpecificIndex.

@Test
void choosesTypeSpecificIndex() throws Exception {
    server.enqueue(SUCCESS_RESPONSE);
    Span span = Span.newBuilder().traceId("1").id("2").parentId("1").name("s").localEndpoint(APP_ENDPOINT).addAnnotation(TimeUnit.DAYS.toMicros(365), /* 1971-01-01 */
    "foo").build();
    // sanity check data
    assertThat(span.timestamp()).isNull();
    accept(span);
    // index timestamp is the server timestamp, not current time!
    assertThat(server.takeRequest().request().contentUtf8()).startsWith("{\"index\":{\"_index\":\"zipkin:span-1971-01-01\",\"_type\":\"span\"");
}
Also used : Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 69 with Span

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

the class ElasticsearchSpanConsumerTest method addsAutocompleteValue_revertsSuppressionOnFailure.

@Test
void addsAutocompleteValue_revertsSuppressionOnFailure() throws Exception {
    server.enqueue(AggregatedHttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR));
    server.enqueue(SUCCESS_RESPONSE);
    Span s = Span.newBuilder().traceId("1").id("1").timestamp(1).putTag("environment", "A").build();
    try {
        accept(s);
        failBecauseExceptionWasNotThrown(RuntimeException.class);
    } catch (RuntimeException expected) {
    }
    accept(s);
    // We only cache when there was no error.. the second request should be same as the first
    assertThat(server.takeRequest().request().contentUtf8()).isEqualTo(server.takeRequest().request().contentUtf8());
}
Also used : Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 70 with Span

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

the class ElasticsearchSpanConsumerTest method writesSpanNaturallyWhenNoTimestamp.

@Test
void writesSpanNaturallyWhenNoTimestamp() throws Exception {
    server.enqueue(SUCCESS_RESPONSE);
    Span span = Span.newBuilder().traceId("1").id("1").name("foo").build();
    accept(Span.newBuilder().traceId("1").id("1").name("foo").build());
    assertThat(server.takeRequest().request().contentUtf8()).contains("\n" + new String(SpanBytesEncoder.JSON_V2.encode(span), UTF_8) + "\n");
}
Also used : Span(zipkin2.Span) Test(org.junit.jupiter.api.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