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 2019/01/06 15:49:52 UTC

[cxf] branch 3.2.x-fixes updated: CXF-7855: Update the Brave/OpenTracing/HTrace documentation to include more code snippets

This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.2.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/3.2.x-fixes by this push:
     new 0411322  CXF-7855: Update the Brave/OpenTracing/HTrace documentation to include more code snippets
0411322 is described below

commit 04113220fad80a8d8c24ad612af066fb0c88350c
Author: reta <dr...@gmail.com>
AuthorDate: Sat Jan 5 18:39:43 2019 -0500

    CXF-7855: Update the Brave/OpenTracing/HTrace documentation to include more code snippets
---
 .../samples/jax_rs/tracing_brave/README.txt        | 11 ++-
 .../release/samples/jax_rs/tracing_brave/pom.xml   | 97 ++++++++++++++++++++++
 .../tracing/client/ApacheHttpAsyncClient.java      | 76 +++++++++++++++++
 .../jaxrs/tracing/client/ApacheHttpClient.java     | 51 ++++++++++++
 .../demo/jaxrs/tracing/client/OkHttp3Client.java   | 48 +++++++++++
 .../java/demo/jaxrs/tracing/server/Catalog.java    | 40 +++++++++
 .../samples/jax_rs/tracing_opentracing/README.txt  |  4 +
 .../samples/jax_rs/tracing_opentracing/pom.xml     | 15 ++++
 ...CatalogApplication.java => GoogleBooksApi.java} | 32 ++-----
 .../java/demo/jaxrs/tracing/server/Catalog.java    | 23 +++++
 .../jaxrs/tracing/server/CatalogApplication.java   |  2 +-
 .../java/demo/jaxrs/tracing/server/Server.java     |  4 +-
 .../jax_rs/tracing_opentracing_camel/README.txt    |  2 +-
 .../jax_rs/tracing_opentracing_osgi/README.txt     |  2 +-
 .../cxf/tracing/brave/BraveTracerContext.java      | 16 ++++
 .../cxf/tracing/brave/BraveTracerContextTest.java  | 63 ++++++++++++++
 .../cxf/tracing/htrace/HTraceTracerContext.java    | 11 +++
 .../tracing/htrace/HTraceTracerContextTest.java    | 43 +++++-----
 integration/tracing/tracing-opentracing/pom.xml    |  5 ++
 .../tracing/opentracing/OpenTracingContext.java    | 11 +++
 .../opentracing/OpenTracingContextTest.java        | 46 +++++-----
 parent/pom.xml                                     |  6 ++
 .../java/org/apache/cxf/tracing/TracerContext.java | 10 +++
 23 files changed, 551 insertions(+), 67 deletions(-)

diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave/README.txt b/distribution/src/main/release/samples/jax_rs/tracing_brave/README.txt
index 37a911e..8dd1043 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_brave/README.txt
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/README.txt
@@ -9,6 +9,10 @@ following services at URL http://localhost:9000/catalog:
  - POST to http://localhost:9000/catalog 
  - GET to URL http://localhost:9000/catalog/<id>
  - DELETE to URL http://localhost:9000/catalog/<id>
+ - GET to URL http://localhost:9000/catalog/search?q=<query>
+ 
+The last endpoint calls public Google Books API in order to search the books by 
+query criteria. It demonstrates the integration with native Brave instrumentation.
  
 Building and running the demo using Maven
 ---------------------------------------
@@ -26,7 +30,12 @@ Using either UNIX or Windows:
   mvn install
   mvn -Pserver  (from one command line window)
   mvn -Pclient  (from a second command line window)
-    
+  
+Alternatively, there are different client examples available (Apache HttpClient, OkHttp3, Apache HttpAsyncClient):
+  
+  mvn -Papache  (from a second command line window)
+  mvn -Pokhttp3  (from a second command line window)
+  mvn -Pasync  (from a second command line window)
 
 To remove the target dir, run mvn clean".
 
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave/pom.xml b/distribution/src/main/release/samples/jax_rs/tracing_brave/pom.xml
index 7efe7ad..b4cd7d8 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_brave/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/pom.xml
@@ -78,6 +78,75 @@
                 </plugins>
             </build>
         </profile>
+        <profile>
+            <id>apache</id>
+            <build>
+                <defaultGoal>test</defaultGoal>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>exec-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>java</goal>
+                                </goals>
+                                <configuration>
+                                    <mainClass>demo.jaxrs.tracing.client.ApacheHttpClient</mainClass>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>async</id>
+            <build>
+                <defaultGoal>test</defaultGoal>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>exec-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>java</goal>
+                                </goals>
+                                <configuration>
+                                    <mainClass>demo.jaxrs.tracing.client.ApacheHttpAsyncClient</mainClass>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>okhttp3</id>
+            <build>
+                <defaultGoal>test</defaultGoal>
+                <plugins>
+                    <plugin>
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>exec-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>java</goal>
+                                </goals>
+                                <configuration>
+                                    <mainClass>demo.jaxrs.tracing.client.OkHttp3Client</mainClass>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
     </profiles>
     <dependencies>
         <dependency>
@@ -137,5 +206,33 @@
             <artifactId>brave-context-slf4j</artifactId>
             <version>5.4.2</version>
         </dependency>
+        <dependency>
+            <groupId>io.zipkin.brave</groupId>
+            <artifactId>brave-instrumentation-httpclient</artifactId>
+            <version>5.4.2</version>
+        </dependency>
+        <dependency>
+            <groupId>io.zipkin.brave</groupId>
+            <artifactId>brave-instrumentation-httpasyncclient</artifactId>
+            <version>5.4.2</version>
+        </dependency>
+        <dependency>
+            <groupId>io.zipkin.brave</groupId>
+            <artifactId>brave-instrumentation-okhttp3</artifactId>
+            <version>5.4.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpasyncclient</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>3.12.1</version>
+        </dependency>
     </dependencies>
 </project>
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/ApacheHttpAsyncClient.java b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/ApacheHttpAsyncClient.java
new file mode 100644
index 0000000..77d5115
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/ApacheHttpAsyncClient.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package demo.jaxrs.tracing.client;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.concurrent.FutureCallback;
+import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
+import org.apache.http.util.EntityUtils;
+
+import brave.httpasyncclient.TracingHttpAsyncClientBuilder;
+import demo.jaxrs.tracing.server.CatalogTracing;
+
+public final class ApacheHttpAsyncClient {
+    private ApacheHttpAsyncClient() {
+    }
+
+    public static void main(final String[] args) throws Exception {
+        try (final CatalogTracing tracing = new CatalogTracing("catalog-client")) {
+            final CloseableHttpAsyncClient httpclient = TracingHttpAsyncClientBuilder
+                .create(tracing.getHttpTracing())
+                .build();
+        
+            final HttpGet request = new HttpGet("http://localhost:9000/catalog");
+            request.setHeader("Accept", "application/json");
+            
+            httpclient.start();
+            final Future<HttpResponse> response = httpclient.execute(request,
+                new FutureCallback<HttpResponse>() {
+                    @Override
+                    public void completed(HttpResponse result) {
+                        try {
+                            System.out.println(EntityUtils.toString(result.getEntity(), StandardCharsets.UTF_8));
+                        } catch (final IOException ex) {
+                            System.out.println(ex);
+                        }
+                    }
+
+                    @Override
+                    public void failed(Exception ex) {
+                        System.out.println(ex);
+                    }
+
+                    @Override
+                    public void cancelled() {
+                    }
+                }
+            );
+            
+            response.get(1000, TimeUnit.MILLISECONDS);
+            httpclient.close();
+        }
+    }
+}
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/ApacheHttpClient.java b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/ApacheHttpClient.java
new file mode 100644
index 0000000..7869272
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/ApacheHttpClient.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package demo.jaxrs.tracing.client;
+
+import java.nio.charset.StandardCharsets;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.util.EntityUtils;
+
+import brave.httpclient.TracingHttpClientBuilder;
+import demo.jaxrs.tracing.server.CatalogTracing;
+
+public final class ApacheHttpClient {
+    private ApacheHttpClient() {
+    }
+
+    public static void main(final String[] args) throws Exception {
+        try (final CatalogTracing tracing = new CatalogTracing("catalog-client")) {
+            final CloseableHttpClient httpclient = TracingHttpClientBuilder
+                    .create(tracing.getHttpTracing())
+                    .build();
+        
+            final HttpGet request = new HttpGet("http://localhost:9000/catalog");
+            request.setHeader("Accept", "application/json");
+            
+            final HttpResponse response = httpclient.execute(request);
+            System.out.println(EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8));
+            
+            httpclient.close();
+        }
+    }
+}
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/OkHttp3Client.java b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/OkHttp3Client.java
new file mode 100644
index 0000000..97eb753
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/OkHttp3Client.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package demo.jaxrs.tracing.client;
+
+import brave.okhttp3.TracingCallFactory;
+import demo.jaxrs.tracing.server.CatalogTracing;
+import okhttp3.Call;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+
+public final class OkHttp3Client {
+    private OkHttp3Client() {
+    }
+
+    public static void main(final String[] args) throws Exception {
+        try (final CatalogTracing tracing = new CatalogTracing("catalog-client")) {
+            final OkHttpClient client = new OkHttpClient();
+            final Call.Factory factory = TracingCallFactory.create(tracing.getHttpTracing(), client);
+            
+            final Request request = new Request.Builder()
+                .url("http://localhost:9000/catalog")
+                .header("Accept", "application/json")
+                .build();
+
+            try (final Response response = factory.newCall(request).execute()) {
+                System.out.println(response.body().string());
+            }
+        }
+    }
+}
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/Catalog.java b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/Catalog.java
index 141effc..eaba39c 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/Catalog.java
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/Catalog.java
@@ -21,6 +21,9 @@ package demo.jaxrs.tracing.server;
 
 
 import java.io.IOException;
+import java.io.StringReader;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
 import java.util.UUID;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -36,6 +39,7 @@ import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.container.AsyncResponse;
 import javax.ws.rs.container.Suspended;
 import javax.ws.rs.core.Context;
@@ -45,6 +49,14 @@ import javax.ws.rs.core.UriInfo;
 
 import org.apache.cxf.tracing.Traceable;
 import org.apache.cxf.tracing.TracerContext;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.util.EntityUtils;
+
+import brave.http.HttpTracing;
+import brave.httpclient.TracingHttpClientBuilder;
 
 @Path("/catalog")
 public class Catalog {
@@ -120,6 +132,34 @@ public class Catalog {
         return book;
     }
 
+    @GET
+    @Path("/search")
+    @Produces(MediaType.APPLICATION_JSON)
+    public JsonObject search(@QueryParam("q") final String query, @Context final TracerContext tracing) throws Exception {
+        final CloseableHttpClient httpclient = TracingHttpClientBuilder
+            .create(tracing.unwrap(HttpTracing.class))
+            .build();
+    
+        try {
+            final URI uri = new URIBuilder("https://www.googleapis.com/books/v1/volumes")
+                .setParameter("q", query)
+                .build();
+            
+            final HttpGet request = new HttpGet(uri);
+            request.setHeader("Accept", "application/json");
+            
+            final HttpResponse response = httpclient.execute(request);
+            final String data = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
+            try (final StringReader reader = new StringReader(data)) {
+                return Json.createReader(reader).readObject();
+            }
+        } finally {
+            httpclient.close();
+        }
+    }
+
+    
+
     @DELETE
     @Path("/{id}")
     @Produces(MediaType.APPLICATION_JSON)
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/README.txt b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/README.txt
index 81aeffd..431d124 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/README.txt
+++ b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/README.txt
@@ -9,6 +9,10 @@ following services at URL http://localhost:9000/catalog:
  - POST to http://localhost:9000/catalog 
  - GET to http://localhost:9000/catalog/<id> 
  - DELETE to URL http://localhost:9000/catalog/<id> 
+ - GET to URL http://localhost:9000/catalog/search?q=<query>
+
+The last endpoint calls public Google Books API in order to search the books by 
+query criteria. It demonstrates the integration with native OpenTracing instrumentation.
 
 Building and running the demo using Maven
 ---------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/pom.xml b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/pom.xml
index e6d7de4..27de9fa 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/pom.xml
@@ -131,5 +131,20 @@
             <groupId>com.uber.jaeger</groupId>
             <artifactId>jaeger-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>io.github.openfeign</groupId>
+            <artifactId>feign-core</artifactId>
+            <version>9.5.0</version>
+        </dependency>
+        <dependency>
+            <groupId>io.github.openfeign</groupId>
+            <artifactId>feign-httpclient</artifactId>
+            <version>9.5.0</version>
+        </dependency>
+        <dependency>
+            <groupId>io.github.openfeign.opentracing</groupId>
+            <artifactId>feign-opentracing</artifactId>
+            <version>0.0.5</version>
+        </dependency>
     </dependencies>
 </project>
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/GoogleBooksApi.java
similarity index 55%
copy from distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
copy to distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/GoogleBooksApi.java
index 9c19a79..f5e0080 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
+++ b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/GoogleBooksApi.java
@@ -17,29 +17,15 @@
  * under the License.
  */
 
-package demo.jaxrs.tracing.server;
+package demo.jaxrs.tracing;
 
+import feign.Headers;
+import feign.Param;
+import feign.RequestLine;
+import feign.Response;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.core.Application;
-
-import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
-import org.apache.cxf.tracing.opentracing.OpenTracingFeature;
-
-@ApplicationPath("/")
-public class CatalogApplication extends Application {
-    @Override
-    public Set<Object> getSingletons() {
-        return new HashSet<>(
-            Arrays.asList(
-                new Catalog(),
-                new OpenTracingFeature(),
-                new JsrJsonpProvider()
-            )
-        );
-    }
+public interface GoogleBooksApi {
+    @RequestLine("GET /books/v1/volumes?q={q}")
+    @Headers("Accept: application/json")
+    Response search(@Param("q") String query);
 }
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/Catalog.java b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/Catalog.java
index 141effc..2e1f880 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/Catalog.java
+++ b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/Catalog.java
@@ -21,6 +21,7 @@ package demo.jaxrs.tracing.server;
 
 
 import java.io.IOException;
+import java.io.Reader;
 import java.util.UUID;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -36,6 +37,7 @@ import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.container.AsyncResponse;
 import javax.ws.rs.container.Suspended;
 import javax.ws.rs.core.Context;
@@ -46,6 +48,12 @@ import javax.ws.rs.core.UriInfo;
 import org.apache.cxf.tracing.Traceable;
 import org.apache.cxf.tracing.TracerContext;
 
+import demo.jaxrs.tracing.GoogleBooksApi;
+import feign.Feign;
+import feign.httpclient.ApacheHttpClient;
+import feign.opentracing.TracingClient;
+import io.opentracing.Tracer;
+
 @Path("/catalog")
 public class Catalog {
     private final ExecutorService executor = Executors.newFixedThreadPool(2);
@@ -130,6 +138,21 @@ public class Catalog {
 
         return Response.ok().build();
     }
+    
+    @GET
+    @Path("/search")
+    @Produces(MediaType.APPLICATION_JSON)
+    public JsonObject search(@QueryParam("q") final String query, @Context final TracerContext tracing) throws Exception {
+        final GoogleBooksApi api = Feign
+            .builder()
+            .client(new TracingClient(new ApacheHttpClient(), tracing.unwrap(Tracer.class)))
+            .target(GoogleBooksApi.class, "https://www.googleapis.com");
+     
+        final feign.Response response = api.search(query);
+        try (final Reader reader = response.body().asReader()) {
+            return Json.createReader(reader).readObject();
+        }
+    }
 }
 
 
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
index 9c19a79..25e6264 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
+++ b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
@@ -28,7 +28,7 @@ import javax.ws.rs.ApplicationPath;
 import javax.ws.rs.core.Application;
 
 import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
-import org.apache.cxf.tracing.opentracing.OpenTracingFeature;
+import org.apache.cxf.tracing.opentracing.jaxrs.OpenTracingFeature;
 
 @ApplicationPath("/")
 public class CatalogApplication extends Application {
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/Server.java b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/Server.java
index 402637e..3966f1d 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/Server.java
+++ b/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/Server.java
@@ -22,6 +22,8 @@ package demo.jaxrs.tracing.server;
 import com.uber.jaeger.Configuration;
 import com.uber.jaeger.samplers.ConstSampler;
 
+import demo.jaxrs.tracing.Slf4jLogSender;
+
 import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
@@ -44,7 +46,7 @@ public class Server {
 
         final Tracer tracer = new Configuration("tracer-server", 
                 new Configuration.SamplerConfiguration(ConstSampler.TYPE, 1),
-                new Configuration.ReporterConfiguration()
+                new Configuration.ReporterConfiguration(new Slf4jLogSender())
             ).getTracer();
         GlobalTracer.register(tracer);
         
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_opentracing_camel/README.txt b/distribution/src/main/release/samples/jax_rs/tracing_opentracing_camel/README.txt
index d36de80..b57fe47 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_opentracing_camel/README.txt
+++ b/distribution/src/main/release/samples/jax_rs/tracing_opentracing_camel/README.txt
@@ -14,7 +14,7 @@ following REST(ful) endpoints are available:
 To collect the traces, please run Jaeger distributed tracer components, the
 simplest way would be using Docker:
 
-  docker run --rm -it --network=host jaegertracing/all-in-one
+  docker run --rm -it --network=host -p 16686:16686 -p 14268:14268 jaegertracing/all-in-one
 
 The following sample traces should be available in Jaeger UI (available
 be default at http://localhost:16686/search):
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_opentracing_osgi/README.txt b/distribution/src/main/release/samples/jax_rs/tracing_opentracing_osgi/README.txt
index 41a3cad..3fd9c8c 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_opentracing_osgi/README.txt
+++ b/distribution/src/main/release/samples/jax_rs/tracing_opentracing_osgi/README.txt
@@ -85,7 +85,7 @@ You can verify if the CXF JAX-RS OpenTracing Blueprint Demo is installed and sta
 To collect the traces, please run Jaeger distributed tracer components, the
 simplest way would be using Docker:
 
-  docker run --rm -it --network=host jaegertracing/all-in-one
+  docker run --rm -it --network=host -p 16686:16686 -p 14268:14268 jaegertracing/all-in-one
 
 Now, you will be able to access this CXF JAXRS demo service on your Karaf instance at
 
diff --git a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/BraveTracerContext.java b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/BraveTracerContext.java
index 2c6f07e..cf66888 100644
--- a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/BraveTracerContext.java
+++ b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/BraveTracerContext.java
@@ -23,6 +23,7 @@ import java.util.concurrent.Callable;
 import brave.Span;
 import brave.Tracer;
 import brave.Tracer.SpanInScope;
+import brave.Tracing;
 import brave.http.HttpTracing;
 import org.apache.cxf.tracing.Traceable;
 import org.apache.cxf.tracing.TracerContext;
@@ -100,6 +101,21 @@ public class BraveTracerContext implements TracerContext {
         }
     }
     
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> T unwrap(final Class<T> clazz) {
+        if (HttpTracing.class.equals(clazz)) {
+            return (T)brave;
+        } else if (Tracing.class.equals(clazz)) {
+            return (T)brave.tracing();
+        } else if (Tracer.class.equals(clazz)) {
+            return (T)tracer;
+        } else {
+            throw new IllegalArgumentException("The class is '" + clazz
+                  + "'not supported and cannot be unwrapped");
+        }
+    }
+    
     private TraceScope newOrChildSpan(final String description, final Span parent) {
         if (parent == null) { 
             return new TraceScope(brave, tracer.newTrace().name(description).start());
diff --git a/integration/tracing/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/BraveTracerContextTest.java b/integration/tracing/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/BraveTracerContextTest.java
new file mode 100644
index 0000000..36727df
--- /dev/null
+++ b/integration/tracing/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/BraveTracerContextTest.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tracing.brave;
+
+import brave.SpanCustomizer;
+import brave.Tracer;
+import brave.Tracing;
+import brave.http.HttpTracing;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.junit.Assert.assertThat;
+
+public class BraveTracerContextTest {
+    private Tracing brave;
+    private HttpTracing httpTracing;
+    private BraveTracerContext context;
+    
+    @Before
+    public void setUp() {
+        brave = Tracing.newBuilder().localServiceName("myservice").build();
+        httpTracing = HttpTracing.create(brave);
+        context = new BraveTracerContext(httpTracing);
+    }
+    
+    @Test
+    public void testUnwrapTracer() {
+        assertThat(context.unwrap(Tracer.class), sameInstance(brave.tracer()));
+    }
+    
+    @Test
+    public void testUnwrapTracing() {
+        assertThat(context.unwrap(Tracing.class), sameInstance(brave));
+    }
+    
+    @Test
+    public void testUnwrapHttpTracing() {
+        assertThat(context.unwrap(HttpTracing.class), sameInstance(httpTracing));
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void testUnwrapUnsupportedClass() {
+        context.unwrap(SpanCustomizer.class);
+    }
+}
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 0c53f78..01f5f8e 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
@@ -89,6 +89,17 @@ public class HTraceTracerContext implements TracerContext {
             currentSpan.addTimelineAnnotation(message);
         }
     }
+    
+    @Override
+    @SuppressWarnings("unchecked")
+    public <T> T unwrap(Class<T> clazz) {
+        if (Tracer.class.equals(clazz)) {
+            return (T)tracer;
+        } else {
+            throw new IllegalArgumentException("The class is '" + clazz
+                + "'not supported and cannot be unwrapped");
+        }
+    }
 
     private boolean isTracing() {
         return Tracer.getCurrentSpan() != null;
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java b/integration/tracing/tracing-htrace/src/test/java/org/apache/cxf/tracing/htrace/HTraceTracerContextTest.java
similarity index 50%
copy from distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
copy to integration/tracing/tracing-htrace/src/test/java/org/apache/cxf/tracing/htrace/HTraceTracerContextTest.java
index 9c19a79..f9a846f 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
+++ b/integration/tracing/tracing-htrace/src/test/java/org/apache/cxf/tracing/htrace/HTraceTracerContextTest.java
@@ -17,29 +17,34 @@
  * under the License.
  */
 
-package demo.jaxrs.tracing.server;
+package org.apache.cxf.tracing.htrace;
 
+import org.apache.htrace.core.SpanReceiver;
+import org.apache.htrace.core.Tracer;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
+import org.junit.Before;
+import org.junit.Test;
 
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.core.Application;
+import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.junit.Assert.assertThat;
 
-import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
-import org.apache.cxf.tracing.opentracing.OpenTracingFeature;
+public class HTraceTracerContextTest {
+    private HTraceTracerContext context; 
+    private Tracer tracer;
 
-@ApplicationPath("/")
-public class CatalogApplication extends Application {
-    @Override
-    public Set<Object> getSingletons() {
-        return new HashSet<>(
-            Arrays.asList(
-                new Catalog(),
-                new OpenTracingFeature(),
-                new JsrJsonpProvider()
-            )
-        );
+    @Before
+    public void setUp() {
+        tracer = new Tracer.Builder("test").build();
+        context = new HTraceTracerContext(tracer);
+    }
+    
+    @Test
+    public void testUnwrapTracer() {
+        assertThat(context.unwrap(Tracer.class), sameInstance(tracer));
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void testUnwrapUnsupportedClass() {
+        context.unwrap(SpanReceiver.class);
     }
 }
diff --git a/integration/tracing/tracing-opentracing/pom.xml b/integration/tracing/tracing-opentracing/pom.xml
index 4dae62f..a7c54ce 100644
--- a/integration/tracing/tracing-opentracing/pom.xml
+++ b/integration/tracing/tracing-opentracing/pom.xml
@@ -77,6 +77,11 @@
             <artifactId>opentracing-util</artifactId>
         </dependency>
         <dependency>
+            <groupId>io.opentracing</groupId>
+            <artifactId>opentracing-mock</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-jdk14</artifactId>
             <scope>test</scope>
diff --git a/integration/tracing/tracing-opentracing/src/main/java/org/apache/cxf/tracing/opentracing/OpenTracingContext.java b/integration/tracing/tracing-opentracing/src/main/java/org/apache/cxf/tracing/opentracing/OpenTracingContext.java
index 772d685..aa1d474 100644
--- a/integration/tracing/tracing-opentracing/src/main/java/org/apache/cxf/tracing/opentracing/OpenTracingContext.java
+++ b/integration/tracing/tracing-opentracing/src/main/java/org/apache/cxf/tracing/opentracing/OpenTracingContext.java
@@ -97,6 +97,17 @@ public class OpenTracingContext implements TracerContext {
         }
     }
     
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> T unwrap(final Class<T> clazz) {
+        if (Tracer.class.equals(clazz)) {
+            return (T)tracer;
+        } else {
+            throw new IllegalArgumentException("The class is '" + clazz
+                + "'not supported and cannot be unwrapped");
+        }
+    }
+    
     private ActiveSpan newOrChildSpan(final String description, final ActiveSpan parent) {
         if (parent == null) {
             return tracer.buildSpan(description).startActive();
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java b/integration/tracing/tracing-opentracing/src/test/java/org/apache/cxf/tracing/opentracing/OpenTracingContextTest.java
similarity index 50%
copy from distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
copy to integration/tracing/tracing-opentracing/src/test/java/org/apache/cxf/tracing/opentracing/OpenTracingContextTest.java
index 9c19a79..25183c3 100644
--- a/distribution/src/main/release/samples/jax_rs/tracing_opentracing/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
+++ b/integration/tracing/tracing-opentracing/src/test/java/org/apache/cxf/tracing/opentracing/OpenTracingContextTest.java
@@ -16,30 +16,36 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.cxf.tracing.opentracing;
 
-package demo.jaxrs.tracing.server;
+import io.opentracing.ScopeManager;
+import io.opentracing.Tracer;
+import io.opentracing.mock.MockTracer;
 
+import org.junit.Before;
+import org.junit.Test;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
+import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.junit.Assert.assertThat;
 
-import javax.ws.rs.ApplicationPath;
-import javax.ws.rs.core.Application;
+public class OpenTracingContextTest {
+    private OpenTracingContext context; 
+    private Tracer tracer;
 
-import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider;
-import org.apache.cxf.tracing.opentracing.OpenTracingFeature;
-
-@ApplicationPath("/")
-public class CatalogApplication extends Application {
-    @Override
-    public Set<Object> getSingletons() {
-        return new HashSet<>(
-            Arrays.asList(
-                new Catalog(),
-                new OpenTracingFeature(),
-                new JsrJsonpProvider()
-            )
-        );
+    @Before
+    public void setUp() {
+        tracer = new MockTracer();
+        context = new OpenTracingContext(tracer);
+    }
+    
+    @Test
+    public void testUnwrapTracer() {
+        assertThat(context.unwrap(Tracer.class), sameInstance(tracer));
     }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void testUnwrapUnsupportedClass() {
+        context.unwrap(ScopeManager.class);
+    }
+
 }
diff --git a/parent/pom.xml b/parent/pom.xml
index 4e3bfc44..234bcba 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -2599,6 +2599,12 @@
                 <version>${cxf.opentracing.version}</version>
             </dependency>
             <dependency>
+                <groupId>io.opentracing</groupId>
+                <artifactId>opentracing-mock</artifactId>
+                <version>${cxf.opentracing.version}</version>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
                 <groupId>com.uber.jaeger</groupId>
                 <artifactId>jaeger-core</artifactId>
                 <version>${cxf.jaeger.version}</version>
diff --git a/rt/management/src/main/java/org/apache/cxf/tracing/TracerContext.java b/rt/management/src/main/java/org/apache/cxf/tracing/TracerContext.java
index 2d4d38d..21ee90e 100644
--- a/rt/management/src/main/java/org/apache/cxf/tracing/TracerContext.java
+++ b/rt/management/src/main/java/org/apache/cxf/tracing/TracerContext.java
@@ -59,4 +59,14 @@ public interface TracerContext {
      * @param message timeline message
      */
     void timeline(String message);
+    
+    /**
+     * Returns an object of the specified type to allow access to the specific API 
+     * of the tracing provider.
+     * @param clazz - the class of the object to be returned.
+     * @return an instance of the specified class 
+     */
+    default <T> T unwrap(Class<T> clazz) {
+        throw new UnsupportedOperationException("This operation is not supported");
+    }
 }