Search in sources :

Example 31 with Span

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

the class ITDependencies method duplicateAddress.

/**
 * This test confirms that the span store can process trace with intermediate spans like the below
 * properly.
 * <p>
 * span1: SR SS span2: intermediate call span3: CS SR SS CR: Dependency 1
 */
@Test
protected void duplicateAddress(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    String traceId = newTraceId();
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
    V1SpanConverter converter = V1SpanConverter.create();
    List<Span> trace = new ArrayList<>();
    converter.convert(V1Span.newBuilder().traceId(traceId).id("20").name("get").timestamp(TODAY * 1000L).duration(350L * 1000L).addAnnotation(TODAY * 1000, "sr", frontend).addAnnotation((TODAY + 350) * 1000, "ss", frontend).addBinaryAnnotation("ca", frontend).addBinaryAnnotation("sa", frontend).build(), trace);
    converter.convert(V1Span.newBuilder().traceId(traceId).parentId("21").id("22").name("get").timestamp((TODAY + 50) * 1000L).duration(250L * 1000L).addAnnotation((TODAY + 50) * 1000, "cs", frontend).addAnnotation((TODAY + 300) * 1000, "cr", frontend).addBinaryAnnotation("ca", backend).addBinaryAnnotation("sa", backend).build(), trace);
    processDependencies(trace);
    assertThat(store().getDependencies(TODAY + 1000, 1000L).execute()).containsOnly(DependencyLink.newBuilder().parent(frontend.serviceName()).child(backend.serviceName()).callCount(1).build());
}
Also used : Endpoint(zipkin2.Endpoint) V1SpanConverter(zipkin2.v1.V1SpanConverter) ArrayList(java.util.ArrayList) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) Test(org.junit.jupiter.api.Test)

Example 32 with Span

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

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

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

the class ITDependenciesHeavy method manyLinks.

/**
 * Ensure there's no query limit problem around links
 */
@Test
protected void manyLinks() throws Exception {
    // Larger than 10, which is the default ES search limit that tripped this
    int count = 1000;
    List<Span> spans = new ArrayList<>(count);
    for (int i = 1; i <= count; i++) {
        String traceId = newTraceId();
        Endpoint web = FRONTEND.toBuilder().serviceName("web-" + i).build();
        Endpoint app = BACKEND.toBuilder().serviceName("app-" + i).build();
        Endpoint db = DB.toBuilder().serviceName("db-" + i).build();
        spans.add(Span.newBuilder().traceId(traceId).id("10").name("get").timestamp((TODAY + 50L) * 1000L).duration(250L * 1000L).kind(Kind.CLIENT).localEndpoint(web).build());
        spans.add(Span.newBuilder().traceId(traceId).id("10").name("get").shared(true).timestamp((TODAY + 100) * 1000L).duration(150 * 1000L).kind(Kind.SERVER).localEndpoint(app).build());
        spans.add(Span.newBuilder().traceId(traceId).parentId("10").id("11").name("get").timestamp((TODAY + 150L) * 1000L).duration(50L * 1000L).kind(Kind.CLIENT).localEndpoint(app).remoteEndpoint(db).build());
    }
    processDependencies(spans);
    List<DependencyLink> links = store().getDependencies(endTs(spans), DAY).execute();
    // web-? -> app-?, app-? -> db-?
    assertThat(links).hasSize(count * 2);
    assertThat(links).extracting(DependencyLink::callCount).allSatisfy(callCount -> assertThat(callCount).isEqualTo(1));
}
Also used : Endpoint(zipkin2.Endpoint) ArrayList(java.util.ArrayList) DependencyLink(zipkin2.DependencyLink) Span(zipkin2.Span) Endpoint(zipkin2.Endpoint) Test(org.junit.jupiter.api.Test)

Example 35 with Span

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

the class ITSearchEnabledFalse method getTraces_indexDataReturnsNothing.

@Test
protected void getTraces_indexDataReturnsNothing(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Span clientSpan = newClientSpan(testSuffix);
    accept(clientSpan);
    assertGetTracesReturnsEmpty(requestBuilder().build());
    assertGetTracesReturnsEmpty(requestBuilder().serviceName(clientSpan.localServiceName()).build());
    assertGetTracesReturnsEmpty(requestBuilder().spanName(clientSpan.name()).build());
    assertGetTracesReturnsEmpty(requestBuilder().annotationQuery(clientSpan.tags()).build());
    assertGetTracesReturnsEmpty(requestBuilder().minDuration(clientSpan.duration()).build());
}
Also used : TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Aggregations

Span (zipkin2.Span)340 Test (org.junit.Test)260 Test (org.junit.jupiter.api.Test)84 Span (io.opentelemetry.proto.trace.v1.Span)54 ArrayList (java.util.ArrayList)45 Endpoint (zipkin2.Endpoint)43 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)41 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)39 List (java.util.List)25 Annotation (wavefront.report.Annotation)22 V1Span (zipkin2.v1.V1Span)17 Span (com.google.devtools.cloudtrace.v2.Span)16 Map (java.util.Map)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)14 AggregateCall (zipkin2.internal.AggregateCall)13 ByteString (com.google.protobuf.ByteString)11 Arrays.asList (java.util.Arrays.asList)11 Trace (com.google.devtools.cloudtrace.v1.Trace)10 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)10 AttributeValue (com.google.devtools.cloudtrace.v2.AttributeValue)10