Search in sources :

Example 71 with Kind

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

the class SpanConverterTest method lateRemoteEndpoint_ca.

/**
 * Late flushed data on a v1 v1
 */
@Test
public void lateRemoteEndpoint_ca() {
    Span v2 = Span.newBuilder().traceId("1").id("2").kind(Kind.SERVER).remoteEndpoint(FRONTEND).build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).id(2L).addBinaryAnnotation("ca", FRONTEND).build();
    assertThat(v2SpanConverter.convert(v2)).usingRecursiveComparison().isEqualTo(v1);
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 72 with Kind

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

the class SpanConverterTest method redundantAddressAnnotations_client.

/**
 * Intentionally create service loopback endpoints as dependency linker can correct it later if
 * incorrect, provided the server is instrumented.
 */
@Test
public void redundantAddressAnnotations_client() {
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").kind(Kind.CLIENT).name("get").localEndpoint(FRONTEND).remoteEndpoint(FRONTEND).timestamp(1472470996199000L).duration(207000L).build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996199000L, "cs", FRONTEND).addAnnotation(1472470996406000L, "cr", FRONTEND).addBinaryAnnotation("ca", FRONTEND).addBinaryAnnotation("sa", FRONTEND).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 73 with Kind

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

the class SpanConverterTest method assumesServerWithoutTimestampIsShared.

/**
 * The old v1 format had no means of saying it is shared or not. This uses lack of timestamp as a
 * signal
 */
@Test
public void assumesServerWithoutTimestampIsShared() {
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").addAnnotation(1472470996250000L, "sr", BACKEND).addAnnotation(1472470996350000L, "ss", BACKEND).build();
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").name("get").kind(Kind.SERVER).shared(true).localEndpoint(BACKEND).timestamp(1472470996250000L).duration(100000L).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 74 with Kind

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

the class SpanConverterTest method redundantServiceNameOnAddressAnnotations_serverRetainsClientSocket.

@Test
public void redundantServiceNameOnAddressAnnotations_serverRetainsClientSocket() {
    Span v2 = Span.newBuilder().traceId("1").parentId("2").id("3").kind(Kind.SERVER).name("get").localEndpoint(BACKEND).remoteEndpoint(FRONTEND.toBuilder().serviceName(null).build()).timestamp(1472470996199000L).duration(207000L).build();
    V1Span v1 = V1Span.newBuilder().traceId(1L).parentId(2L).id(3L).name("get").timestamp(1472470996199000L).duration(207000L).addAnnotation(1472470996199000L, "sr", BACKEND).addAnnotation(1472470996406000L, "ss", BACKEND).addBinaryAnnotation("ca", FRONTEND.toBuilder().serviceName("backend").build()).addBinaryAnnotation("sa", BACKEND).build();
    assertThat(v1SpanConverter.convert(v1)).containsExactly(v2);
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 75 with Kind

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

the class WireSpanDecoder method decodeOne.

public static Span decodeOne(ProtoReader input) throws IOException {
    Span.Builder span = Span.newBuilder();
    boolean done = false;
    while (!done) {
        int tag = input.nextTag();
        switch(tag) {
            case -1:
                done = true;
                break;
            case 1:
                {
                    span.traceId(readHexString(input));
                    break;
                }
            case 2:
                {
                    span.parentId(readHexString(input));
                    break;
                }
            case 3:
                {
                    span.id(readHexString(input));
                    break;
                }
            case 4:
                {
                    int kind = input.readVarint32();
                    if (kind == 0)
                        break;
                    if (kind > Span.Kind.values().length)
                        break;
                    span.kind(Span.Kind.values()[kind - 1]);
                    break;
                }
            case 5:
                {
                    String name = input.readString();
                    span.name(name);
                    break;
                }
            case 6:
                {
                    span.timestamp(input.readFixed64());
                    break;
                }
            case 7:
                {
                    span.duration(input.readVarint64());
                    break;
                }
            case 8:
                {
                    long token = input.beginMessage();
                    span.localEndpoint(decodeEndpoint(input));
                    input.endMessageAndGetUnknownFields(token);
                    break;
                }
            case 9:
                {
                    long token = input.beginMessage();
                    span.remoteEndpoint(decodeEndpoint(input));
                    input.endMessageAndGetUnknownFields(token);
                    break;
                }
            case 10:
                {
                    long token = input.beginMessage();
                    decodeAnnotation(input, span);
                    input.endMessageAndGetUnknownFields(token);
                    break;
                }
            case 11:
                {
                    long token = input.beginMessage();
                    decodeTag(input, span);
                    input.endMessageAndGetUnknownFields(token);
                    break;
                }
            case 12:
                {
                    span.debug(ProtoAdapter.BOOL.decode(input));
                    break;
                }
            case 13:
                {
                    span.shared(ProtoAdapter.BOOL.decode(input));
                    break;
                }
            default:
                {
                    logAndSkip(input, tag);
                    break;
                }
        }
    }
    return span.build();
}
Also used : ByteString(okio.ByteString) Span(zipkin2.Span) Endpoint(zipkin2.Endpoint)

Aggregations

Span (zipkin2.Span)77 Test (org.junit.Test)54 Endpoint (zipkin2.Endpoint)28 Test (org.junit.jupiter.api.Test)17 V1Span (zipkin2.v1.V1Span)10 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)8 SpanSampler (com.wavefront.agent.sampler.SpanSampler)6 ByteBuf (io.netty.buffer.ByteBuf)6 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)6 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)6 IOException (java.io.IOException)6 Map (java.util.Map)6 Span (wavefront.report.Span)6 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)5 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)5 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)5 Trace (com.google.devtools.cloudtrace.v1.Trace)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Annotation (wavefront.report.Annotation)4 Annotation (zipkin2.Annotation)3