use of zipkin2.TestObjects.TODAY in project zipkin by openzipkin.
the class ITDependencies method unnamedEndpointsAreSkipped.
@Test
protected void unnamedEndpointsAreSkipped(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("20").name("get").timestamp(TODAY * 1000L).duration(350L * 1000L).localEndpoint(Endpoint.newBuilder().ip("172.17.0.4").build()).remoteEndpoint(frontend).build(), Span.newBuilder().traceId(traceId).parentId("20").id("21").name("get").timestamp((TODAY + 50) * 1000L).duration(250L * 1000L).localEndpoint(frontend).remoteEndpoint(backend).build(), Span.newBuilder().traceId(traceId).parentId("21").id("22").name("get").timestamp((TODAY + 150) * 1000L).duration(50L * 1000L).localEndpoint(backend).remoteEndpoint(db).build());
processDependencies(trace);
// note there is no empty string service names
assertThat(store().getDependencies(TODAY + 1000, 1000L).execute()).containsOnly(DependencyLink.newBuilder().parent(frontend.serviceName()).child(backend.serviceName()).callCount(1).build(), DependencyLink.newBuilder().parent(backend.serviceName()).child(db.serviceName()).callCount(1).build());
}
use of zipkin2.TestObjects.TODAY 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));
}
use of zipkin2.TestObjects.TODAY 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 zipkin2.TestObjects.TODAY in project zipkin by openzipkin.
the class ITZipkinSelfTracing method postSpan.
/**
* This POSTs a single span. Afterwards, we expect this trace in storage, and also the self-trace
* of POSTing it.
*/
void postSpan(String version) throws IOException {
SpanBytesEncoder encoder = "v1".equals(version) ? SpanBytesEncoder.JSON_V1 : SpanBytesEncoder.JSON_V2;
List<Span> testTrace = Collections.singletonList(Span.newBuilder().timestamp(TODAY).traceId("1").id("2").name("test-trace").build());
Response response = client.newCall(new Request.Builder().url(url(server, "/api/" + version + "/spans")).post(RequestBody.create(encoder.encodeList(testTrace))).build()).execute();
assertSuccessful(response);
}
use of zipkin2.TestObjects.TODAY in project zipkin by openzipkin.
the class ITSpanStore method getTraces_endTsAndLookback.
/**
* Traces whose root span has timestamps between (endTs - lookback) and endTs are returned
*/
@Test
protected void getTraces_endTsAndLookback(TestInfo testInfo) throws Exception {
String testSuffix = testSuffix(testInfo);
Span span1 = spanBuilder(testSuffix).timestamp((TODAY + 1) * 1000L).build();
Span span2 = span1.toBuilder().traceId(newTraceId()).timestamp((TODAY + 2) * 1000L).build();
accept(span1, span2);
assertGetTracesReturnsEmpty(requestBuilder().endTs(TODAY).build());
assertGetTracesReturns(requestBuilder().endTs(TODAY + 1).build(), asList(span1));
assertGetTracesReturns(requestBuilder().endTs(TODAY + 2).build(), asList(span1), asList(span2));
assertGetTracesReturns(requestBuilder().endTs(TODAY + 3).build(), asList(span1), asList(span2));
assertGetTracesReturnsEmpty(requestBuilder().endTs(TODAY).build());
assertGetTracesReturns(requestBuilder().endTs(TODAY + 1).lookback(1).build(), asList(span1));
assertGetTracesReturns(requestBuilder().endTs(TODAY + 2).lookback(1).build(), asList(span1), asList(span2));
assertGetTracesReturns(requestBuilder().endTs(TODAY + 3).lookback(1).build(), asList(span2));
}
Aggregations