Search in sources :

Example 6 with TODAY

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

the class InMemoryStorageTest method getSpanNames_skipsNullSpanName.

@Test
public void getSpanNames_skipsNullSpanName() throws IOException {
    Span span1 = Span.newBuilder().traceId("1").id("1").name("root").localEndpoint(Endpoint.newBuilder().serviceName("app").build()).timestamp(TODAY * 1000).build();
    Span span2 = Span.newBuilder().traceId("1").parentId("1").id("2").localEndpoint(Endpoint.newBuilder().serviceName("app").build()).timestamp(TODAY * 1000).build();
    storage.accept(asList(span1, span2)).execute();
    assertThat(storage.getSpanNames("app").execute()).containsOnly("root");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 7 with TODAY

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

the class InMemoryStorageTest method getTagsAndThenValues.

@Test
public void getTagsAndThenValues() throws IOException {
    Span span1 = Span.newBuilder().traceId("1").id("1").name("root").localEndpoint(Endpoint.newBuilder().serviceName("app").build()).putTag("environment", "dev").putTag("http.method", "GET").timestamp(TODAY * 1000).build();
    Span span2 = Span.newBuilder().traceId("1").parentId("1").id("2").localEndpoint(Endpoint.newBuilder().serviceName("app").build()).putTag("environment", "dev").putTag("http.method", "POST").putTag("http.path", "/users").timestamp(TODAY * 1000).build();
    Span span3 = Span.newBuilder().traceId("2").id("3").name("root").localEndpoint(Endpoint.newBuilder().serviceName("app").build()).putTag("environment", "dev").putTag("http.method", "GET").timestamp(TODAY * 1000).build();
    Span span4 = Span.newBuilder().traceId("2").parentId("3").id("4").localEndpoint(Endpoint.newBuilder().serviceName("app").build()).putTag("environment", "dev").putTag("http.method", "POST").putTag("http.path", "/users").timestamp(TODAY * 1000).build();
    storage.accept(asList(span1, span2, span3, span4)).execute();
    assertThat(storage.getKeys().execute()).containsOnlyOnce("http.path");
    assertThat(storage.getValues("http.path").execute()).containsOnlyOnce("/users");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 8 with TODAY

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

the class ITZipkinServer method setsCacheControlOnNameEndpointsWhenMoreThan3Services.

@Test
public void setsCacheControlOnNameEndpointsWhenMoreThan3Services() throws Exception {
    List<String> services = asList("foo", "bar", "baz", "quz");
    for (int i = 0; i < services.size(); i++) {
        storage.accept(asList(Span.newBuilder().traceId("a").id(i + 1).timestamp(TODAY).name("whopper").localEndpoint(Endpoint.newBuilder().serviceName(services.get(i)).build()).remoteEndpoint(Endpoint.newBuilder().serviceName(services.get(i) + 1).build()).build())).execute();
    }
    assertThat(get("/api/v2/services").header("Cache-Control")).isEqualTo("max-age=300, must-revalidate");
    assertThat(get("/api/v2/spans?serviceName=web").header("Cache-Control")).isEqualTo("max-age=300, must-revalidate");
    assertThat(get("/api/v2/remoteServices?serviceName=web").header("Cache-Control")).isEqualTo("max-age=300, must-revalidate");
    // Check that the response is alphabetically sorted.
    assertThat(get("/api/v2/services").body().string()).isEqualTo("[\"bar\",\"baz\",\"foo\",\"quz\"]");
}
Also used : Endpoint(zipkin2.Endpoint) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with TODAY

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

the class ITDependencies method notInstrumentedClientAndServer.

/**
 * This test confirms that the span store can detect dependency indicated by local and remote
 * endpoint. Specifically, this detects an uninstrumented client before the trace and an
 * uninstrumented server at the end of it.
 */
@Test
protected void notInstrumentedClientAndServer(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).kind(Kind.SERVER).localEndpoint(frontend).remoteEndpoint(kafka).build(), Span.newBuilder().traceId(traceId).parentId("20").id("21").name("get").timestamp((TODAY + 50L) * 1000L).duration(250L * 1000L).kind(Kind.CLIENT).localEndpoint(frontend).build(), Span.newBuilder().traceId(traceId).parentId("20").id("21").name("get").shared(true).timestamp((TODAY + 250) * 1000L).duration(50L * 1000L).kind(Kind.SERVER).localEndpoint(backend).build(), Span.newBuilder().traceId(traceId).parentId("21").id("22").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(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 10 with TODAY

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

the class ITDependencies method oneway.

/**
 * Span starts on one host and ends on the other. In both cases, a response is neither sent nor
 * received.
 */
@Test
protected void oneway(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("10").timestamp((TODAY + 50) * 1000).kind(Kind.CLIENT).localEndpoint(frontend).build(), Span.newBuilder().traceId(traceId).id("10").shared(true).timestamp((TODAY + 100) * 1000).kind(Kind.SERVER).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)

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