Search in sources :

Example 41 with Span

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

the class ITSpanStore method getTraces_groupsTracesTogether.

@Test
protected void getTraces_groupsTracesTogether(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Span traceASpan1 = spanBuilder(testSuffix).timestamp((TODAY + 1) * 1000L).build();
    Span traceASpan2 = traceASpan1.toBuilder().id("2").timestamp((TODAY + 2) * 1000L).build();
    String traceId2 = newTraceId();
    Span traceBSpan1 = traceASpan1.toBuilder().traceId(traceId2).build();
    Span traceBSpan2 = traceASpan2.toBuilder().traceId(traceId2).build();
    accept(traceASpan1, traceBSpan1, traceASpan2, traceBSpan2);
    assertGetTracesReturns(requestBuilder().build(), asList(traceASpan1, traceASpan2), asList(traceBSpan1, traceBSpan2));
}
Also used : TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 42 with Span

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

the class ITSpanStore method spanWithProblematicData.

/**
 * This tests problematic data that can sometimes break storage:
 *
 * <ul>
 *   <li>json in span name</li>
 *   <li>tag with nested dots (can be confused as nested objects)</li>
 * </ul>
 */
@Test
protected void spanWithProblematicData(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    // Intentionally store in two fragments to try to trigger storage problems with dots
    Span part1 = spanBuilder(testSuffix).putTag("http.path", "/api").build();
    accept(part1);
    String json = "{\"foo\":\"bar\"}";
    Span part2 = part1.toBuilder().name(json).clearTags().putTag("http.path.morepath", "/api/api").build();
    accept(part2);
    assertGetTracesReturns(requestBuilder().serviceName(part1.localServiceName()).spanName(json).build(), asList(part2, part1));
    assertGetTraceReturns(part1.traceId(), asList(part2, part1));
}
Also used : TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 43 with Span

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

the class ITSpanStore method getTraces_minDuration.

@Test
protected void getTraces_minDuration(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Span clientSpan = newClientSpan(testSuffix);
    accept(clientSpan);
    assertGetTracesReturnsEmpty(requestBuilder().minDuration(clientSpan.durationAsLong() + 1).build());
    assertGetTracesReturns(requestBuilder().minDuration(clientSpan.durationAsLong()).build(), asList(clientSpan));
}
Also used : TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 44 with Span

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

the class ITSpanStore method setupDurationData.

List<List<Span>> setupDurationData(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
    Endpoint db = suffixServiceName(TestObjects.DB, testSuffix);
    String traceId1 = newTraceId(), traceId2 = newTraceId(), traceId3 = newTraceId();
    // to make sure queries look back properly
    long offsetMicros = (TODAY - 3) * 1000L;
    Span targz = Span.newBuilder().traceId(traceId1).id(1L).name("targz").timestamp(offsetMicros + 100L).duration(200_000L).localEndpoint(frontend).remoteEndpoint(db).putTag("lc", "archiver").build();
    Span tar = Span.newBuilder().traceId(traceId1).id(2L).parentId(1L).name("tar").timestamp(offsetMicros + 200L).duration(150_000L).localEndpoint(backend).remoteEndpoint(backend).putTag("lc", "archiver").build();
    Span gz = Span.newBuilder().traceId(traceId1).id(3L).parentId(1L).name("gz").timestamp(offsetMicros + 250L).duration(50_000L).localEndpoint(db).remoteEndpoint(frontend).putTag("lc", "archiver").build();
    Span zip = Span.newBuilder().traceId(traceId3).id(3L).name("zip").timestamp(offsetMicros + 130L).duration(50_000L).addAnnotation(offsetMicros + 130L, "zip").localEndpoint(backend).remoteEndpoint(backend).putTag("lc", "archiver").build();
    List<Span> trace1 = asList(targz, tar, gz);
    List<Span> trace2 = asList(targz.toBuilder().traceId(traceId2).timestamp(offsetMicros + 110L).localEndpoint(db).remoteEndpoint(frontend).putTag("lc", "archiver-v2").build(), tar.toBuilder().traceId(traceId2).timestamp(offsetMicros + 210L).localEndpoint(backend).remoteEndpoint(backend).putTag("lc", "archiver").build(), gz.toBuilder().traceId(traceId2).timestamp(offsetMicros + 260L).localEndpoint(frontend).remoteEndpoint(backend).putTag("lc", "archiver").build());
    List<Span> trace3 = asList(zip);
    accept(trace1);
    accept(trace2);
    accept(trace3);
    return asList(trace1, trace2, trace3);
}
Also used : Endpoint(zipkin2.Endpoint) TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span)

Example 45 with Span

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

the class ITSpanStore method getTraces_duration.

/**
 * Shows that duration queries go against the root span, not the child
 */
@Test
protected void getTraces_duration(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
    Endpoint db = suffixServiceName(TestObjects.DB, testSuffix);
    List<List<Span>> traces = setupDurationData(testInfo);
    List<Span> trace1 = traces.get(0), trace2 = traces.get(1), trace3 = traces.get(2);
    // instead of since epoch
    QueryRequest.Builder q = requestBuilder().endTs(TODAY).lookback(DAY);
    // Min duration is inclusive and is applied by service.
    assertGetTracesReturns(q.serviceName(frontend.serviceName()).minDuration(200_000L).build(), trace1);
    assertGetTracesReturns(q.serviceName(db.serviceName()).minDuration(200_000L).build(), trace2);
    // Duration bounds aren't limited to root spans: they apply to all spans by service in a trace
    assertGetTracesReturns(q.serviceName(backend.serviceName()).minDuration(50_000L).maxDuration(150_000L).build(), trace1, trace2, trace3);
    // Remote service name should apply to the duration filter
    assertGetTracesReturns(q.serviceName(frontend.serviceName()).remoteServiceName(backend.serviceName()).maxDuration(50_000L).build(), trace2);
    // Span name should apply to the duration filter
    assertGetTracesReturns(q.serviceName(backend.serviceName()).spanName("zip").maxDuration(50_000L).build(), trace3);
    // Max duration should filter our longer spans from the same service
    assertGetTracesReturns(q.serviceName(backend.serviceName()).minDuration(50_000L).maxDuration(50_000L).build(), trace3);
}
Also used : Endpoint(zipkin2.Endpoint) Arrays.asList(java.util.Arrays.asList) List(java.util.List) 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