Search in sources :

Example 1 with UTF_8

use of zipkin2.TestObjects.UTF_8 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 2 with UTF_8

use of zipkin2.TestObjects.UTF_8 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 3 with UTF_8

use of zipkin2.TestObjects.UTF_8 in project zipkin by openzipkin.

the class V1JsonSpanWriterTest method writesEmptyServiceName.

@Test
public void writesEmptyServiceName() {
    Span span = CLIENT_SPAN.toBuilder().localEndpoint(Endpoint.newBuilder().ip("127.0.0.1").build()).build();
    writer.write(span, buf);
    assertThat(new String(bytes, UTF_8)).contains("\"value\":\"foo\",\"endpoint\":{\"serviceName\":\"\",\"ipv4\":\"127.0.0.1\"}");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 4 with UTF_8

use of zipkin2.TestObjects.UTF_8 in project zipkin by openzipkin.

the class V2SpanWriterTest method omitsEmptySpanName.

@Test
public void omitsEmptySpanName() {
    Span span = Span.newBuilder().traceId("7180c278b62e8f6a216a2aea45d08fc9").parentId("6b221d5bc9e6496c").id("5b4185666d50f68b").build();
    writer.write(span, buf);
    assertThat(new String(bytes, UTF_8)).doesNotContain("name");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 5 with UTF_8

use of zipkin2.TestObjects.UTF_8 in project zipkin by openzipkin.

the class V1SpanBytesDecoderTest method ignoresNonAddressBooleanBinaryAnnotations.

@Test
public void ignoresNonAddressBooleanBinaryAnnotations() {
    String json = "{\n" + "  \"traceId\": \"6b221d5bc9e6496c\",\n" + "  \"id\": \"6b221d5bc9e6496c\",\n" + "  \"binaryAnnotations\": [\n" + "    {\n" + "      \"key\": \"aa\",\n" + "      \"value\": true,\n" + "      \"endpoint\": {\n" + "        \"serviceName\": \"foo\"\n" + "      }\n" + "    }\n" + "  ]\n" + "}";
    Span decoded = SpanBytesDecoder.JSON_V1.decodeOne(json.getBytes(UTF_8));
    assertThat(decoded.tags()).isEmpty();
    assertThat(decoded.localEndpoint()).isNull();
    assertThat(decoded.remoteEndpoint()).isNull();
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 Span (zipkin2.Span)7 DependencyLink (zipkin2.DependencyLink)2 Endpoint (zipkin2.Endpoint)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Record (org.jooq.Record)1 SelectField (org.jooq.SelectField)1 Test (org.junit.jupiter.api.Test)1 WriteBuffer (zipkin2.internal.WriteBuffer)1 ZipkinAnnotations (zipkin2.storage.mysql.v1.internal.generated.tables.ZipkinAnnotations)1