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));
}
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));
}
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));
}
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);
}
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);
}
Aggregations