You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2015/10/16 03:29:07 UTC
cxf git commit: CXF-6643: Upgraded Apache HTrace to 4.0 release
branch. Minor fixes and adding more tests.
Repository: cxf
Updated Branches:
refs/heads/master a1d59ed7a -> e27ccedf7
CXF-6643: Upgraded Apache HTrace to 4.0 release branch. Minor fixes and adding more tests.
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e27ccedf
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e27ccedf
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e27ccedf
Branch: refs/heads/master
Commit: e27ccedf71d44ca5b20296e8401eef302311ebff
Parents: a1d59ed
Author: reta <dr...@gmail.com>
Authored: Thu Oct 15 21:28:53 2015 -0400
Committer: reta <dr...@gmail.com>
Committed: Thu Oct 15 21:28:53 2015 -0400
----------------------------------------------------------------------
.../tracing/htrace/AbstractHTraceProvider.java | 2 +-
.../cxf/tracing/htrace/HTraceTracerContext.java | 6 +++++-
.../cxf/systest/jaxrs/tracing/BookStore.java | 20 ++++++++++++++++++++
.../jaxrs/tracing/htrace/HTraceTracingTest.java | 16 ++++++++++++++++
4 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/e27ccedf/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
index 76ca4f3..952b12f 100644
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/AbstractHTraceProvider.java
@@ -109,7 +109,7 @@ public abstract class AbstractHTraceProvider extends AbstractTracingProvider {
try {
return SpanId.fromString(value.get(0));
} catch (NumberFormatException ex) {
- LOG.log(Level.FINE, String.format("Unable to parse '%s' header value to long number", header), ex);
+ LOG.log(Level.FINE, String.format("Unable to parse '%s' header value to Span Id", header), ex);
}
}
return defaultValue;
http://git-wip-us.apache.org/repos/asf/cxf/blob/e27ccedf/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/HTraceTracerContext.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/HTraceTracerContext.java b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/HTraceTracerContext.java
index cc8b2c9..52a43f9 100644
--- a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/HTraceTracerContext.java
+++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/tracing/htrace/HTraceTracerContext.java
@@ -47,14 +47,18 @@ public class HTraceTracerContext implements TracerContext {
@Override
public <T> T continueSpan(final Traceable<T> traceable) throws Exception {
+ boolean attached = false;
if (!isTracing() && continuationScope != null) {
continuationScope.reattach();
+ attached = true;
}
try {
return traceable.call(new HTraceTracerContext(tracer));
} finally {
- continuationScope.detach();
+ if (continuationScope != null && attached) {
+ continuationScope.detach();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/e27ccedf/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java
index 7df41da..89bdab1 100644
--- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java
+++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java
@@ -114,6 +114,26 @@ public class BookStore {
}
@GET
+ @Path("/books/pseudo-async")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Collection<Book> getBooksPseudoAsync() throws Exception {
+ return tracer.continueSpan(new Traceable<Collection<Book>>() {
+ @Override
+ public Collection<Book> call(final TracerContext context) throws Exception {
+ return tracer.wrap("Processing books", new Traceable<Collection<Book>>() {
+ @Override
+ public Collection<Book> call(final TracerContext context) throws Exception {
+ return Arrays.asList(
+ new Book("Apache CXF in Action", UUID.randomUUID().toString()),
+ new Book("Mastering Apache CXF", UUID.randomUUID().toString())
+ );
+ }
+ }).call();
+ }
+ });
+ }
+
+ @GET
@Path("/book/{id}")
@Produces(MediaType.APPLICATION_JSON)
public Book getBook(@PathParam("id") final String id) {
http://git-wip-us.apache.org/repos/asf/cxf/blob/e27ccedf/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
----------------------------------------------------------------------
diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
index 9c88ffa..6b59144 100644
--- a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
+++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
@@ -272,6 +272,22 @@ public class HTraceTracingTest extends AbstractBusClientServerTestBase {
assertThat(TestSpanReceiver.getAllSpans().get(2).getDescription(), equalTo("test span"));
}
+ @Test
+ public void testThatInnerSpanIsCreatedUsingPseudoAsyncInvocation() {
+ final SpanId spanId = SpanId.fromRandom();
+
+ final Response r = createWebClient("/bookstore/books/pseudo-async")
+ .header(TracerHeaders.DEFAULT_HEADER_SPAN_ID, spanId.toString())
+ .get();
+ assertEquals(Status.OK.getStatusCode(), r.getStatus());
+
+ assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(2));
+ assertThat(TestSpanReceiver.getAllSpans().get(1).getDescription(), equalTo("GET bookstore/books/pseudo-async"));
+ assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Processing books"));
+
+ assertThat((String)r.getHeaders().getFirst(TracerHeaders.DEFAULT_HEADER_SPAN_ID), equalTo(spanId.toString()));
+ }
+
protected WebClient createWebClient(final String url, final Object ... providers) {
return WebClient
.create("http://localhost:" + PORT + url, Arrays.asList(providers))