Search in sources :

Example 36 with TODAY

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

the class ITDependencies method missingIntermediateSpan.

/**
 * This shows a missing parent still results in a dependency link when local endpoints change
 */
@Test
protected void missingIntermediateSpan(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    String traceId = newTraceId();
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    Endpoint backend = suffixServiceName(TestObjects.BACKEND, testSuffix);
    List<Span> trace = asList(Span.newBuilder().traceId(traceId).id("20").name("get").timestamp(TODAY * 1000L).duration(350L * 1000L).kind(Kind.SERVER).localEndpoint(frontend).build(), // missing an intermediate span
    Span.newBuilder().traceId(traceId).parentId("21").id("22").name("get").timestamp((TODAY + 150L) * 1000L).duration(50L * 1000L).kind(Kind.CLIENT).localEndpoint(backend).build());
    processDependencies(trace);
    assertThat(store().getDependencies(endTs(trace), DAY).execute()).containsOnly(DependencyLink.newBuilder().parent(frontend.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 37 with TODAY

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

the class ITDependencies method intermediateSpans.

/**
 * 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 intermediateSpans(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).kind(Kind.SERVER).localEndpoint(frontend).build(), Span.newBuilder().traceId(traceId).parentId("20").id("21").name("call").timestamp((TODAY + 25) * 1000L).duration(325L * 1000L).localEndpoint(frontend).build(), Span.newBuilder().traceId(traceId).parentId("21").id("22").name("get").timestamp((TODAY + 50) * 1000L).duration(250L * 1000L).kind(Kind.CLIENT).localEndpoint(frontend).build(), Span.newBuilder().traceId(traceId).parentId("21").id("22").name("get").timestamp((TODAY + 100) * 1000L).duration(150 * 1000L).shared(true).kind(Kind.SERVER).localEndpoint(backend).build(), Span.newBuilder().traceId(traceId).parentId("22").id(23L).name("call").timestamp((TODAY + 110) * 1000L).duration(130L * 1000L).name("depth4").localEndpoint(backend).build(), Span.newBuilder().traceId(traceId).parentId(23L).id(24L).name("call").timestamp((TODAY + 125) * 1000L).duration(105L * 1000L).name("depth5").localEndpoint(backend).build(), Span.newBuilder().traceId(traceId).parentId(24L).id(25L).name("get").timestamp((TODAY + 150) * 1000L).duration(50L * 1000L).kind(Kind.CLIENT).localEndpoint(backend).remoteEndpoint(db).build());
    processDependencies(trace);
    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());
}
Also used : Endpoint(zipkin2.Endpoint) Span(zipkin2.Span) V1Span(zipkin2.v1.V1Span) Test(org.junit.jupiter.api.Test)

Example 38 with TODAY

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

the class ITSpanStore method readback_minimalErrorSpan.

/**
 * The following skeletal span is used in dependency linking.
 *
 * <p>Notably this guards empty tag values work
 */
@Test
protected void readback_minimalErrorSpan(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    String serviceName = appendSuffix("isao01", testSuffix);
    Span errorSpan = Span.newBuilder().traceId(newTraceId()).id("1").timestamp(TODAY * 1000L).localEndpoint(Endpoint.newBuilder().serviceName(serviceName).build()).kind(CLIENT).putTag("error", "").build();
    accept(errorSpan);
    QueryRequest.Builder requestBuilder = // so this doesn't die on cassandra v1
    requestBuilder().serviceName(serviceName);
    assertGetTracesReturns(requestBuilder.build(), asList(errorSpan));
    assertGetTracesReturns(requestBuilder.parseAnnotationQuery("error").build(), asList(errorSpan));
    assertGetTracesReturnsEmpty(requestBuilder.parseAnnotationQuery("error=1").build());
    assertGetTraceReturns(errorSpan);
}
Also used : TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 39 with TODAY

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

the class ITSpanStore method getTraces_limit.

/**
 * limit should apply to traces closest to endTs
 */
@Test
protected void getTraces_limit(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Span span1 = spanBuilder(testSuffix).build();
    Span span2 = span1.toBuilder().traceId(newTraceId()).timestamp((TODAY + 2) * 1000L).build();
    accept(span1, span2);
    assertGetTracesReturns(requestBuilder().serviceName(span1.localServiceName()).limit(1).build(), asList(span2));
}
Also used : TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Example 40 with TODAY

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

the class ITSpanStore method getTraces_multipleAnnotationsBecomeAndFilter.

@Test
protected void getTraces_multipleAnnotationsBecomeAndFilter(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    Endpoint frontend = suffixServiceName(TestObjects.FRONTEND, testSuffix);
    Span foo = Span.newBuilder().traceId(newTraceId()).name("call1").id(1).timestamp((TODAY + 1) * 1000L).localEndpoint(frontend).addAnnotation((TODAY + 1) * 1000L, "foo").build();
    // would be foo bar, except lexicographically bar precedes foo
    Span barAndFoo = Span.newBuilder().traceId(newTraceId()).name("call2").id(2).timestamp((TODAY + 2) * 1000L).localEndpoint(frontend).addAnnotation((TODAY + 2) * 1000L, "bar").addAnnotation((TODAY + 2) * 1000L, "foo").build();
    Span fooAndBazAndQux = Span.newBuilder().traceId(newTraceId()).name("call3").id(3).timestamp((TODAY + 3) * 1000L).localEndpoint(frontend).addAnnotation((TODAY + 3) * 1000L, "foo").putTag("baz", "qux").build();
    Span barAndFooAndBazAndQux = Span.newBuilder().traceId(newTraceId()).name("call4").id(4).timestamp((TODAY + 4) * 1000L).localEndpoint(frontend).addAnnotation((TODAY + 4) * 1000L, "bar").addAnnotation((TODAY + 4) * 1000L, "foo").putTag("baz", "qux").build();
    accept(foo, barAndFoo, fooAndBazAndQux, barAndFooAndBazAndQux);
    assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("foo").build(), asList(foo), asList(barAndFoo), asList(fooAndBazAndQux), asList(barAndFooAndBazAndQux));
    assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("foo and bar").build(), asList(barAndFoo), asList(barAndFooAndBazAndQux));
    assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("foo and bar and baz=qux").build(), asList(barAndFooAndBazAndQux));
    // ensure we can search only by tag key
    assertGetTracesReturns(requestBuilder().serviceName(frontend.serviceName()).parseAnnotationQuery("baz").build(), asList(fooAndBazAndQux), asList(barAndFooAndBazAndQux));
}
Also used : Endpoint(zipkin2.Endpoint) TestObjects.newClientSpan(zipkin2.TestObjects.newClientSpan) Span(zipkin2.Span) Test(org.junit.jupiter.api.Test)

Aggregations

Span (zipkin2.Span)38 Test (org.junit.jupiter.api.Test)28 Endpoint (zipkin2.Endpoint)20 V1Span (zipkin2.v1.V1Span)13 TestObjects.newClientSpan (zipkin2.TestObjects.newClientSpan)10 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)3 Map (java.util.Map)2 QueryRequest (zipkin2.storage.QueryRequest)2 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 DependencyLink (zipkin2.DependencyLink)1 SpanBytesEncoder (zipkin2.codec.SpanBytesEncoder)1 V1SpanConverter (zipkin2.v1.V1SpanConverter)1