Search in sources :

Example 21 with BACKEND

use of zipkin2.TestObjects.BACKEND in project zipkin by openzipkin.

the class ITDependencies method oneway_noClient.

/**
 * Async span starts from an uninstrumented source.
 */
@Test
protected void oneway_noClient(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    String traceId = newTraceId();
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
    Endpoint kafka = suffixServiceName(TestObjects.KAFKA, testSuffix);
    List<Span> trace = asList(Span.newBuilder().traceId(traceId).id("10").name("receive").timestamp(TODAY * 1000).kind(Kind.SERVER).localEndpoint(backend).remoteEndpoint(kafka).build(), Span.newBuilder().traceId(traceId).parentId("10").id("11").name("process").timestamp((TODAY + 25) * 1000L).duration(325L * 1000L).localEndpoint(backend).build());
    processDependencies(trace);
    assertThat(store().getDependencies(endTs(trace), DAY).execute()).containsOnly(DependencyLink.newBuilder().parent(kafka.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 22 with BACKEND

use of zipkin2.TestObjects.BACKEND 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 23 with BACKEND

use of zipkin2.TestObjects.BACKEND 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());
}
Also used : Endpoint(zipkin2.Endpoint) TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 24 with BACKEND

use of zipkin2.TestObjects.BACKEND 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)

Example 25 with BACKEND

use of zipkin2.TestObjects.BACKEND 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());
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) Test(org.junit.jupiter.api.Test)

Aggregations

Span (zipkin2.Span)48 Test (org.junit.Test)31 Endpoint (zipkin2.Endpoint)17 Test (org.junit.jupiter.api.Test)16 V1Span (zipkin2.v1.V1Span)13 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)4 Call (zipkin2.Call)3 AggregateCall (zipkin2.internal.AggregateCall)3 InsertEntry (zipkin2.storage.cassandra.internal.call.InsertEntry)3 ArrayList (java.util.ArrayList)2 Arrays.asList (java.util.Arrays.asList)2 List (java.util.List)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 TraceSpan (com.google.devtools.cloudtrace.v1.TraceSpan)1 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)1 SpanSampler (com.wavefront.agent.sampler.SpanSampler)1 RateSampler (com.wavefront.sdk.entities.tracing.sampling.RateSampler)1 ByteBuf (io.netty.buffer.ByteBuf)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)1