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);
}
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();
}
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());
}
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");
}
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);
}
Aggregations