Search in sources :

Example 21 with Endpoint

use of zipkin.Endpoint in project zipkin by openzipkin.

the class DependenciesTest method notInstrumentedClientAndServer.

/**
   * This test confirms that the span store can detect dependency indicated by SERVER_ADDR and
   * CLIENT_ADDR. In some cases an RPC call is made where one of the two services is not
   * instrumented. However, if the other service is able to emit "sa" or "ca" annotation with a
   * service name, the link can still be constructed.
   *
   * span1: CA SR SS: Dependency 1 by a not-instrumented client span2: intermediate call span3: CS
   * CR SA: Dependency 2 to a not-instrumented server
   */
@Test
public void notInstrumentedClientAndServer() {
    Endpoint someClient = Endpoint.create("some-client", 172 << 24 | 17 << 16 | 4);
    List<Span> trace = asList(Span.builder().traceId(20L).id(20L).name("get").timestamp(TODAY * 1000).duration(350L * 1000).addAnnotation(Annotation.create(TODAY * 1000, SERVER_RECV, WEB_ENDPOINT)).addAnnotation(Annotation.create((TODAY + 350) * 1000, SERVER_SEND, WEB_ENDPOINT)).addBinaryAnnotation(BinaryAnnotation.address(CLIENT_ADDR, someClient)).build(), Span.builder().traceId(20L).parentId(20L).id(21L).name("get").timestamp((TODAY + 50L) * 1000).duration(250L * 1000).addAnnotation(Annotation.create((TODAY + 50) * 1000, CLIENT_SEND, WEB_ENDPOINT)).addAnnotation(Annotation.create((TODAY + 100) * 1000, SERVER_RECV, APP_ENDPOINT)).addAnnotation(Annotation.create((TODAY + 250) * 1000, SERVER_SEND, APP_ENDPOINT)).addAnnotation(Annotation.create((TODAY + 300) * 1000, CLIENT_RECV, WEB_ENDPOINT)).build(), Span.builder().traceId(20L).parentId(21L).id(22L).name("get").timestamp((TODAY + 150L) * 1000).duration(50L * 1000).addAnnotation(Annotation.create((TODAY + 150) * 1000, CLIENT_SEND, APP_ENDPOINT)).addAnnotation(Annotation.create((TODAY + 200) * 1000, CLIENT_RECV, APP_ENDPOINT)).addBinaryAnnotation(BinaryAnnotation.address(CLIENT_ADDR, APP_ENDPOINT)).addBinaryAnnotation(BinaryAnnotation.address(SERVER_ADDR, DB_ENDPOINT)).build());
    processDependencies(trace);
    assertThat(store().getDependencies(TODAY + 1000L, null)).containsOnly(DependencyLink.create("some-client", "web", 1), DependencyLink.create("web", "app", 1), DependencyLink.create("app", "db", 1));
}
Also used : Endpoint(zipkin.Endpoint) Span(zipkin.Span) Test(org.junit.Test)

Example 22 with Endpoint

use of zipkin.Endpoint in project zipkin by openzipkin.

the class CorrectForClockSkewTest method childSpan.

static Span childSpan(Span parent, Endpoint to, long begin, long duration, long skew) {
    long spanId = parent.id + 1;
    Endpoint from = parent.annotations.get(0).endpoint;
    long networkLatency = 10L;
    return Span.builder().traceId(parent.traceId).id(spanId).parentId(parent.id).name("span" + spanId).timestamp(begin).addAnnotation(Annotation.create(begin, CLIENT_SEND, from)).addAnnotation(Annotation.create(begin + skew + networkLatency, SERVER_RECV, to)).addAnnotation(Annotation.create(begin + skew + duration - networkLatency, SERVER_SEND, to)).addAnnotation(Annotation.create(begin + duration, CLIENT_RECV, from)).build();
}
Also used : Endpoint(zipkin.Endpoint)

Example 23 with Endpoint

use of zipkin.Endpoint in project zipkin by openzipkin.

the class CorrectForClockSkewTest method ipsMatch_falseWhenIpv6Different.

@Test
public void ipsMatch_falseWhenIpv6Different() throws UnknownHostException {
    Endpoint different = ipv6.toBuilder().ipv6(Inet6Address.getByName("2001:db8::c002").getAddress()).build();
    assertFalse(ipsMatch(different, ipv6));
    assertFalse(ipsMatch(ipv6, different));
}
Also used : Endpoint(zipkin.Endpoint) Test(org.junit.Test)

Example 24 with Endpoint

use of zipkin.Endpoint in project zipkin by openzipkin.

the class CorrectForClockSkewTest method ipsMatch_falseWhenNoIp.

@Test
public void ipsMatch_falseWhenNoIp() {
    Endpoint noIp = Endpoint.builder().serviceName("foo").build();
    assertFalse(ipsMatch(noIp, ipv4));
    assertFalse(ipsMatch(noIp, ipv6));
    assertFalse(ipsMatch(ipv4, noIp));
    assertFalse(ipsMatch(ipv6, noIp));
}
Also used : Endpoint(zipkin.Endpoint) Test(org.junit.Test)

Aggregations

Endpoint (zipkin.Endpoint)24 Test (org.junit.Test)20 Span (zipkin.Span)16 BinaryAnnotation (zipkin.BinaryAnnotation)8 Annotation (zipkin.Annotation)6 ArrayList (java.util.ArrayList)3 List (java.util.List)2 QueryRequest (zipkin.storage.QueryRequest)2 SpanStoreTest (zipkin.storage.SpanStoreTest)2 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 Arrays.asList (java.util.Arrays.asList)1 Collections.emptyList (java.util.Collections.emptyList)1 LinkedHashMap (java.util.LinkedHashMap)1 Collectors.toList (java.util.stream.Collectors.toList)1 Buffer (okio.Buffer)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Condition (org.jooq.Condition)1