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 2017/05/31 18:11:42 UTC

[3/3] cxf git commit: CXF-7247: Support tracing using latest Zipkin Brave 4.x release. Backporting from 3.2 (master) to 3.1 release branch.

CXF-7247: Support tracing using latest Zipkin Brave 4.x release. Backporting from 3.2 (master) to 3.1 release branch.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/5bcce9c6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/5bcce9c6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/5bcce9c6

Branch: refs/heads/3.1.x-fixes
Commit: 5bcce9c61d4b211fec827b2e3f61be6f2b66fe0b
Parents: c7cc700
Author: reta <dr...@gmail.com>
Authored: Wed May 31 14:11:22 2017 -0400
Committer: reta <dr...@gmail.com>
Committed: Wed May 31 14:11:22 2017 -0400

----------------------------------------------------------------------
 .../samples/jax_rs/tracing_brave/README.txt     |  39 ++
 .../samples/jax_rs/tracing_brave/pom.xml        | 136 ++++++
 .../java/demo/jaxrs/tracing/client/Client.java  |  48 +++
 .../java/demo/jaxrs/tracing/server/Catalog.java | 135 ++++++
 .../tracing/server/CatalogApplication.java      |  45 ++
 .../demo/jaxrs/tracing/server/CatalogStore.java |  71 ++++
 .../java/demo/jaxrs/tracing/server/Server.java  |  52 +++
 .../jax_rs/tracing_brave_osgi/README.txt        |  79 ++++
 .../samples/jax_rs/tracing_brave_osgi/pom.xml   | 117 ++++++
 .../java/demo/jaxrs/tracing/server/Catalog.java | 135 ++++++
 .../demo/jaxrs/tracing/server/CatalogStore.java |  71 ++++
 .../services/javax.json.spi.JsonProvider        |   1 +
 .../resources/OSGI-INF/blueprint/context.xml    |  58 +++
 .../samples/jaxws_tracing_brave_osgi/README.txt |  71 ++++
 .../samples/jaxws_tracing_brave_osgi/pom.xml    |  97 +++++
 .../java/demo/jaxws/tracing/server/Book.java    |  48 +++
 .../jaxws/tracing/server/CatalogService.java    |  29 ++
 .../tracing/server/impl/CatalogServiceImpl.java |  89 ++++
 .../resources/OSGI-INF/blueprint/context.xml    |  62 +++
 distribution/src/main/release/samples/pom.xml   |   3 +
 integration/pom.xml                             |   1 +
 integration/tracing/tracing-brave/pom.xml       |  90 ++++
 .../brave/AbstractBraveClientInterceptor.java   |  63 +++
 .../brave/AbstractBraveClientProvider.java      | 117 ++++++
 .../tracing/brave/AbstractBraveInterceptor.java | 157 +++++++
 .../tracing/brave/AbstractBraveProvider.java    | 138 ++++++
 .../cxf/tracing/brave/BraveClientFeature.java   |  57 +++
 .../brave/BraveClientStartInterceptor.java      |  48 +++
 .../brave/BraveClientStopInterceptor.java       |  49 +++
 .../apache/cxf/tracing/brave/BraveFeature.java  |  75 ++++
 .../tracing/brave/BraveStartInterceptor.java    |  45 ++
 .../cxf/tracing/brave/BraveStopInterceptor.java |  66 +++
 .../cxf/tracing/brave/BraveTracerContext.java   | 104 +++++
 .../cxf/tracing/brave/HttpClientSpanParser.java |  39 ++
 .../cxf/tracing/brave/HttpServerSpanParser.java |  39 ++
 .../apache/cxf/tracing/brave/TraceScope.java    |  51 +++
 .../brave/internal/HttpAdapterFactory.java      |  69 +++
 .../internal/HttpClientAdapterFactory.java      |  89 ++++
 .../internal/HttpServerAdapterFactory.java      |  89 ++++
 .../brave/jaxrs/BraveClientProvider.java        |  71 ++++
 .../brave/jaxrs/BraveContextProvider.java       |  50 +++
 .../cxf/tracing/brave/jaxrs/BraveFeature.java   |  68 +++
 .../cxf/tracing/brave/jaxrs/BraveProvider.java  |  77 ++++
 .../cxf/tracing/brave/BraveTraceTest.java       | 107 +++++
 .../org/apache/cxf/tracing/brave/MyService.java |  26 ++
 .../apache/cxf/tracing/brave/MyServiceImpl.java |  28 ++
 .../features/src/main/resources/features.xml    |   9 +
 parent/pom.xml                                  |  21 +
 systests/tracing/pom.xml                        |  14 +-
 .../apache/cxf/systest/TestSpanReporter.java    |  42 ++
 .../cxf/systest/brave/BraveTestSupport.java     |  70 ++++
 .../cxf/systest/jaxrs/tracing/BookStore.java    |  19 +-
 .../jaxrs/tracing/brave/BraveTracingTest.java   | 415 +++++++++++++++++++
 .../systest/jaxrs/tracing/brave/HasSpan.java    |  71 ++++
 .../tracing/brave/IsAnnotationContaining.java   |  47 +++
 .../brave/IsBinaryAnnotationContaining.java     |  51 +++
 .../htrace/HTraceTracingCustomHeadersTest.java  |   3 +-
 .../jaxrs/tracing/htrace/HTraceTracingTest.java |  77 +++-
 .../systest/jaxrs/tracing/htrace/HasSpan.java   |  70 ++++
 .../tracing/htrace/IsTimelineContaining.java    |  47 +++
 .../jaxrs/tracing/htrace/IsTimelineEmpty.java   |  39 ++
 .../cxf/systest/jaxws/tracing/BookStore.java    |  43 --
 .../systest/jaxws/tracing/BookStoreService.java |   1 +
 .../systest/jaxws/tracing/brave/BookStore.java  |  64 +++
 .../jaxws/tracing/brave/BraveTracingTest.java   | 319 ++++++++++++++
 .../systest/jaxws/tracing/htrace/BookStore.java |  49 +++
 .../jaxws/tracing/htrace/HTraceTracingTest.java |   5 +-
 67 files changed, 4612 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave/README.txt
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..3a04f91
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/README.txt
@@ -0,0 +1,39 @@
+JAX-RS Brave/OpenZipkin Tracing Demo 
+=================
+
+The demo shows a basic usage of Brave/OpenZipkin distributed tracer with REST based 
+Web Services using  JAX-RS 2.0 (JSR-339). The REST server provides the 
+following services: 
+
+A RESTful catalog service is provided on URL http://localhost:9000/catalog 
+
+A HTTP GET request to URL http://localhost:9000/catalog generates following 
+traces:
+
+A HTTP POST request to URL http://localhost:9000/catalog generates following 
+traces:
+
+A HTTP GET request to URL http://localhost:9000/catalog/<id> generates following 
+traces:
+
+A HTTP DELETE request to URL http://localhost:9000/catalog/<id> generates following 
+traces:
+
+Building and running the demo using Maven
+---------------------------------------
+
+From the base directory of this sample (i.e., where this README file is
+located), the Maven pom.xml file can be used to build and run the demo. 
+
+
+Using either UNIX or Windows:
+
+  mvn install
+  mvn -Pserver  (from one command line window)
+  mvn -Pclient  (from a second command line window)
+    
+
+To remove the target dir, run mvn clean".
+
+
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave/pom.xml
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..e4f3777
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/pom.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>jax_rs_tracing_brave</artifactId>
+    <name>JAX-RS Demo Using Distributed Tracing with OpenZipkin Brave</name>
+    <description>JAX-RS Demo Using Distributed Tracing with OpenZipkin Brave</description>
+    <parent>
+        <groupId>org.apache.cxf.samples</groupId>
+        <artifactId>cxf-samples</artifactId>
+        <version>3.1.12-SNAPSHOT</version>
+        <relativePath>../..</relativePath>
+    </parent>
+    <properties>
+        <cxf.version>${project.version}</cxf.version>
+        <httpclient.version>3.1</httpclient.version>
+    </properties>
+    <profiles>
+        <profile>
+            <id>server</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.server.Server</mainClass>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+        <profile>
+            <id>client</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.Client</mainClass>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <!-- This dependency is needed if you're using the Jetty container -->
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http-jetty</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-client</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>    
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-integration-tracing-brave</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-extension-providers</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.json</groupId>
+            <artifactId>javax.json-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish</groupId>
+            <artifactId>javax.json</artifactId>
+        </dependency>                    
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+        </dependency>                
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>javax.ws.rs-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-webapp</artifactId>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/Client.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/Client.java b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/Client.java
new file mode 100644
index 0000000..a1fc3a6
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/client/Client.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 java.util.Arrays;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.tracing.brave.jaxrs.BraveClientProvider;
+
+import brave.Tracing;
+
+public final class Client {
+    private Client() {
+    }
+
+    public static void main(final String[] args) throws Exception {
+        final Tracing brave = Tracing.newBuilder().build();
+        final BraveClientProvider provider = new BraveClientProvider(brave);
+
+        final Response response = WebClient
+            .create("http://localhost:9000/catalog", Arrays.asList(provider))
+            .accept(MediaType.APPLICATION_JSON)
+            .get();
+
+        System.out.println(response.readEntity(String.class));
+        response.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/Catalog.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..141effc
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/Catalog.java
@@ -0,0 +1,135 @@
+/**
+ * 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.server;
+
+
+import java.io.IOException;
+import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import javax.json.Json;
+import javax.json.JsonObject;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.AsyncResponse;
+import javax.ws.rs.container.Suspended;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.tracing.Traceable;
+import org.apache.cxf.tracing.TracerContext;
+
+@Path("/catalog")
+public class Catalog {
+    private final ExecutorService executor = Executors.newFixedThreadPool(2);
+    private final CatalogStore store;
+
+    public Catalog() {
+        store = new CatalogStore();
+    }
+
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response addBook(@Context final UriInfo uriInfo, @Context final TracerContext tracing,
+            @FormParam("title") final String title)  {
+        try {
+            final String id = UUID.randomUUID().toString();
+
+            executor.submit(
+                tracing.wrap("Inserting New Book",
+                    new Traceable<Void>() {
+                        public Void call(final TracerContext context) throws Exception {
+                            store.put(id, title);
+                            return null;
+                        }
+                    }
+                )
+            ).get(10, TimeUnit.SECONDS);
+
+            return Response
+                .created(uriInfo.getRequestUriBuilder().path(id).build())
+                .build();
+        } catch (final Exception ex) {
+            return Response
+                .serverError()
+                .entity(Json
+                     .createObjectBuilder()
+                     .add("error", ex.getMessage())
+                     .build())
+                .build();
+        }
+    }
+
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public void getBooks(@Suspended final AsyncResponse response,
+            @Context final TracerContext tracing) throws Exception {
+        tracing.continueSpan(new Traceable<Void>() {
+            @Override
+            public Void call(final TracerContext context) throws Exception {
+                executor.submit(tracing.wrap("Looking for books", new Traceable<Void>() {
+                    @Override
+                    public Void call(final TracerContext context) throws Exception {
+                        response.resume(store.scan());
+                        return null;
+                    }
+                }));
+
+                return null;
+            }
+        });
+    }
+
+    @GET
+    @Path("/{id}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public JsonObject getBook(@PathParam("id") final String id) throws IOException {
+        final JsonObject book = store.get(id);
+
+        if (book == null) {
+            throw new NotFoundException("Book with does not exists: " + id);
+        }
+
+        return book;
+    }
+
+    @DELETE
+    @Path("/{id}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response delete(@PathParam("id") final String id) throws IOException {
+        if (!store.remove(id)) {
+            throw new NotFoundException("Book with does not exists: " + id);
+        }
+
+        return Response.ok().build();
+    }
+}
+
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
new file mode 100644
index 0000000..f0c5032
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/CatalogApplication.java
@@ -0,0 +1,45 @@
+/**
+ * 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.server;
+
+
+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.brave.jaxrs.BraveFeature;
+
+@ApplicationPath("/")
+public class CatalogApplication extends Application {
+    @Override
+    public Set<Object> getSingletons() {
+        return new HashSet<>(
+            Arrays.asList(
+                new Catalog(),
+                new BraveFeature(),
+                new JsrJsonpProvider()
+            )
+        );
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
new file mode 100644
index 0000000..d68ba66
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
@@ -0,0 +1,71 @@
+/**
+ * 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.server;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+
+public class CatalogStore {
+    private final Map<String, String> books = new ConcurrentHashMap<>();
+
+    public CatalogStore() {
+    }
+
+    public boolean remove(final String key) throws IOException {
+        return books.remove(key) != null;
+    }
+
+    public JsonObject get(final String key) throws IOException {
+        final String title = books.get(key);
+
+        if (title != null) {
+            return Json.createObjectBuilder()
+                .add("id", key)
+                .add("title", title)
+                .build();
+        }
+
+        return null;
+    }
+
+    public void put(final String key, final String title) throws IOException {
+        books.put(key, title);
+    }
+
+    public JsonArray scan() throws IOException {
+        final JsonArrayBuilder builder = Json.createArrayBuilder();
+
+        for (final Map.Entry<String, String> entry: books.entrySet()) {
+            builder.add(Json.createObjectBuilder()
+                .add("id", entry.getKey())
+                .add("title", entry.getValue())
+            );
+        }
+
+        return builder.build();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/Server.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/Server.java b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/Server.java
new file mode 100644
index 0000000..c57083d
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave/src/main/java/demo/jaxrs/tracing/server/Server.java
@@ -0,0 +1,52 @@
+/**
+ * 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.server;
+
+import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+public class Server {
+    protected Server() throws Exception {
+        org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(9000);
+
+        // Register and map the dispatcher servlet
+        final ServletHolder servletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
+        final ServletContextHandler context = new ServletContextHandler();
+        context.setContextPath("/");
+        context.addServlet(servletHolder, "/*");
+
+        servletHolder.setInitParameter("javax.ws.rs.Application",
+            CatalogApplication.class.getName());
+
+        server.setHandler(context);
+        server.start();
+        server.join();
+    }
+
+    public static void main(String args[]) throws Exception {
+        new Server();
+        System.out.println("Server ready...");
+
+        Thread.sleep(5 * 6000 * 1000);
+        System.out.println("Server exiting");
+        System.exit(0);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/README.txt
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/README.txt b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/README.txt
new file mode 100644
index 0000000..2832d9e
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/README.txt
@@ -0,0 +1,79 @@
+JAX-RS Brave/OpenZipkin Tracing Demo in OSGi container
+=================
+
+The demo shows a basic usage of Brave/OpenZipkin distributed tracer with REST based 
+Web Services using  JAX-RS 2.0 (JSR-339). The REST server provides the 
+following services: 
+
+A RESTful catalog service is provided on URL http://localhost:9000/catalog 
+
+A HTTP GET request to URL http://localhost:8181/cxf/catalog generates following 
+traces:
+
+A HTTP POST request to URL http://localhost:8181/cxf/catalog generates following 
+traces:
+
+A HTTP GET request to URL http://localhost:8181/cxf/catalog/<id> generates following 
+traces:
+
+A HTTP DELETE request to URL http://localhost:8181/cxf/catalog/<id> generates following 
+traces:
+
+
+Building and running the demo using Maven
+---------------------------------------
+
+From the base directory of this sample (i.e., where this README file is
+located), the Maven pom.xml file can be used to build and run the demo. 
+
+Using either UNIX or Windows:
+
+  mvn install
+  
+Starting Karaf (refer to http://karaf.apache.org/manual/latest-4.0.x/quick-start.html)
+
+  bin/karaf
+
+
+          __ __                  ____      
+         / //_/____ __________ _/ __/      
+        / ,<  / __ `/ ___/ __ `/ /_        
+       / /| |/ /_/ / /  / /_/ / __/        
+      /_/ |_|\__,_/_/   \__,_/_/         
+  
+    Apache Karaf (4.0.7)
+  
+  Hit '<tab>' for a list of available commands
+  and '[cmd] --help' for help on a specific command.
+  Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
+
+
+In order to install CXF's features, you need to add the CXF's features repo using
+
+  feature:repo-add cxf 3.n.m
+
+ where 3.n.m corresponds to a valid CXF version number (e.g., 3.2.0).
+
+Install CXF's cxf-tracing-brave feature that installs all the required bundles
+for this demo bundle.
+
+  feature:install cxf-jaxrs
+  feature:install cxf-jsr-json
+  feature:install cxf-tracing-brave
+
+Install this demo bundle (using the appropriate bundle version number)
+  
+  install -s mvn:org.apache.cxf.samples/jax_rs_tracing_brave_osgi/3.n.m
+
+You can verify if the CXF JAX-RS OpenZipkin Brave Blueprint Demo is installed and started.
+
+  karaf@root()> list
+  START LEVEL 100 , List Threshold: 50
+   ID | State  | Lvl | Version | Name                              
+  -----------------------------------------------------------------
+  117 | Active |  80 | 3.2.0.SNAPSHOT | JAX-RS Demo Using Distributed Tracing with OpenZipkin Brave and OSGi
+  karaf@root()>
+
+Now, you will be able to access this CXF JAXRS demo service on your Karaf instance at
+
+  http://localhost:8181/cxf/catalog
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/pom.xml b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/pom.xml
new file mode 100644
index 0000000..7c1868b
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/pom.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>jax_rs_tracing_brave_osgi</artifactId>
+    <name>JAX-RS Demo Using Distributed Tracing with OpenZipkin Brave and OSGi</name>
+    <description>JAX-RS Demo Using Distributed Tracing with OpenZipkin Brave and OSGi</description>
+    <packaging>bundle</packaging>
+    <parent>
+        <groupId>org.apache.cxf.samples</groupId>
+        <artifactId>cxf-samples</artifactId>
+        <version>3.1.12-SNAPSHOT</version>
+        <relativePath>../..</relativePath>
+    </parent>
+    <properties>
+        <cxf.version>${project.version}</cxf.version>
+        <httpclient.version>3.1</httpclient.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <!-- This dependency is needed if you're using the Jetty container -->
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http-jetty</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-client</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>    
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-integration-tracing-brave</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-rs-extension-providers</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.json</groupId>
+            <artifactId>javax.json-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.johnzon</groupId>
+            <artifactId>johnzon-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>javax.ws.rs-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-webapp</artifactId>
+        </dependency>
+    </dependencies>
+    
+     <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+                        <Import-Package>
+                            javax.ws.rs,
+                            javax.ws.rs.core,
+                            javax.ws.rs.container,
+                            org.apache.cxf.jaxrs.provider,
+                            org.apache.cxf.tracing.brave.jaxrs,
+                            org.osgi.service.blueprint,
+                            javax.annotation;version="[1.2,2)",
+                            org.apache.johnzon.core,
+                            *
+                        </Import-Package>
+                        <Export-Package>
+                        </Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/java/demo/jaxrs/tracing/server/Catalog.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/java/demo/jaxrs/tracing/server/Catalog.java b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/java/demo/jaxrs/tracing/server/Catalog.java
new file mode 100644
index 0000000..141effc
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/java/demo/jaxrs/tracing/server/Catalog.java
@@ -0,0 +1,135 @@
+/**
+ * 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.server;
+
+
+import java.io.IOException;
+import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import javax.json.Json;
+import javax.json.JsonObject;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.NotFoundException;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.AsyncResponse;
+import javax.ws.rs.container.Suspended;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.tracing.Traceable;
+import org.apache.cxf.tracing.TracerContext;
+
+@Path("/catalog")
+public class Catalog {
+    private final ExecutorService executor = Executors.newFixedThreadPool(2);
+    private final CatalogStore store;
+
+    public Catalog() {
+        store = new CatalogStore();
+    }
+
+    @POST
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response addBook(@Context final UriInfo uriInfo, @Context final TracerContext tracing,
+            @FormParam("title") final String title)  {
+        try {
+            final String id = UUID.randomUUID().toString();
+
+            executor.submit(
+                tracing.wrap("Inserting New Book",
+                    new Traceable<Void>() {
+                        public Void call(final TracerContext context) throws Exception {
+                            store.put(id, title);
+                            return null;
+                        }
+                    }
+                )
+            ).get(10, TimeUnit.SECONDS);
+
+            return Response
+                .created(uriInfo.getRequestUriBuilder().path(id).build())
+                .build();
+        } catch (final Exception ex) {
+            return Response
+                .serverError()
+                .entity(Json
+                     .createObjectBuilder()
+                     .add("error", ex.getMessage())
+                     .build())
+                .build();
+        }
+    }
+
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public void getBooks(@Suspended final AsyncResponse response,
+            @Context final TracerContext tracing) throws Exception {
+        tracing.continueSpan(new Traceable<Void>() {
+            @Override
+            public Void call(final TracerContext context) throws Exception {
+                executor.submit(tracing.wrap("Looking for books", new Traceable<Void>() {
+                    @Override
+                    public Void call(final TracerContext context) throws Exception {
+                        response.resume(store.scan());
+                        return null;
+                    }
+                }));
+
+                return null;
+            }
+        });
+    }
+
+    @GET
+    @Path("/{id}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public JsonObject getBook(@PathParam("id") final String id) throws IOException {
+        final JsonObject book = store.get(id);
+
+        if (book == null) {
+            throw new NotFoundException("Book with does not exists: " + id);
+        }
+
+        return book;
+    }
+
+    @DELETE
+    @Path("/{id}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response delete(@PathParam("id") final String id) throws IOException {
+        if (!store.remove(id)) {
+            throw new NotFoundException("Book with does not exists: " + id);
+        }
+
+        return Response.ok().build();
+    }
+}
+
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
new file mode 100644
index 0000000..d68ba66
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/java/demo/jaxrs/tracing/server/CatalogStore.java
@@ -0,0 +1,71 @@
+/**
+ * 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.server;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+
+public class CatalogStore {
+    private final Map<String, String> books = new ConcurrentHashMap<>();
+
+    public CatalogStore() {
+    }
+
+    public boolean remove(final String key) throws IOException {
+        return books.remove(key) != null;
+    }
+
+    public JsonObject get(final String key) throws IOException {
+        final String title = books.get(key);
+
+        if (title != null) {
+            return Json.createObjectBuilder()
+                .add("id", key)
+                .add("title", title)
+                .build();
+        }
+
+        return null;
+    }
+
+    public void put(final String key, final String title) throws IOException {
+        books.put(key, title);
+    }
+
+    public JsonArray scan() throws IOException {
+        final JsonArrayBuilder builder = Json.createArrayBuilder();
+
+        for (final Map.Entry<String, String> entry: books.entrySet()) {
+            builder.add(Json.createObjectBuilder()
+                .add("id", entry.getKey())
+                .add("title", entry.getValue())
+            );
+        }
+
+        return builder.build();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/resources/META-INF/services/javax.json.spi.JsonProvider
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/resources/META-INF/services/javax.json.spi.JsonProvider b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/resources/META-INF/services/javax.json.spi.JsonProvider
new file mode 100644
index 0000000..10c8c57
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/resources/META-INF/services/javax.json.spi.JsonProvider
@@ -0,0 +1 @@
+org.apache.johnzon.core.JsonProviderImpl
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/resources/OSGI-INF/blueprint/context.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/resources/OSGI-INF/blueprint/context.xml b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/resources/OSGI-INF/blueprint/context.xml
new file mode 100644
index 0000000..194f96e
--- /dev/null
+++ b/distribution/src/main/release/samples/jax_rs/tracing_brave_osgi/src/main/resources/OSGI-INF/blueprint/context.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!-- START SNIPPET: blueprint -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:cxf="http://cxf.apache.org/blueprint/core"
+       xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
+
+       xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
+                           http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
+                           http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd">
+
+    <!-- JAXRS providers -->
+    <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider" />
+
+    <bean id="braveFeature" class="org.apache.cxf.tracing.brave.jaxrs.BraveFeature">
+        <argument index="0" value="catalog-service" />
+    </bean>
+    
+    <!-- Application resources -->
+    <bean id="catalogResource" class="demo.jaxrs.tracing.server.Catalog" />
+
+    <!-- CXF BraveFeature -->  
+    <cxf:bus>
+        <cxf:features>
+            <cxf:logging />
+        </cxf:features>
+    </cxf:bus>
+
+    <jaxrs:server id="catalogServer" address="/">
+        <jaxrs:serviceBeans>
+            <ref component-id="catalogResource" />
+        </jaxrs:serviceBeans>
+        <jaxrs:providers>
+            <ref component-id="jsonProvider" />
+            <ref component-id="braveFeature" />
+        </jaxrs:providers>
+    </jaxrs:server>
+
+</blueprint>
+<!-- END SNIPPET: blueprint -->

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/README.txt
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/README.txt b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/README.txt
new file mode 100644
index 0000000..72c6ab5
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/README.txt
@@ -0,0 +1,71 @@
+JAX-RS Brave/OpenZipkin Tracing Demo in OSGi container
+=================
+
+The demo shows a basic usage of Brave/OpenZipkin distributed tracer with REST based 
+Web Services using  JAX-RS 2.0 (JSR-339). The REST server provides the 
+following services: 
+
+A SOAP catalog service is provided on URL http://localhost:8181/cxf/catalog. The WSDL 
+contract is available at http://localhost:8181/cxf/catalog?wsdl.
+
+There are three SOAP actions:
+  - addBook
+  - deleteBook
+  - getBook
+
+Building and running the demo using Maven
+---------------------------------------
+
+From the base directory of this sample (i.e., where this README file is
+located), the Maven pom.xml file can be used to build and run the demo. 
+
+Using either UNIX or Windows:
+
+  mvn install
+  
+Starting Karaf (refer to http://karaf.apache.org/manual/latest-4.0.x/quick-start.html)
+
+  bin/karaf
+
+
+          __ __                  ____      
+         / //_/____ __________ _/ __/      
+        / ,<  / __ `/ ___/ __ `/ /_        
+       / /| |/ /_/ / /  / /_/ / __/        
+      /_/ |_|\__,_/_/   \__,_/_/         
+  
+    Apache Karaf (4.0.7)
+  
+  Hit '<tab>' for a list of available commands
+  and '[cmd] --help' for help on a specific command.
+  Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
+
+
+In order to install CXF's features, you need to add the CXF's features repo using
+
+  feature:repo-add cxf 3.n.m
+
+ where 3.n.m corresponds to a valid CXF version number (e.g., 3.2.0).
+
+Install CXF's cxf-tracing-brave feature that installs all the required bundles
+for this demo bundle.
+
+  feature:install cxf-jaxws
+  feature:install cxf-tracing-brave
+
+Install this demo bundle (using the appropriate bundle version number)
+  
+  install -s mvn:org.apache.cxf.samples/jax_ws_tracing_brave_osgi/3.n.m
+
+You can verify if the CXF JAX-RS OpenZipkin Brave Blueprint Demo is installed and started.
+
+  karaf@root()> list
+  START LEVEL 100 , List Threshold: 50
+   ID | State  | Lvl | Version | Name                              
+  -----------------------------------------------------------------
+  117 | Active |  80 | 3.2.0.SNAPSHOT | JAX-RS Demo Using Distributed Tracing with OpenZipkin Brave and OSGi
+  karaf@root()>
+
+Now, you will be able to access this CXF JAXWS demo service on your Karaf instance at
+
+  http://localhost:8181/cxf/catalog?wsdl
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/pom.xml b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/pom.xml
new file mode 100644
index 0000000..b88e9d5
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>jax_ws_tracing_brave_osgi</artifactId>
+    <name>JAX-WS Demo Using Distributed Tracing with OpenZipkin Brave and OSGi</name>
+    <description>JAX-WS Demo Using Distributed Tracing with OpenZipkin Brave and OSGi</description>
+    <packaging>bundle</packaging>
+    <parent>
+        <groupId>org.apache.cxf.samples</groupId>
+        <artifactId>cxf-samples</artifactId>
+        <version>3.1.12-SNAPSHOT</version>
+        <relativePath>..</relativePath>
+    </parent>
+    <properties>
+        <cxf.version>${project.version}</cxf.version>
+        <httpclient.version>3.1</httpclient.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <!-- This dependency is needed if you're using the Jetty container -->
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http-jetty</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-integration-tracing-brave</artifactId>
+            <version>3.1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+        </dependency>                
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>javax.ws.rs-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-webapp</artifactId>
+        </dependency>
+    </dependencies>
+    
+     <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+                        <Import-Package>
+                            javax.ws.rs,
+                            javax.ws.rs.core,
+                            javax.ws.rs.container,
+                            org.apache.cxf.tracing.brave,
+                            org.osgi.service.blueprint,
+                            brave,
+                            *
+                        </Import-Package>
+                        <Export-Package>
+                        </Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/Book.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/Book.java b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/Book.java
new file mode 100644
index 0000000..9131b4f
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/Book.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.jaxws.tracing.server;
+
+public class Book {
+    private String id;
+    private String title;
+
+    public Book() {
+    }
+
+    public Book(String id, String title) {
+        this.id = id;
+        this.title = title;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/CatalogService.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/CatalogService.java b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/CatalogService.java
new file mode 100644
index 0000000..5d2c1de
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/CatalogService.java
@@ -0,0 +1,29 @@
+/**
+ * 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.jaxws.tracing.server;
+
+import javax.jws.WebService;
+
+@WebService
+public interface CatalogService {
+    void addBook(Book book);
+    Book getBook(final String id);
+    void deleteBook(final String id);
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/impl/CatalogServiceImpl.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/impl/CatalogServiceImpl.java b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/impl/CatalogServiceImpl.java
new file mode 100644
index 0000000..1b42d99
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/java/demo/jaxws/tracing/server/impl/CatalogServiceImpl.java
@@ -0,0 +1,89 @@
+/**
+ * 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.jaxws.tracing.server.impl;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+
+import org.apache.cxf.annotations.UseAsyncMethod;
+import org.apache.cxf.jaxws.ServerAsyncResponse;
+
+import brave.Span;
+import brave.Tracer.SpanInScope;
+import brave.Tracing;
+
+import demo.jaxws.tracing.server.Book;
+import demo.jaxws.tracing.server.CatalogService;
+
+public class CatalogServiceImpl implements CatalogService {
+    private final ExecutorService executor = Executors.newFixedThreadPool(2);
+    private final Map<String, Book> books = new ConcurrentHashMap<>();
+    private final Tracing brave;
+
+    public CatalogServiceImpl(final Tracing brave) {
+        this.brave = brave;
+    }
+
+    @UseAsyncMethod
+    public void addBook(Book book)  {
+        throw new UnsupportedOperationException("Please use async version of the method");
+    }
+
+    public Future<?> addBookAsync(final Book book, final AsyncHandler<Book> handler) {
+        final ServerAsyncResponse<Book> response = new ServerAsyncResponse<Book>();
+
+        executor.submit(new Runnable() {
+            @Override
+            public void run() {
+                final Span span = brave.tracer().nextSpan().name("Inserting New Book").start();
+                try (final SpanInScope scope = brave.tracer().withSpanInScope(span)) {
+                    books.put(book.getId(), book);
+                    handler.handleResponse(response);
+                } finally {
+                    span.finish();
+                }
+            }
+        });
+
+        return response;
+    }
+
+    @Override
+    public Book getBook(final String id) {
+        final Book book = books.get(id);
+
+        if (book == null) {
+            throw new RuntimeException("Book with does not exists: " + id);
+        }
+
+        return book;
+    }
+
+    @Override
+    public void deleteBook(final String id) {
+        if (books.remove(id) == null) {
+            throw new RuntimeException("Book with does not exists: " + id);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/resources/OSGI-INF/blueprint/context.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/resources/OSGI-INF/blueprint/context.xml b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/resources/OSGI-INF/blueprint/context.xml
new file mode 100644
index 0000000..95110ed
--- /dev/null
+++ b/distribution/src/main/release/samples/jaxws_tracing_brave_osgi/src/main/resources/OSGI-INF/blueprint/context.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!-- START SNIPPET: blueprint -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:cxf="http://cxf.apache.org/blueprint/core"
+       xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws"
+
+       xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
+                           http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
+                           http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd">
+
+    <!-- CXF BraveFeature -->
+    <bean id="braveFeature" class="org.apache.cxf.tracing.brave.BraveFeature">
+        <argument index="0" ref="brave" />
+    </bean>
+    
+    <cxf:bus>
+        <cxf:features>
+            <cxf:logging />
+        </cxf:features>
+    </cxf:bus>
+    
+    <bean id="catalogServiceImpl" class="demo.jaxws.tracing.server.impl.CatalogServiceImpl">
+        <argument index="0" ref="brave" />
+    </bean>
+    
+    <bean id="braveBuilder" class="brave.Tracing" factory-method="newBuilder" />
+
+    <bean id="braveCatalogBuilder" factory-ref="braveBuilder" factory-method="localServiceName">
+        <argument index="0" value="catalog-service" />
+    </bean>
+    
+    <bean id="brave" factory-ref="braveCatalogBuilder" factory-method="build" />
+    
+    <jaxws:endpoint
+        implementor="#catalogServiceImpl"
+        address="/catalog"
+        implementorClass="demo.jaxws.tracing.server.impl.CatalogServiceImpl">
+        <jaxws:features>
+            <ref component-id="braveFeature" />
+        </jaxws:features>
+    </jaxws:endpoint>
+</blueprint>
+<!-- END SNIPPET: blueprint -->

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/distribution/src/main/release/samples/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/pom.xml b/distribution/src/main/release/samples/pom.xml
index dcc50b5..4b3785c 100644
--- a/distribution/src/main/release/samples/pom.xml
+++ b/distribution/src/main/release/samples/pom.xml
@@ -120,6 +120,9 @@
         <module>ws_eventing</module>
         <module>throttling</module>
         <module>jax_rs/tracing_htrace</module>
+        <module>jax_rs/tracing_brave</module>
+        <module>jax_rs/tracing_brave_osgi</module>
+        <module>jaxws_tracing_brave_osgi</module>
     </modules>
     <dependencyManagement>
         <dependencies>

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/integration/pom.xml
----------------------------------------------------------------------
diff --git a/integration/pom.xml b/integration/pom.xml
index ff28526..ced0988 100644
--- a/integration/pom.xml
+++ b/integration/pom.xml
@@ -33,6 +33,7 @@
         <module>jca</module>
         <module>cdi</module>
         <module>tracing/tracing-htrace</module>
+        <module>tracing/tracing-brave</module>
         <module>spring-boot</module>
     </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/integration/tracing/tracing-brave/pom.xml
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-brave/pom.xml b/integration/tracing/tracing-brave/pom.xml
new file mode 100644
index 0000000..23bded9
--- /dev/null
+++ b/integration/tracing/tracing-brave/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>cxf-integration-tracing-brave</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache CXF Distributed Tracing using OpenZipkin Brave</name>
+    <description>Apache CXF Distributed using OpenZipkin Brave</description>
+    <url>http://cxf.apache.org</url>
+    <parent>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-parent</artifactId>
+        <version>3.1.12-SNAPSHOT</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+    
+    <properties>
+        <cxf.osgi.export>
+            org.apache.cxf.tracing,
+            org.apache.cxf.tracing.brave,
+            org.apache.cxf.tracing.brave.jaxrs
+        </cxf.osgi.export>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+            <version>${project.version}</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-management</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.zipkin.brave</groupId>
+            <artifactId>brave</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.zipkin.brave</groupId>
+            <artifactId>brave-instrumentation-http</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http-jetty</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientInterceptor.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientInterceptor.java b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientInterceptor.java
new file mode 100644
index 0000000..2e0c6a1
--- /dev/null
+++ b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientInterceptor.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 java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.PhaseInterceptor;
+
+import brave.http.HttpTracing;
+
+public abstract class AbstractBraveClientInterceptor extends AbstractBraveClientProvider
+        implements PhaseInterceptor<Message> {
+
+    private String phase;
+
+    protected AbstractBraveClientInterceptor(final String phase, final HttpTracing brave) {
+        super(brave);
+        this.phase = phase;
+    }
+
+    public Collection<PhaseInterceptor<? extends Message>> getAdditionalInterceptors() {
+        return null;
+    }
+
+    public Set<String> getAfter() {
+        return Collections.emptySet();
+    }
+
+    public Set<String> getBefore() {
+        return Collections.emptySet();
+    }
+
+    public String getId() {
+        return getClass().getName();
+    }
+
+    public String getPhase() {
+        return phase;
+    }
+
+    public void handleFault(Message message) {
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientProvider.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientProvider.java b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientProvider.java
new file mode 100644
index 0000000..fc2ccf0
--- /dev/null
+++ b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveClientProvider.java
@@ -0,0 +1,117 @@
+/**
+ * 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 java.net.URI;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.tracing.AbstractTracingProvider;
+import org.apache.cxf.tracing.brave.internal.HttpAdapterFactory;
+import org.apache.cxf.tracing.brave.internal.HttpAdapterFactory.Request;
+import org.apache.cxf.tracing.brave.internal.HttpAdapterFactory.Response;
+import org.apache.cxf.tracing.brave.internal.HttpClientAdapterFactory;
+
+import brave.Span;
+import brave.Tracer.SpanInScope;
+import brave.http.HttpClientAdapter;
+import brave.http.HttpClientHandler;
+import brave.http.HttpTracing;
+import brave.propagation.Propagation.Setter;
+
+public abstract class AbstractBraveClientProvider extends AbstractTracingProvider {
+    protected static final Logger LOG = LogUtils.getL7dLogger(AbstractBraveClientProvider.class);
+    protected static final String TRACE_SPAN = "org.apache.cxf.tracing.client.brave.span";
+
+    private final HttpTracing brave;
+
+    public AbstractBraveClientProvider(final HttpTracing brave) {
+        this.brave = brave;
+    }
+
+    protected TraceScopeHolder<TraceScope> startTraceSpan(final Map<String, List<String>> requestHeaders,
+            URI uri, String method) {
+
+        final Request request = HttpAdapterFactory.request(requestHeaders, uri, method);
+        final HttpClientAdapter<Request, ?> adapter = HttpClientAdapterFactory.create(request);
+        
+        @SuppressWarnings("unchecked")
+        final HttpClientHandler<Request, ?> handler = HttpClientHandler.create(brave, adapter);
+        final Span span = handler.handleSend(
+            brave
+                .tracing()
+                .propagation()
+                .injector(this.<Request>inject(requestHeaders)), 
+            request);
+
+        // In case of asynchronous client invocation, the span should be detached as JAX-RS
+        // client request / response filters are going to be executed in different threads.
+        SpanInScope scope = null;
+        if (!isAsyncInvocation() && span != null && !span.isNoop()) {
+            scope = brave.tracing().tracer().withSpanInScope(span);
+        }
+
+        return new TraceScopeHolder<TraceScope>(new TraceScope(span, scope), scope == null /* detached */);
+    }
+    
+    private <C> Setter<C, String> inject(final Map<String, List<String>> requestHeaders) {
+        return new Setter<C, String>() {
+            @Override
+            public void put(C carrier, String key, String value) {
+                if (!requestHeaders.containsKey(key)) {
+                    requestHeaders.put(key, Collections.singletonList(value));
+                }
+            }
+        };
+    }
+
+    private boolean isAsyncInvocation() {
+        return !JAXRSUtils.getCurrentMessage().getExchange().isSynchronous();
+    }
+
+    protected void stopTraceSpan(final TraceScopeHolder<TraceScope> holder, final int responseStatus) {
+        if (holder == null) {
+            return;
+        }
+
+        final TraceScope scope = holder.getScope();
+        if (scope != null) {
+            try {
+                // If the client invocation was asynchronous , the trace span has been created
+                // in another thread and should be re-attached to the current one.
+                if (holder.isDetached()) {
+                    brave.tracing().tracer().joinSpan(scope.getSpan().context());
+                }
+    
+                final Response response = HttpAdapterFactory.response(responseStatus);
+                final HttpClientAdapter<?, Response> adapter = HttpClientAdapterFactory.create(response);
+                
+                @SuppressWarnings("unchecked")
+                final HttpClientHandler<?, Response> handler = HttpClientHandler.create(brave, adapter);
+                handler.handleReceive(response, null, scope.getSpan());
+            } finally {
+                scope.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/5bcce9c6/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveInterceptor.java
----------------------------------------------------------------------
diff --git a/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveInterceptor.java b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveInterceptor.java
new file mode 100644
index 0000000..58b67f8
--- /dev/null
+++ b/integration/tracing/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/AbstractBraveInterceptor.java
@@ -0,0 +1,157 @@
+/**
+ * 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 java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.phase.PhaseInterceptor;
+
+import brave.http.HttpTracing;
+
+public abstract class AbstractBraveInterceptor extends AbstractBraveProvider implements PhaseInterceptor<Message> {
+    private final String phase;
+
+    protected static class ParsedMessage {
+        private Message message;
+
+        ParsedMessage(Message message) {
+            this.message = message;
+        }
+
+        String safeGet(String key) {
+            if (!message.containsKey(key)) {
+                return null;
+            }
+            Object value = message.get(key);
+            return (value instanceof String) ? value.toString() : null;
+        }
+
+        private String getUriSt() {
+            String uri = safeGet(Message.REQUEST_URL);
+            if (uri == null) {
+                String address = safeGet(Message.ENDPOINT_ADDRESS);
+                uri = safeGet(Message.REQUEST_URI);
+                if (uri != null && uri.startsWith("/")) {
+                    if (address != null && !address.startsWith(uri)) {
+                        if (address.endsWith("/") && address.length() > 1) {
+                            address = address.substring(0, address.length());
+                        }
+                        uri = address + uri;
+                    }
+                } else {
+                    uri = address;
+                }
+            }
+            String query = safeGet(Message.QUERY_STRING);
+            if (query != null) {
+                return uri + "?" + query;
+            } else {
+                return uri;
+            }
+        }
+
+        URI getUri() {
+            try {
+                String uriSt = getUriSt();
+                return uriSt != null ? new URI(uriSt) : new URI("");
+            } catch (URISyntaxException e) {
+                throw new RuntimeException(e.getMessage(), e);
+            }
+        }
+
+        Message getEffectiveMessage() {
+            boolean isRequestor = MessageUtils.isRequestor(message);
+            boolean isOutbound = MessageUtils.isOutbound(message);
+            if (isRequestor) {
+                return isOutbound ? message : message.getExchange().getOutMessage();
+            } else {
+                return isOutbound ? message.getExchange().getInMessage() : message;
+            }
+        }
+
+        Map<String, List<String>> getHeaders() {
+            Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
+
+            if (headers == null) {
+                return Collections.emptyMap();
+            }
+
+            return headers;
+        }
+
+        void addHeader(String key, String value) {
+            Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
+            if (headers == null) {
+                headers = new HashMap<>();
+                message.put(Message.PROTOCOL_HEADERS, headers);
+            }
+            headers.put(key, Arrays.asList(value));
+        }
+
+        String getHttpMethod() {
+            ParsedMessage eMessage = new ParsedMessage(getEffectiveMessage());
+            return eMessage.safeGet(Message.HTTP_REQUEST_METHOD);
+        }
+    }
+
+    protected AbstractBraveInterceptor(String phase, HttpTracing brave) {
+        super(brave);
+        this.phase = phase;
+    }
+
+    @Override
+    public Set<String> getAfter() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public Set<String> getBefore() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public String getId() {
+        return getClass().getName();
+    }
+
+    @Override
+    public String getPhase() {
+        return phase;
+    }
+
+    @Override
+    public Collection<PhaseInterceptor<? extends Message>> getAdditionalInterceptors() {
+        return null;
+    }
+
+    @Override
+    public void handleFault(Message message) {
+    }
+}