Search in sources :

Example 1 with SpanId

use of org.apache.cxf.systest.brave.BraveTestSupport.SpanId in project cxf by apache.

the class BraveTracingTest method testThatNewInnerSpanIsCreated.

@Test
public void testThatNewInnerSpanIsCreated() throws Exception {
    final Random random = new Random();
    final SpanId spanId = new SpanId().traceId(random.nextLong()).parentId(random.nextLong()).spanId(random.nextLong()).sampled(true);
    final Map<String, List<String>> headers = new HashMap<>();
    headers.put(SPAN_ID_NAME, Arrays.asList(Long.toString(spanId.spanId())));
    headers.put(TRACE_ID_NAME, Arrays.asList(Long.toString(spanId.traceId())));
    headers.put(SAMPLED_NAME, Arrays.asList(Boolean.toString(spanId.sampled())));
    headers.put(PARENT_SPAN_ID_NAME, Arrays.asList(Long.toString(spanId.parentId())));
    final BookStoreService service = createJaxWsService(headers);
    assertThat(service.getBooks().size(), equalTo(2));
    assertThat(TestSpanReporter.getAllSpans().size(), equalTo(2));
    assertThat(TestSpanReporter.getAllSpans().get(0).name(), equalTo("get books"));
    assertThat(TestSpanReporter.getAllSpans().get(1).name(), equalTo("post /bookstore"));
}
Also used : Random(java.util.Random) HashMap(java.util.HashMap) BookStoreService(org.apache.cxf.systest.jaxws.tracing.BookStoreService) List(java.util.List) SpanId(org.apache.cxf.systest.brave.BraveTestSupport.SpanId) Test(org.junit.Test)

Example 2 with SpanId

use of org.apache.cxf.systest.brave.BraveTestSupport.SpanId in project cxf by apache.

the class BraveTracingTest method testThatCurrentSpanIsAnnotatedWithKeyValue.

@Test
public void testThatCurrentSpanIsAnnotatedWithKeyValue() {
    final SpanId spanId = fromRandom();
    final Response r = withTrace(createWebClient("/bookstore/book/1"), spanId).get();
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertThat(TestSpanReporter.getAllSpans().size(), equalTo(1));
    assertThat(TestSpanReporter.getAllSpans().get(0).name(), equalTo("get /bookstore/book/1"));
    assertThat(TestSpanReporter.getAllSpans().get(0).tags(), hasEntry("book-id", "1"));
}
Also used : Response(javax.ws.rs.core.Response) SpanId(org.apache.cxf.systest.brave.BraveTestSupport.SpanId) Test(org.junit.Test)

Example 3 with SpanId

use of org.apache.cxf.systest.brave.BraveTestSupport.SpanId in project cxf by apache.

the class BraveTracingTest method testThatParallelSpanIsAnnotatedWithTimeline.

@Test
public void testThatParallelSpanIsAnnotatedWithTimeline() {
    final SpanId spanId = fromRandom();
    final Response r = withTrace(createWebClient("/bookstore/process"), spanId).put("");
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertThat(TestSpanReporter.getAllSpans().size(), equalTo(2));
    assertThat(TestSpanReporter.getAllSpans(), hasSpan("processing books", hasItem("Processing started")));
    assertThat(TestSpanReporter.getAllSpans(), hasSpan("put /bookstore/process"));
}
Also used : Response(javax.ws.rs.core.Response) SpanId(org.apache.cxf.systest.brave.BraveTestSupport.SpanId) Test(org.junit.Test)

Example 4 with SpanId

use of org.apache.cxf.systest.brave.BraveTestSupport.SpanId in project cxf by apache.

the class BraveTracingTest method testThatNewInnerSpanIsCreated.

@Test
public void testThatNewInnerSpanIsCreated() {
    final SpanId spanId = fromRandom();
    final Response r = withTrace(createWebClient("/bookstore/books"), spanId).get();
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertThat(TestSpanReporter.getAllSpans().size(), equalTo(2));
    assertThat(TestSpanReporter.getAllSpans().get(0).name(), equalTo("get books"));
    assertThat(TestSpanReporter.getAllSpans().get(1).name(), equalTo("get /bookstore/books"));
}
Also used : Response(javax.ws.rs.core.Response) SpanId(org.apache.cxf.systest.brave.BraveTestSupport.SpanId) Test(org.junit.Test)

Example 5 with SpanId

use of org.apache.cxf.systest.brave.BraveTestSupport.SpanId in project cxf by apache.

the class BraveTracingTest method testThatOuterSpanIsCreatedUsingAsyncInvocation.

@Test
public void testThatOuterSpanIsCreatedUsingAsyncInvocation() {
    final SpanId spanId = fromRandom();
    final Response r = withTrace(createWebClient("/bookstore/books/async/notrace"), spanId).get();
    assertEquals(Status.OK.getStatusCode(), r.getStatus());
    assertThat(TestSpanReporter.getAllSpans().size(), equalTo(1));
    assertThat(TestSpanReporter.getAllSpans().get(0).name(), equalTo("get /bookstore/books/async/notrace"));
}
Also used : Response(javax.ws.rs.core.Response) SpanId(org.apache.cxf.systest.brave.BraveTestSupport.SpanId) Test(org.junit.Test)

Aggregations

SpanId (org.apache.cxf.systest.brave.BraveTestSupport.SpanId)7 Test (org.junit.Test)7 Response (javax.ws.rs.core.Response)6 HashMap (java.util.HashMap)1 List (java.util.List)1 Random (java.util.Random)1 BookStoreService (org.apache.cxf.systest.jaxws.tracing.BookStoreService)1