Search in sources :

Example 36 with Kind

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

the class ProtobufSpanDecoder method decodeOne.

public static Span decodeOne(CodedInputStream input) throws IOException {
    Span.Builder span = Span.newBuilder();
    boolean done = false;
    while (!done) {
        int tag = input.readTag();
        switch(tag) {
            case 0:
                done = true;
                break;
            case 10:
                {
                    span.traceId(readHexString(input));
                    break;
                }
            case 18:
                {
                    span.parentId(readHexString(input));
                    break;
                }
            case 26:
                {
                    span.id(readHexString(input));
                    break;
                }
            case 32:
                {
                    int kind = input.readEnum();
                    if (kind == 0)
                        break;
                    if (kind > Span.Kind.values().length)
                        break;
                    span.kind(Span.Kind.values()[kind - 1]);
                    break;
                }
            case 42:
                {
                    span.name(input.readStringRequireUtf8());
                    break;
                }
            case 49:
                {
                    span.timestamp(input.readFixed64());
                    break;
                }
            case 56:
                {
                    span.duration(input.readUInt64());
                    break;
                }
            case 66:
                {
                    int length = input.readRawVarint32();
                    int oldLimit = input.pushLimit(length);
                    span.localEndpoint(decodeEndpoint(input));
                    input.checkLastTagWas(0);
                    input.popLimit(oldLimit);
                    break;
                }
            case 74:
                {
                    int length = input.readRawVarint32();
                    int oldLimit = input.pushLimit(length);
                    span.remoteEndpoint(decodeEndpoint(input));
                    input.checkLastTagWas(0);
                    input.popLimit(oldLimit);
                    break;
                }
            case 82:
                {
                    int length = input.readRawVarint32();
                    int oldLimit = input.pushLimit(length);
                    decodeAnnotation(input, span);
                    input.checkLastTagWas(0);
                    input.popLimit(oldLimit);
                    break;
                }
            case 90:
                {
                    int length = input.readRawVarint32();
                    int oldLimit = input.pushLimit(length);
                    decodeTag(input, span);
                    input.checkLastTagWas(0);
                    input.popLimit(oldLimit);
                    break;
                }
            case 96:
                {
                    span.debug(input.readBool());
                    break;
                }
            case 104:
                {
                    span.shared(input.readBool());
                    break;
                }
            default:
                {
                    logAndSkip(input, tag);
                    break;
                }
        }
    }
    return span.build();
}
Also used : Span(zipkin2.Span) Endpoint(zipkin2.Endpoint)

Example 37 with Kind

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

the class ITDependencies method notInstrumentedClientAndServer.

/**
 * This test confirms that the span store can detect dependency indicated by local and remote
 * endpoint. Specifically, this detects an uninstrumented client before the trace and an
 * uninstrumented server at the end of it.
 */
@Test
protected void notInstrumentedClientAndServer(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    String traceId = newTraceId();
    Endpoint kafka = suffixServiceName(TestObjects.KAFKA, testSuffix);
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
    Endpoint db = suffixServiceName(TestObjects.DB, testSuffix);
    List<Span> trace = asList(Span.newBuilder().traceId(traceId).id("20").name("get").timestamp(TODAY * 1000L).duration(350L * 1000L).kind(Kind.SERVER).localEndpoint(frontend).remoteEndpoint(kafka).build(), Span.newBuilder().traceId(traceId).parentId("20").id("21").name("get").timestamp((TODAY + 50L) * 1000L).duration(250L * 1000L).kind(Kind.CLIENT).localEndpoint(frontend).build(), Span.newBuilder().traceId(traceId).parentId("20").id("21").name("get").shared(true).timestamp((TODAY + 250) * 1000L).duration(50L * 1000L).kind(Kind.SERVER).localEndpoint(backend).build(), Span.newBuilder().traceId(traceId).parentId("21").id("22").name("get").timestamp((TODAY + 150L) * 1000L).duration(50L * 1000L).kind(Kind.CLIENT).localEndpoint(backend).remoteEndpoint(db).build());
    processDependencies(trace);
    assertThat(store().getDependencies(endTs(trace), DAY).execute()).containsOnly(DependencyLink.newBuilder().parent(kafka.serviceName()).child(frontend.serviceName()).callCount(1).build(), DependencyLink.newBuilder().parent(frontend.serviceName()).child(backend.serviceName()).callCount(1).build(), DependencyLink.newBuilder().parent(backend.serviceName()).child(db.serviceName()).callCount(1).build());
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) Test(org.junit.jupiter.api.Test)

Example 38 with Kind

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

the class ITDependencies method oneway.

/**
 * Span starts on one host and ends on the other. In both cases, a response is neither sent nor
 * received.
 */
@Test
protected void oneway(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    String traceId = newTraceId();
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
    List<Span> trace = asList(Span.newBuilder().traceId(traceId).id("10").timestamp((TODAY + 50) * 1000).kind(Kind.CLIENT).localEndpoint(frontend).build(), Span.newBuilder().traceId(traceId).id("10").shared(true).timestamp((TODAY + 100) * 1000).kind(Kind.SERVER).localEndpoint(backend).build());
    processDependencies(trace);
    assertThat(store().getDependencies(endTs(trace), DAY).execute()).containsOnly(DependencyLink.newBuilder().parent(frontend.serviceName()).child(backend.serviceName()).callCount(1).build());
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) Test(org.junit.jupiter.api.Test)

Example 39 with Kind

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

the class ITDependencies method instrumentedClientAndServer.

@Test
protected void instrumentedClientAndServer(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    String traceId = newTraceId();
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
    Endpoint db = suffixServiceName(TestObjects.DB, testSuffix);
    List<Span> trace = asList(Span.newBuilder().traceId(traceId).id("10").name("get").timestamp((TODAY + 50L) * 1000L).duration(250L * 1000L).kind(Kind.CLIENT).localEndpoint(frontend).build(), Span.newBuilder().traceId(traceId).id("10").name("get").shared(true).timestamp((TODAY + 100) * 1000L).duration(150L * 1000L).kind(Kind.SERVER).localEndpoint(backend).build(), Span.newBuilder().traceId(traceId).parentId("10").id("11").name("get").timestamp((TODAY + 150L) * 1000L).duration(50L * 1000L).kind(Kind.CLIENT).localEndpoint(backend).remoteEndpoint(db).build());
    processDependencies(trace);
    assertThat(store().getDependencies(endTs(trace), DAY).execute()).containsOnly(DependencyLink.newBuilder().parent(frontend.serviceName()).child(backend.serviceName()).callCount(1).build(), DependencyLink.newBuilder().parent(backend.serviceName()).child(db.serviceName()).callCount(1).build());
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) Test(org.junit.jupiter.api.Test)

Example 40 with Kind

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

the class ITDependencies method oneway_noClient.

/**
 * Async span starts from an uninstrumented source.
 */
@Test
protected void oneway_noClient(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    String traceId = newTraceId();
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
    Endpoint kafka = suffixServiceName(TestObjects.KAFKA, testSuffix);
    List<Span> trace = asList(Span.newBuilder().traceId(traceId).id("10").name("receive").timestamp(TODAY * 1000).kind(Kind.SERVER).localEndpoint(backend).remoteEndpoint(kafka).build(), Span.newBuilder().traceId(traceId).parentId("10").id("11").name("process").timestamp((TODAY + 25) * 1000L).duration(325L * 1000L).localEndpoint(backend).build());
    processDependencies(trace);
    assertThat(store().getDependencies(endTs(trace), DAY).execute()).containsOnly(DependencyLink.newBuilder().parent(kafka.serviceName()).child(backend.serviceName()).callCount(1).build());
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) Test(org.junit.jupiter.api.Test)

Aggregations

Span (zipkin2.Span)82 Test (org.junit.Test)54 Endpoint (zipkin2.Endpoint)25 Test (org.junit.jupiter.api.Test)17 V1Span (zipkin2.v1.V1Span)10 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)8 IOException (java.io.IOException)6 Map (java.util.Map)5 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)5 Tracer (brave.Tracer)4 Tracing (brave.Tracing)4 Trace (com.google.devtools.cloudtrace.v1.Trace)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 Before (org.junit.Before)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 Span (brave.Span)3 Sampler (brave.sampler.Sampler)3 Annotation (zipkin2.Annotation)3