Search in sources :

Example 61 with Span

use of com.google.devtools.cloudtrace.v2.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 62 with Span

use of com.google.devtools.cloudtrace.v2.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 63 with Span

use of com.google.devtools.cloudtrace.v2.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)

Example 64 with Span

use of com.google.devtools.cloudtrace.v2.Span in project zipkin by openzipkin.

the class JsonSerializersTest method span_specialCharsInJson.

/**
 * This isn't a test of what we "should" accept as a span, rather that characters that trip-up
 * json don't fail in SPAN_PARSER.
 */
@Test
public void span_specialCharsInJson() {
    // service name is surrounded by control characters
    Endpoint e = Endpoint.newBuilder().serviceName(new String(new char[] { 0, 'a', 1 })).build();
    Span worstSpanInTheWorld = Span.newBuilder().traceId("1").id("1").name(new String(new char[] { '"', '\\', '\t', '\b', '\n', '\r', '\f' })).localEndpoint(e).addAnnotation(1L, "\u2028 and \u2029").putTag("\"foo", "Database error: ORA-00942:\u2028 and \u2029 table or view does not exist\n").build();
    assertThat(parse(SPAN_PARSER, new String(SpanBytesEncoder.JSON_V2.encode(worstSpanInTheWorld), UTF_8))).isEqualTo(worstSpanInTheWorld);
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) Test(org.junit.Test)

Example 65 with Span

use of com.google.devtools.cloudtrace.v2.Span in project zipkin by openzipkin.

the class JsonSerializersTest method span_tag_double_read.

@Test
public void span_tag_double_read() {
    String json = "{\n" + "  \"traceId\": \"6b221d5bc9e6496c\",\n" + "  \"name\": \"get-traces\",\n" + "  \"id\": \"6b221d5bc9e6496c\",\n" + "  \"tags\": {" + "      \"num\": 1.23456789" + "  }" + "}";
    Span span = parse(SPAN_PARSER, json);
    assertThat(span.tags()).containsExactly(entry("num", "1.23456789"));
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Aggregations

Span (zipkin2.Span)290 Test (org.junit.Test)192 Test (org.junit.jupiter.api.Test)67 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)41 Endpoint (zipkin2.Endpoint)37 ArrayList (java.util.ArrayList)24 V1Span (zipkin2.v1.V1Span)17 List (java.util.List)14 AggregateCall (zipkin2.internal.AggregateCall)13 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)12 Arrays.asList (java.util.Arrays.asList)9 Map (java.util.Map)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 Span (com.google.devtools.cloudtrace.v2.Span)8 LinkedHashMap (java.util.LinkedHashMap)8 Trace (com.google.devtools.cloudtrace.v1.Trace)7 Span (zipkin2.proto3.Span)7 SpanData (io.opencensus.trace.export.SpanData)6 SpanCustomizer (brave.SpanCustomizer)5 IOException (java.io.IOException)5