use of zipkin2.TestObjects.FRONTEND in project zipkin by openzipkin.
the class ITSpanStore method getTraces_differentiateOnServiceName.
/**
* This test makes sure that annotation queries pay attention to which host recorded data
*/
@Test
protected void getTraces_differentiateOnServiceName(TestInfo testInfo) throws Exception {
String testSuffix = testSuffix(testInfo);
Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
Span trace1 = Span.newBuilder().traceId(newTraceId()).name("1").id(1).kind(CLIENT).timestamp((TODAY + 1) * 1000L).duration(3000L).localEndpoint(frontend).addAnnotation(((TODAY + 1) * 1000L) + 500, "web").putTag("local", "web").putTag("web-b", "web").build();
Span trace1Server = Span.newBuilder().traceId(trace1.traceId()).name("1").id(1).kind(SERVER).shared(true).localEndpoint(backend).timestamp((TODAY + 2) * 1000L).duration(1000L).build();
Span trace2 = Span.newBuilder().traceId(newTraceId()).name("2").id(2).timestamp((TODAY + 11) * 1000L).duration(3000L).kind(CLIENT).localEndpoint(backend).addAnnotation(((TODAY + 11) * 1000) + 500, "app").putTag("local", "app").putTag("app-b", "app").build();
Span trace2Server = Span.newBuilder().traceId(trace2.traceId()).name("2").id(2).shared(true).kind(SERVER).localEndpoint(frontend).timestamp((TODAY + 12) * 1000L).duration(1000L).build();
accept(trace1, trace1Server, trace2, trace2Server);
// Sanity check
assertGetTraceReturns(trace1.traceId(), asList(trace1, trace1Server));
assertGetTraceReturns(trace2.traceId(), asList(trace2, trace2Server));
assertGetTracesReturns(requestBuilder().build(), asList(trace1, trace1Server), asList(trace2, trace2Server));
// We only return traces where the service specified caused the data queried.
assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("web").build(), asList(trace1, trace1Server));
assertGetTracesReturnsEmpty(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("web").build());
assertGetTracesReturns(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("app").build(), asList(trace2, trace2Server));
assertGetTracesReturnsEmpty(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("app").build());
// tags are returned on annotation queries
assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("web-b").build(), asList(trace1, trace1Server));
assertGetTracesReturnsEmpty(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("web-b").build());
assertGetTracesReturns(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("app-b").build(), asList(trace2, trace2Server));
assertGetTracesReturnsEmpty(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("app-b").build());
// We only return traces where the service specified caused the tag queried.
assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("local=web").build(), asList(trace1, trace1Server));
assertGetTracesReturnsEmpty(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("local=web").build());
assertGetTracesReturns(requestBuilder().serviceName(backend.serviceName()).parseAnnotationQuery("local=app").build(), asList(trace2, trace2Server));
assertGetTracesReturnsEmpty(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("local=app").build());
}
use of zipkin2.TestObjects.FRONTEND 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);
}
use of zipkin2.TestObjects.FRONTEND in project zipkin by openzipkin.
the class ITDependencies method getDependenciesAllInstrumented.
/**
* When all servers are instrumented, they all record {@link Kind#SERVER} and the {@link
* Span#localEndpoint()} indicates the service.
*/
@Test
protected void getDependenciesAllInstrumented(TestInfo testInfo) throws Exception {
String testSuffix = testSuffix(testInfo);
String traceId = newTraceId();
String frontend = appendSuffix(TestObjects.FRONTEND.serviceName(), testSuffix);
String backend = appendSuffix(TestObjects.BACKEND.serviceName(), testSuffix);
String db = appendSuffix(TestObjects.DB.serviceName(), testSuffix);
Endpoint one = Endpoint.newBuilder().serviceName(frontend).ip("127.0.0.1").build();
Endpoint onePort3001 = one.toBuilder().port(3001).build();
Endpoint two = Endpoint.newBuilder().serviceName(backend).ip("127.0.0.2").build();
Endpoint twoPort3002 = two.toBuilder().port(3002).build();
Endpoint three = Endpoint.newBuilder().serviceName(db).ip("127.0.0.3").build();
List<Span> trace = asList(Span.newBuilder().traceId(traceId).id("10").name("get").kind(Kind.SERVER).timestamp(TODAY * 1000L).duration(350 * 1000L).localEndpoint(one).build(), Span.newBuilder().traceId(traceId).parentId("10").id("20").name("get").kind(Kind.CLIENT).timestamp((TODAY + 50) * 1000L).duration(250 * 1000L).localEndpoint(onePort3001).build(), Span.newBuilder().traceId(traceId).parentId("10").id("20").name("get").shared(true).kind(Kind.SERVER).timestamp((TODAY + 100) * 1000L).duration(150 * 1000L).localEndpoint(two).build(), Span.newBuilder().traceId(traceId).parentId("20").id("30").name("query").kind(Kind.CLIENT).timestamp((TODAY + 150) * 1000L).duration(50 * 1000L).localEndpoint(twoPort3002).build(), Span.newBuilder().traceId(traceId).parentId("20").id("30").name("query").shared(true).kind(Kind.SERVER).timestamp((TODAY + 160) * 1000L).duration(20 * 1000L).localEndpoint(three).build());
processDependencies(trace);
assertThat(store().getDependencies(endTs(trace), DAY).execute()).containsOnly(DependencyLink.newBuilder().parent(frontend).child(backend).callCount(1).build(), DependencyLink.newBuilder().parent(backend).child(db).callCount(1).build());
}
use of zipkin2.TestObjects.FRONTEND 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.FRONTEND 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);
}
Aggregations