Search in sources :

Example 11 with TODAY

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

the class ITDependencies method instrumentedClientAndServer.

@Test
protected void instrumentedClientAndServer(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("10").name("get").timestamp((TODAY + 50L) * 1000L).duration(250L * 1000L).kind(Kind.CLIENT).localEndpoint(frontend).build(), Span.newBuilder().traceId(traceId).id("10").name("get").shared(true).timestamp((TODAY + 100) * 1000L).duration(150L * 1000L).kind(Kind.SERVER).localEndpoint(backend).build(), Span.newBuilder().traceId(traceId).parentId("10").id("11").name("get").timestamp((TODAY + 150L) * 1000L).duration(50L * 1000L).kind(Kind.CLIENT).localEndpoint(backend).remoteEndpoint(db).build());
    processDependencies(trace);
    assertThat(store().getDependencies(endTs(trace), DAY).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 12 with TODAY

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

the class ITDependencies method spanKindIsNotRequiredWhenEndpointsArePresent.

@Test
protected void spanKindIsNotRequiredWhenEndpointsArePresent(TestInfo testInfo) throws Exception {
    String testSuffix = testSuffix(testInfo);
    String traceId = newTraceId();
    Endpoint kafka = suffixServiceName(TestObjects.KAFKA, testSuffix);
    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(kafka).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);
    assertThat(store().getDependencies(TODAY + 1000, 1000L).execute()).containsOnly(DependencyLink.newBuilder().parent(kafka.serviceName()).child(frontend.serviceName()).callCount(1).build(), 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 13 with TODAY

use of zipkin2.TestObjects.TODAY 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 14 with TODAY

use of zipkin2.TestObjects.TODAY 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 15 with TODAY

use of zipkin2.TestObjects.TODAY 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));
}
Also used : 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