Search in sources :

Example 6 with Endpoint

use of zipkin2.Endpoint in project brave by openzipkin.

the class TracerTest method localServiceName_ignoredWhenGivenLocalEndpoint.

@Test
public void localServiceName_ignoredWhenGivenLocalEndpoint() {
    Endpoint endpoint = Endpoint.newBuilder().serviceName("my-bar").build();
    tracer = Tracing.newBuilder().localServiceName("my-foo").endpoint(endpoint).build().tracer();
    assertThat(tracer).extracting("recorder.spanMap.endpoint").containsExactly(endpoint);
}
Also used : Endpoint(zipkin2.Endpoint) Test(org.junit.Test)

Example 7 with Endpoint

use of zipkin2.Endpoint in project brave by openzipkin.

the class PlatformTest method localEndpoint_provisionsOnce.

/**
 * Getting an endpoint is expensive. This tests it is provisioned only once.
 *
 * test inspired by dagger.internal.DoubleCheckTest
 */
@Test
public void localEndpoint_provisionsOnce() throws Exception {
    // create all the tasks up front so that they are executed with no delay
    List<Callable<Endpoint>> tasks = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        tasks.add(() -> platform.endpoint());
    }
    ExecutorService executor = Executors.newFixedThreadPool(tasks.size());
    List<Future<Endpoint>> futures = executor.invokeAll(tasks);
    // check there's only a single unique endpoint returned
    Set<Object> results = Sets.newIdentityHashSet();
    for (Future<Endpoint> future : futures) {
        results.add(future.get());
    }
    assertThat(results).hasSize(1);
    executor.shutdownNow();
}
Also used : Endpoint(zipkin2.Endpoint) ArrayList(java.util.ArrayList) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) Callable(java.util.concurrent.Callable) Endpoint(zipkin2.Endpoint) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 8 with Endpoint

use of zipkin2.Endpoint in project brave by openzipkin.

the class ITHttpServer method createsChildSpan.

/**
 * This ensures thread-state is propagated from trace interceptors to user code. The endpoint
 * "/child" is expected to create a local span. When this works, it should be a child of the
 * "current span", in this case the span representing an incoming server request. When thread
 * state isn't managed properly, the child span will appear as a new trace.
 */
@Test
public void createsChildSpan() throws Exception {
    get("/child");
    Span child = takeSpan();
    Span parent = takeSpan();
    assertThat(parent.traceId()).isEqualTo(child.traceId());
    assertThat(parent.id()).isEqualTo(child.parentId());
    assertThat(parent.timestamp()).isLessThan(child.timestamp());
    assertThat(parent.duration()).isGreaterThan(child.duration());
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 9 with Endpoint

use of zipkin2.Endpoint in project brave by openzipkin.

the class ITHttpServer method reportsClientAddress_XForwardedFor.

@Test
public void reportsClientAddress_XForwardedFor() throws Exception {
    get(new Request.Builder().url(url("/foo")).header("X-Forwarded-For", "1.2.3.4").build());
    Span span = takeSpan();
    assertThat(span.remoteEndpoint()).extracting(Endpoint::ipv4).contains("1.2.3.4");
}
Also used : Span(zipkin2.Span) Test(org.junit.Test)

Example 10 with Endpoint

use of zipkin2.Endpoint in project brave by openzipkin.

the class MutableSpanTest method remoteEndpoint.

@Test
public void remoteEndpoint() {
    MutableSpan span = newSpan();
    Endpoint endpoint = Endpoint.newBuilder().serviceName("server").build();
    span.kind(CLIENT);
    span.remoteEndpoint(endpoint);
    span.start(1L);
    span.finish(2L);
    assertThat(span.toSpan().remoteEndpoint()).isEqualTo(endpoint);
}
Also used : Endpoint(zipkin2.Endpoint) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 Endpoint (zipkin2.Endpoint)7 Span (zipkin2.Span)5 Endpoint (org.jboss.remoting3.Endpoint)2 Access (org.openstack4j.model.identity.v2.Access)2 Tracing (brave.Tracing)1 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1 CrnkClient (io.crnk.client.CrnkClient)1 Task (io.crnk.monitor.brave.mock.models.Task)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 NetworkInterface (java.net.NetworkInterface)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Callable (java.util.concurrent.Callable)1