You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2016/12/06 13:36:10 UTC

cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Repository: cxf
Updated Branches:
  refs/heads/master 892a4ca84 -> fd77d3f33


[CXF-7164] Support tracing using Zipkin Brave


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

Branch: refs/heads/master
Commit: fd77d3f3380f805db3547d37cbb2ff72bd033ad0
Parents: 892a4ca
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Dec 6 14:35:35 2016 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Dec 6 14:36:01 2016 +0100

----------------------------------------------------------------------
 rt/features/pom.xml                             |   1 +
 rt/features/tracing-brave/pom.xml               |  87 +++++++++++++
 .../brave/soap/CxfHttpClientRequest.java        |  49 ++++++++
 .../tracing/brave/soap/CxfServerRequest.java    |  48 ++++++++
 .../cxf/tracing/brave/soap/HttpResponse200.java |  28 +++++
 .../cxf/tracing/brave/soap/ParsedMessage.java   | 121 +++++++++++++++++++
 .../cxf/tracing/brave/soap/TraceFeature.java    |  50 ++++++++
 .../tracing/brave/soap/TraceInInterceptor.java  |  58 +++++++++
 .../tracing/brave/soap/TraceOutInterceptor.java |  57 +++++++++
 .../cxf/tracing/brave/soap/BraveTraceTest.java  |  99 +++++++++++++++
 .../brave/soap/LoggingSpanNameProvider.java     |  31 +++++
 .../cxf/tracing/brave/soap/MyService.java       |  26 ++++
 .../cxf/tracing/brave/soap/MyServiceImpl.java   |  28 +++++
 13 files changed, 683 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/pom.xml
----------------------------------------------------------------------
diff --git a/rt/features/pom.xml b/rt/features/pom.xml
index 0365bf6..a4cfdff 100644
--- a/rt/features/pom.xml
+++ b/rt/features/pom.xml
@@ -34,5 +34,6 @@
         <module>logging</module>
         <module>metrics</module>
         <module>throttling</module>
+        <module>tracing-brave</module>
     </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/pom.xml
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/pom.xml b/rt/features/tracing-brave/pom.xml
new file mode 100644
index 0000000..9af22e4
--- /dev/null
+++ b/rt/features/tracing-brave/pom.xml
@@ -0,0 +1,87 @@
+<?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-rt-features-tracing-brave</artifactId>
+    <packaging>jar</packaging>
+    <name>Apache CXF Tracing using Zipkin Brave</name>
+    <url>http://cxf.apache.org</url>
+    <parent>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-parent</artifactId>
+        <version>3.2.0-SNAPSHOT</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+    
+    <properties>
+        <cxf.osgi.export>
+            org.apache.cxf.tracing.brave.soap
+        </cxf.osgi.export>
+        <brave.version>3.15.1</brave.version>
+    </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-features-logging</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+        	<groupId>io.zipkin.brave</groupId>
+        	<artifactId>brave-core</artifactId>
+        	<version>${brave.version}</version>
+        </dependency>
+        <dependency>
+        	<groupId>io.zipkin.brave</groupId>
+        	<artifactId>brave-http</artifactId>
+        	<version>${brave.version}</version>
+        </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>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java
new file mode 100644
index 0000000..78a40fd
--- /dev/null
+++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java
@@ -0,0 +1,49 @@
+/**
+ * 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.soap;
+
+import java.net.URI;
+
+import com.github.kristofa.brave.http.HttpClientRequest;
+import org.apache.cxf.message.Message;
+
+public class CxfHttpClientRequest implements HttpClientRequest {
+
+    private ParsedMessage message;
+
+    public CxfHttpClientRequest(Message message) {
+        this.message = new ParsedMessage(message);
+    }
+
+    @Override
+    public URI getUri() {
+        return message.getUri();
+    }
+
+    @Override
+    public String getHttpMethod() {
+        return message.getHttpMethod();
+    }
+
+    @Override
+    public void addHeader(String header, String value) {
+        message.addHeader(header, value);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java
new file mode 100644
index 0000000..fcc8797
--- /dev/null
+++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.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 org.apache.cxf.tracing.brave.soap;
+
+import java.net.URI;
+
+import com.github.kristofa.brave.http.HttpServerRequest;
+
+public class CxfServerRequest implements HttpServerRequest {
+
+    private ParsedMessage message;
+
+    public CxfServerRequest(ParsedMessage message) {
+        this.message = message;
+    }
+
+    @Override
+    public URI getUri() {
+        return message.getUri();
+    }
+
+    @Override
+    public String getHttpMethod() {
+        return message.getHttpMethod();
+    }
+
+    @Override
+    public String getHttpHeaderValue(String headerName) {
+        return message.getHeaders().get(headerName);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java
new file mode 100644
index 0000000..f50dbde
--- /dev/null
+++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java
@@ -0,0 +1,28 @@
+/**
+ * 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.soap;
+
+import com.github.kristofa.brave.http.HttpResponse;
+
+final class HttpResponse200 implements HttpResponse {
+    @Override
+    public int getHttpStatusCode() {
+        return 200;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java
new file mode 100644
index 0000000..8967375
--- /dev/null
+++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java
@@ -0,0 +1,121 @@
+/**
+ * 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.soap;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+
+public class ParsedMessage {
+    
+    private Message message;
+
+    public 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;
+    }
+    
+    public 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;
+        }
+    }
+    
+    public 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, String> getHeaders() {
+        Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
+        Map<String, String> result = new HashMap<>();
+        if (headers == null) {
+            return result;
+        }
+        for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
+            if (entry.getValue().size() == 1) {
+                result.put(entry.getKey(), entry.getValue().get(0));
+            } else {
+                String[] valueAr = entry.getValue().toArray(new String[] {});
+                result.put(entry.getKey(), valueAr.toString());
+            }
+        }
+        return result;
+    }
+    
+    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<String, List<String>>();
+            message.put(Message.PROTOCOL_HEADERS, headers);
+        }
+        headers.put(key, Arrays.asList(value));
+    }
+
+    public String getHttpMethod() {
+        ParsedMessage eMessage = new ParsedMessage(getEffectiveMessage());
+        return eMessage.safeGet(Message.HTTP_REQUEST_METHOD);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java
new file mode 100644
index 0000000..fbaca07
--- /dev/null
+++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java
@@ -0,0 +1,50 @@
+/**
+ * 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.soap;
+
+import com.github.kristofa.brave.Brave;
+import com.github.kristofa.brave.http.DefaultSpanNameProvider;
+import org.apache.cxf.Bus;
+import org.apache.cxf.annotations.Provider;
+import org.apache.cxf.annotations.Provider.Type;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.interceptor.InterceptorProvider;
+
+@NoJSR250Annotations
+@Provider(value = Type.Feature)
+public class TraceFeature extends AbstractFeature {
+    private TraceInInterceptor in;
+    private TraceOutInterceptor out;
+
+    public TraceFeature(Brave brave) {
+        DefaultSpanNameProvider nameProvider = new DefaultSpanNameProvider();
+        in = new TraceInInterceptor(brave, nameProvider);
+        out = new TraceOutInterceptor(brave, nameProvider);
+    }
+
+    @Override
+    protected void initializeProvider(InterceptorProvider provider, Bus bus) {
+        provider.getInInterceptors().add(in);
+        provider.getInFaultInterceptors().add(in);
+
+        provider.getOutInterceptors().add(out);
+        provider.getOutFaultInterceptors().add(out);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java
new file mode 100644
index 0000000..4b84eb3
--- /dev/null
+++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java
@@ -0,0 +1,58 @@
+/**
+ * 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.soap;
+
+import com.github.kristofa.brave.Brave;
+import com.github.kristofa.brave.http.HttpClientResponseAdapter;
+import com.github.kristofa.brave.http.HttpServerRequestAdapter;
+import com.github.kristofa.brave.http.SpanNameProvider;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+/**
+ * 
+ */
+@NoJSR250Annotations
+public class TraceInInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    private Brave brave;
+    private SpanNameProvider spanNameProvider;
+
+    public TraceInInterceptor(Brave brave, SpanNameProvider spanNameProvider) {
+        super(Phase.PRE_INVOKE);
+        this.brave = brave;
+        this.spanNameProvider = spanNameProvider;
+    }
+
+    public void handleMessage(Message cxfMessage) throws Fault {
+        ParsedMessage message = new ParsedMessage(cxfMessage);
+        if (MessageUtils.isRequestor(cxfMessage)) {
+            brave.clientResponseInterceptor().handle(new HttpClientResponseAdapter(new HttpResponse200()));
+        } else {
+            HttpServerRequestAdapter adapter = 
+                new HttpServerRequestAdapter(new CxfServerRequest(message), spanNameProvider);
+            brave.serverRequestInterceptor().handle(adapter);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java
new file mode 100644
index 0000000..17f76d0
--- /dev/null
+++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java
@@ -0,0 +1,57 @@
+/**
+ * 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.soap;
+
+import com.github.kristofa.brave.Brave;
+import com.github.kristofa.brave.http.HttpClientRequest;
+import com.github.kristofa.brave.http.HttpClientRequestAdapter;
+import com.github.kristofa.brave.http.HttpServerResponseAdapter;
+import com.github.kristofa.brave.http.SpanNameProvider;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+/**
+ * 
+ */
+@NoJSR250Annotations
+public class TraceOutInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    private Brave brave;
+    private SpanNameProvider spanNameProvider;
+
+    public TraceOutInterceptor(Brave brave, SpanNameProvider spanNameProvider) {
+        super(Phase.PRE_PROTOCOL);
+        this.brave = brave;
+        this.spanNameProvider = spanNameProvider;
+    }
+
+    public void handleMessage(Message message) throws Fault {
+        if (MessageUtils.isRequestor(message)) {
+            final HttpClientRequest req = new CxfHttpClientRequest(message);
+            brave.clientRequestInterceptor().handle(new HttpClientRequestAdapter(req, spanNameProvider));
+        } else {
+            brave.serverResponseInterceptor().handle(new HttpServerResponseAdapter(new HttpResponse200()));
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java
new file mode 100644
index 0000000..5bac5f7
--- /dev/null
+++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java
@@ -0,0 +1,99 @@
+/**
+ * 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.soap;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.github.kristofa.brave.Brave;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.ext.logging.LoggingFeature;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import zipkin.Span;
+import zipkin.reporter.Reporter;
+
+public class BraveTraceTest {
+    
+    private static final String ADDRESS = "http://localhost:8182";
+    private Server server;
+    private TraceFeature logging;
+    private Localreporter localReporter;
+
+    @Before
+    public void startServer() {
+        localReporter = new Localreporter();
+        logging = createLoggingFeature(localReporter);
+        server = createServer(logging);
+    }
+
+    @Test
+    public void testMyService() {
+        MyService myService = createProxy(logging);
+        myService.echo("test");
+        for (Span span : localReporter.spans) {
+            System.out.println(span);
+        }
+        Assert.assertEquals(2, localReporter.spans.size());
+
+    }
+    
+    @After
+    public void stopServer() {
+        server.destroy();
+    }
+    
+    private static Server createServer(Feature logging) {
+        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
+        factory.setAddress(ADDRESS);
+        factory.setServiceBean(new MyServiceImpl());
+        factory.setFeatures(Arrays.asList(logging));
+        return factory.create();
+    }
+    
+    private static MyService createProxy(Feature trace) {
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setServiceClass(MyService.class);
+        factory.setAddress(ADDRESS);
+        factory.setFeatures(Arrays.asList(trace, new LoggingFeature()));
+        return (MyService)factory.create();
+    }
+
+    private static TraceFeature createLoggingFeature(Reporter<Span> reporter) {
+        Brave brave = new Brave.Builder("myservice").reporter(reporter).build();
+        return new TraceFeature(brave);
+    }
+    
+    static final class Localreporter implements Reporter<Span> {
+        List<Span> spans = new ArrayList<Span>();
+
+        @Override
+        public void report(Span span) {
+            spans.add(span);
+        }
+        
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java
new file mode 100644
index 0000000..86fa25a
--- /dev/null
+++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java
@@ -0,0 +1,31 @@
+/**
+ * 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.soap;
+
+import com.github.kristofa.brave.http.HttpRequest;
+import com.github.kristofa.brave.http.SpanNameProvider;
+
+public class LoggingSpanNameProvider implements SpanNameProvider {
+
+    @Override
+    public String spanName(HttpRequest request) {
+        return (request instanceof SpanNameProvider) ? ((SpanNameProvider)request).spanName(request) : ""; 
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java
new file mode 100644
index 0000000..2001164
--- /dev/null
+++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java
@@ -0,0 +1,26 @@
+/**
+ * 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.soap;
+
+import javax.jws.WebService;
+
+@WebService
+public interface MyService {
+    String echo(String msg);
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java
----------------------------------------------------------------------
diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java
new file mode 100644
index 0000000..e9f901a
--- /dev/null
+++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java
@@ -0,0 +1,28 @@
+/**
+ * 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.soap;
+
+public class MyServiceImpl implements MyService {
+
+    @Override
+    public String echo(String msg) {
+        return msg;
+    }
+
+}


Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2016-12-08 21:39 GMT+01:00 Andrey Redko <dr...@gmail.com>:

> We have discussed this issue with Brave guys, pointing out to this specific
> use case (async call). Yes, all tracer are relying heavily on thread
> locals, however the detach / attach techniques are used to carry over the
> parent spans between threads.
>
>
Didn't see it in brave ATM but if handled that's good. Is it a dedicated
ContextProvider as proposed - which allows to control it through standard
@Context injection or something more specific?


> On Thu, Dec 8, 2016 at 12:36 PM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > 2016-12-08 19:35 GMT+01:00 Andrey Redko <dr...@gmail.com>:
> >
> > > That's right, Sergey, we have done some work around span manipulation
> in
> > > case of async calls. The brave-cxf supports that as well but in any
> case
> > > things may get a bit more complicated. I agree with you.
> > >
> > >
> > Quick correction: bave DOESN'T since it relies on threadlocal which
> doesnt
> > passthrough the value or inherited thread local which leaks in this case.
> >
> >
> > > On Thu, Dec 8, 2016 at 10:32 AM, Sergey Beryozkin <
> sberyozkin@gmail.com>
> > > wrote:
> > >
> > > > Hi Romain
> > > >
> > > > At least for CXF hTrace I know Andriy did some context switching to
> > keep
> > > > the track of the spans/etc. The span is detached, etc, I wonder how
> > does
> > > it
> > > > work under the hood
> > > >
> > > > Sergey
> > > >
> > > > On 08/12/16 14:34, Romain Manni-Bucau wrote:
> > > >
> > > >> 2016-12-08 15:14 GMT+01:00 Sergey Beryozkin <sb...@gmail.com>:
> > > >>
> > > >> Hi Romain
> > > >>>
> > > >>> Light-weight tracing (capturing few headers. etc) can be done with
> > > basic
> > > >>> custom features/interceptors, do you reckon there's a scope for
> > > shipping
> > > >>> something in CXF ?
> > > >>>
> > > >>> Yes
> > > >>>
> > > >>
> > > >>
> > > >> I suppose adding few basic interceptors to rt/management can work
> > > >>>
> > > >>>
> > > >> Yes,
> > > >>
> > > >> only trick is to support @Suspended case, see
> > > >> https://gist.github.com/rmannibucau/8c48d4182388b228046586fd6785a2
> f2
> > > >>
> > > >>
> > > >>
> > > >>> Cheers, Sergey
> > > >>>
> > > >>> On 08/12/16 13:29, Romain Manni-Bucau wrote:
> > > >>>
> > > >>> 2016-12-08 14:24 GMT+01:00 Andrey Redko <dr...@gmail.com>:
> > > >>>>
> > > >>>> Right, it looks like really light version of tracing, which
> > > essentially
> > > >>>>
> > > >>>>> allows to figure out which service/host is the problem. I am not
> > sure
> > > >>>>> how
> > > >>>>> useful it could be in practice, and there is a large overlap with
> > > >>>>> logging
> > > >>>>> in this case.
> > > >>>>>
> > > >>>>>
> > > >>>>> - light: sure
> > > >>>>>
> > > >>>> - overlap with logging: no. Of course it ends up in a log (or
> > > aggregator
> > > >>>> or
> > > >>>> even other kind of storage) but the point is not "where to put it"
> > but
> > > >>>> "where to take the data from". Whatever logging system you use you
> > > will
> > > >>>> never get the full tracing if you dont handle it and the point of
> > the
> > > >>>> code
> > > >>>> is just to maintain the value and make it available for logging or
> > > other
> > > >>>>  (a request header works well there)
> > > >>>> - how useful: if you have zipkin it is useless, if you have
> anything
> > > >>>> else
> > > >>>> (including an aggregator) it saves time and allows some
> > auto-analysis
> > > to
> > > >>>> be
> > > >>>> in place saving time for not that rare but easy errors
> > > >>>>
> > > >>>> Personally I see it as a kind of level 0 of analysis but
> > surprisingly
> > > if
> > > >>>> you compare the light vs powerful solutions, the light solves a
> lot
> > of
> > > >>>> cases in a simpler manner (Pareto?).
> > > >>>>
> > > >>>>
> > > >>>> On Thu, Dec 8, 2016 at 2:13 AM, Romain Manni-Bucau <
> > > >>>> rmannibucau@gmail.com
> > > >>>>
> > > >>>>>
> > > >>>>>> wrote:
> > > >>>>>
> > > >>>>> 2016-12-08 9:10 GMT+01:00 Christian Schneider <
> > > chris@die-schneider.net
> > > >>>>> >:
> > > >>>>>
> > > >>>>>>
> > > >>>>>> The new logging support in rt/features/logging already creates
> > > >>>>>> exchange
> > > >>>>>>
> > > >>>>>>>
> > > >>>>>>> id
> > > >>>>>>
> > > >>>>>> and message id. It also allows to send the message id over the
> > wire.
> > > >>>>>>> I have already fed the data into elastic search. There I was
> able
> > > to
> > > >>>>>>> correlate request to reply and request sent out from the client
> > to
> > > >>>>>>>
> > > >>>>>>> request
> > > >>>>>>
> > > >>>>>> received on the server.
> > > >>>>>>>
> > > >>>>>>> Would that already work?
> > > >>>>>>>
> > > >>>>>>> See http://cxf.apache.org/docs/message-logging.html
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>> It is closer to zipkin I think. The point of the previous
> > solution
> > > is
> > > >>>>>>>
> > > >>>>>> to
> > > >>>>>> "pre-stack" (pre-compute) the data to have an immediate reading
> of
> > > it
> > > >>>>>> vs
> > > >>>>>> requiring to rely on an aggregator to exploit it. It is
> generally
> > > >>>>>> added
> > > >>>>>>
> > > >>>>>> to
> > > >>>>>
> > > >>>>> the access log and allows to associate immediately a request to
> its
> > > >>>>>>
> > > >>>>>> origin
> > > >>>>>
> > > >>>>> (if you start getting a bunch of 500 or 401 and have a pipeline
> of
> > >
> > > 3
> > > >>>>>>
> > > >>>>>> hops
> > > >>>>>
> > > >>>>> it makes the diagnostic very efficient compared to going to your
> > > >>>>>>
> > > >>>>>> aggregator
> > > >>>>>
> > > >>>>> in general). Makes sense?
> > > >>>>>>
> > > >>>>>>
> > > >>>>>>
> > > >>>>>> Christian
> > > >>>>>>
> > > >>>>>>>
> > > >>>>>>> On 08.12.2016 08:58, Romain Manni-Bucau wrote:
> > > >>>>>>>
> > > >>>>>>> Hello guys,
> > > >>>>>>>
> > > >>>>>>>>
> > > >>>>>>>> would it make sense to have a lighter tracker in cxf? idea is
> > just
> > > >>>>>>>> to
> > > >>>>>>>>
> > > >>>>>>>> have
> > > >>>>>>>
> > > >>>>>>
> > > >>>>>> a header accumulator but not all the data zipkin requires. I
> often
> > > saw
> > > >>>>>>>
> > > >>>>>>>>
> > > >>>>>>>> it
> > > >>>>>>>
> > > >>>>>>
> > > >>>>>> used in companies to track the data path but often it is self
> > > >>>>>>>
> > > >>>>>>>>
> > > >>>>>>>> contained
> > > >>>>>>>
> > > >>>>>>
> > > >>>>> and
> > > >>>>>>
> > > >>>>>>> only contains the host list. In term of delivery it would be a
> > > jaxrs
> > > >>>>>>>> client/server provider (or interceptor) to handle the header
> and
> > > >>>>>>>> soap
> > > >>>>>>>> equivalent probably. Wdyt?
> > > >>>>>>>>
> > > >>>>>>>> (to make it clear client1 would send Cxf-Tracking: host1, if
> > > >>>>>>>> received
> > > >>>>>>>>
> > > >>>>>>>> on
> > > >>>>>>>
> > > >>>>>>
> > > >>>>> host2 the program does another request it will send Cxf-Tracking:
> > > >>>>>>
> > > >>>>>>> host1,host2 etc...)
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>>>>>>> --
> > > >>>>>>> Christian Schneider
> > > >>>>>>> http://www.liquid-reality.de
> > > >>>>>>>
> > > >>>>>>> Open Source Architect
> > > >>>>>>> http://www.talend.com
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>
> > > >>>>>
> > > >>>>
> > > >>> --
> > > >>> Sergey Beryozkin
> > > >>>
> > > >>> Talend Community Coders
> > > >>> http://coders.talend.com/
> > > >>>
> > > >>>
> > > >>
> > > >
> > >
> >
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Andrey Redko <dr...@gmail.com>.
We have discussed this issue with Brave guys, pointing out to this specific
use case (async call). Yes, all tracer are relying heavily on thread
locals, however the detach / attach techniques are used to carry over the
parent spans between threads.

On Thu, Dec 8, 2016 at 12:36 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> 2016-12-08 19:35 GMT+01:00 Andrey Redko <dr...@gmail.com>:
>
> > That's right, Sergey, we have done some work around span manipulation in
> > case of async calls. The brave-cxf supports that as well but in any case
> > things may get a bit more complicated. I agree with you.
> >
> >
> Quick correction: bave DOESN'T since it relies on threadlocal which doesnt
> passthrough the value or inherited thread local which leaks in this case.
>
>
> > On Thu, Dec 8, 2016 at 10:32 AM, Sergey Beryozkin <sb...@gmail.com>
> > wrote:
> >
> > > Hi Romain
> > >
> > > At least for CXF hTrace I know Andriy did some context switching to
> keep
> > > the track of the spans/etc. The span is detached, etc, I wonder how
> does
> > it
> > > work under the hood
> > >
> > > Sergey
> > >
> > > On 08/12/16 14:34, Romain Manni-Bucau wrote:
> > >
> > >> 2016-12-08 15:14 GMT+01:00 Sergey Beryozkin <sb...@gmail.com>:
> > >>
> > >> Hi Romain
> > >>>
> > >>> Light-weight tracing (capturing few headers. etc) can be done with
> > basic
> > >>> custom features/interceptors, do you reckon there's a scope for
> > shipping
> > >>> something in CXF ?
> > >>>
> > >>> Yes
> > >>>
> > >>
> > >>
> > >> I suppose adding few basic interceptors to rt/management can work
> > >>>
> > >>>
> > >> Yes,
> > >>
> > >> only trick is to support @Suspended case, see
> > >> https://gist.github.com/rmannibucau/8c48d4182388b228046586fd6785a2f2
> > >>
> > >>
> > >>
> > >>> Cheers, Sergey
> > >>>
> > >>> On 08/12/16 13:29, Romain Manni-Bucau wrote:
> > >>>
> > >>> 2016-12-08 14:24 GMT+01:00 Andrey Redko <dr...@gmail.com>:
> > >>>>
> > >>>> Right, it looks like really light version of tracing, which
> > essentially
> > >>>>
> > >>>>> allows to figure out which service/host is the problem. I am not
> sure
> > >>>>> how
> > >>>>> useful it could be in practice, and there is a large overlap with
> > >>>>> logging
> > >>>>> in this case.
> > >>>>>
> > >>>>>
> > >>>>> - light: sure
> > >>>>>
> > >>>> - overlap with logging: no. Of course it ends up in a log (or
> > aggregator
> > >>>> or
> > >>>> even other kind of storage) but the point is not "where to put it"
> but
> > >>>> "where to take the data from". Whatever logging system you use you
> > will
> > >>>> never get the full tracing if you dont handle it and the point of
> the
> > >>>> code
> > >>>> is just to maintain the value and make it available for logging or
> > other
> > >>>>  (a request header works well there)
> > >>>> - how useful: if you have zipkin it is useless, if you have anything
> > >>>> else
> > >>>> (including an aggregator) it saves time and allows some
> auto-analysis
> > to
> > >>>> be
> > >>>> in place saving time for not that rare but easy errors
> > >>>>
> > >>>> Personally I see it as a kind of level 0 of analysis but
> surprisingly
> > if
> > >>>> you compare the light vs powerful solutions, the light solves a lot
> of
> > >>>> cases in a simpler manner (Pareto?).
> > >>>>
> > >>>>
> > >>>> On Thu, Dec 8, 2016 at 2:13 AM, Romain Manni-Bucau <
> > >>>> rmannibucau@gmail.com
> > >>>>
> > >>>>>
> > >>>>>> wrote:
> > >>>>>
> > >>>>> 2016-12-08 9:10 GMT+01:00 Christian Schneider <
> > chris@die-schneider.net
> > >>>>> >:
> > >>>>>
> > >>>>>>
> > >>>>>> The new logging support in rt/features/logging already creates
> > >>>>>> exchange
> > >>>>>>
> > >>>>>>>
> > >>>>>>> id
> > >>>>>>
> > >>>>>> and message id. It also allows to send the message id over the
> wire.
> > >>>>>>> I have already fed the data into elastic search. There I was able
> > to
> > >>>>>>> correlate request to reply and request sent out from the client
> to
> > >>>>>>>
> > >>>>>>> request
> > >>>>>>
> > >>>>>> received on the server.
> > >>>>>>>
> > >>>>>>> Would that already work?
> > >>>>>>>
> > >>>>>>> See http://cxf.apache.org/docs/message-logging.html
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> It is closer to zipkin I think. The point of the previous
> solution
> > is
> > >>>>>>>
> > >>>>>> to
> > >>>>>> "pre-stack" (pre-compute) the data to have an immediate reading of
> > it
> > >>>>>> vs
> > >>>>>> requiring to rely on an aggregator to exploit it. It is generally
> > >>>>>> added
> > >>>>>>
> > >>>>>> to
> > >>>>>
> > >>>>> the access log and allows to associate immediately a request to its
> > >>>>>>
> > >>>>>> origin
> > >>>>>
> > >>>>> (if you start getting a bunch of 500 or 401 and have a pipeline of
> >
> > 3
> > >>>>>>
> > >>>>>> hops
> > >>>>>
> > >>>>> it makes the diagnostic very efficient compared to going to your
> > >>>>>>
> > >>>>>> aggregator
> > >>>>>
> > >>>>> in general). Makes sense?
> > >>>>>>
> > >>>>>>
> > >>>>>>
> > >>>>>> Christian
> > >>>>>>
> > >>>>>>>
> > >>>>>>> On 08.12.2016 08:58, Romain Manni-Bucau wrote:
> > >>>>>>>
> > >>>>>>> Hello guys,
> > >>>>>>>
> > >>>>>>>>
> > >>>>>>>> would it make sense to have a lighter tracker in cxf? idea is
> just
> > >>>>>>>> to
> > >>>>>>>>
> > >>>>>>>> have
> > >>>>>>>
> > >>>>>>
> > >>>>>> a header accumulator but not all the data zipkin requires. I often
> > saw
> > >>>>>>>
> > >>>>>>>>
> > >>>>>>>> it
> > >>>>>>>
> > >>>>>>
> > >>>>>> used in companies to track the data path but often it is self
> > >>>>>>>
> > >>>>>>>>
> > >>>>>>>> contained
> > >>>>>>>
> > >>>>>>
> > >>>>> and
> > >>>>>>
> > >>>>>>> only contains the host list. In term of delivery it would be a
> > jaxrs
> > >>>>>>>> client/server provider (or interceptor) to handle the header and
> > >>>>>>>> soap
> > >>>>>>>> equivalent probably. Wdyt?
> > >>>>>>>>
> > >>>>>>>> (to make it clear client1 would send Cxf-Tracking: host1, if
> > >>>>>>>> received
> > >>>>>>>>
> > >>>>>>>> on
> > >>>>>>>
> > >>>>>>
> > >>>>> host2 the program does another request it will send Cxf-Tracking:
> > >>>>>>
> > >>>>>>> host1,host2 etc...)
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>> --
> > >>>>>>> Christian Schneider
> > >>>>>>> http://www.liquid-reality.de
> > >>>>>>>
> > >>>>>>> Open Source Architect
> > >>>>>>> http://www.talend.com
> > >>>>>>>
> > >>>>>>>
> > >>>>>>>
> > >>>>>>>
> > >>>>>>
> > >>>>>
> > >>>>
> > >>> --
> > >>> Sergey Beryozkin
> > >>>
> > >>> Talend Community Coders
> > >>> http://coders.talend.com/
> > >>>
> > >>>
> > >>
> > >
> >
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2016-12-08 19:35 GMT+01:00 Andrey Redko <dr...@gmail.com>:

> That's right, Sergey, we have done some work around span manipulation in
> case of async calls. The brave-cxf supports that as well but in any case
> things may get a bit more complicated. I agree with you.
>
>
Quick correction: bave DOESN'T since it relies on threadlocal which doesnt
passthrough the value or inherited thread local which leaks in this case.


> On Thu, Dec 8, 2016 at 10:32 AM, Sergey Beryozkin <sb...@gmail.com>
> wrote:
>
> > Hi Romain
> >
> > At least for CXF hTrace I know Andriy did some context switching to keep
> > the track of the spans/etc. The span is detached, etc, I wonder how does
> it
> > work under the hood
> >
> > Sergey
> >
> > On 08/12/16 14:34, Romain Manni-Bucau wrote:
> >
> >> 2016-12-08 15:14 GMT+01:00 Sergey Beryozkin <sb...@gmail.com>:
> >>
> >> Hi Romain
> >>>
> >>> Light-weight tracing (capturing few headers. etc) can be done with
> basic
> >>> custom features/interceptors, do you reckon there's a scope for
> shipping
> >>> something in CXF ?
> >>>
> >>> Yes
> >>>
> >>
> >>
> >> I suppose adding few basic interceptors to rt/management can work
> >>>
> >>>
> >> Yes,
> >>
> >> only trick is to support @Suspended case, see
> >> https://gist.github.com/rmannibucau/8c48d4182388b228046586fd6785a2f2
> >>
> >>
> >>
> >>> Cheers, Sergey
> >>>
> >>> On 08/12/16 13:29, Romain Manni-Bucau wrote:
> >>>
> >>> 2016-12-08 14:24 GMT+01:00 Andrey Redko <dr...@gmail.com>:
> >>>>
> >>>> Right, it looks like really light version of tracing, which
> essentially
> >>>>
> >>>>> allows to figure out which service/host is the problem. I am not sure
> >>>>> how
> >>>>> useful it could be in practice, and there is a large overlap with
> >>>>> logging
> >>>>> in this case.
> >>>>>
> >>>>>
> >>>>> - light: sure
> >>>>>
> >>>> - overlap with logging: no. Of course it ends up in a log (or
> aggregator
> >>>> or
> >>>> even other kind of storage) but the point is not "where to put it" but
> >>>> "where to take the data from". Whatever logging system you use you
> will
> >>>> never get the full tracing if you dont handle it and the point of the
> >>>> code
> >>>> is just to maintain the value and make it available for logging or
> other
> >>>>  (a request header works well there)
> >>>> - how useful: if you have zipkin it is useless, if you have anything
> >>>> else
> >>>> (including an aggregator) it saves time and allows some auto-analysis
> to
> >>>> be
> >>>> in place saving time for not that rare but easy errors
> >>>>
> >>>> Personally I see it as a kind of level 0 of analysis but surprisingly
> if
> >>>> you compare the light vs powerful solutions, the light solves a lot of
> >>>> cases in a simpler manner (Pareto?).
> >>>>
> >>>>
> >>>> On Thu, Dec 8, 2016 at 2:13 AM, Romain Manni-Bucau <
> >>>> rmannibucau@gmail.com
> >>>>
> >>>>>
> >>>>>> wrote:
> >>>>>
> >>>>> 2016-12-08 9:10 GMT+01:00 Christian Schneider <
> chris@die-schneider.net
> >>>>> >:
> >>>>>
> >>>>>>
> >>>>>> The new logging support in rt/features/logging already creates
> >>>>>> exchange
> >>>>>>
> >>>>>>>
> >>>>>>> id
> >>>>>>
> >>>>>> and message id. It also allows to send the message id over the wire.
> >>>>>>> I have already fed the data into elastic search. There I was able
> to
> >>>>>>> correlate request to reply and request sent out from the client to
> >>>>>>>
> >>>>>>> request
> >>>>>>
> >>>>>> received on the server.
> >>>>>>>
> >>>>>>> Would that already work?
> >>>>>>>
> >>>>>>> See http://cxf.apache.org/docs/message-logging.html
> >>>>>>>
> >>>>>>>
> >>>>>>> It is closer to zipkin I think. The point of the previous solution
> is
> >>>>>>>
> >>>>>> to
> >>>>>> "pre-stack" (pre-compute) the data to have an immediate reading of
> it
> >>>>>> vs
> >>>>>> requiring to rely on an aggregator to exploit it. It is generally
> >>>>>> added
> >>>>>>
> >>>>>> to
> >>>>>
> >>>>> the access log and allows to associate immediately a request to its
> >>>>>>
> >>>>>> origin
> >>>>>
> >>>>> (if you start getting a bunch of 500 or 401 and have a pipeline of >
> 3
> >>>>>>
> >>>>>> hops
> >>>>>
> >>>>> it makes the diagnostic very efficient compared to going to your
> >>>>>>
> >>>>>> aggregator
> >>>>>
> >>>>> in general). Makes sense?
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> Christian
> >>>>>>
> >>>>>>>
> >>>>>>> On 08.12.2016 08:58, Romain Manni-Bucau wrote:
> >>>>>>>
> >>>>>>> Hello guys,
> >>>>>>>
> >>>>>>>>
> >>>>>>>> would it make sense to have a lighter tracker in cxf? idea is just
> >>>>>>>> to
> >>>>>>>>
> >>>>>>>> have
> >>>>>>>
> >>>>>>
> >>>>>> a header accumulator but not all the data zipkin requires. I often
> saw
> >>>>>>>
> >>>>>>>>
> >>>>>>>> it
> >>>>>>>
> >>>>>>
> >>>>>> used in companies to track the data path but often it is self
> >>>>>>>
> >>>>>>>>
> >>>>>>>> contained
> >>>>>>>
> >>>>>>
> >>>>> and
> >>>>>>
> >>>>>>> only contains the host list. In term of delivery it would be a
> jaxrs
> >>>>>>>> client/server provider (or interceptor) to handle the header and
> >>>>>>>> soap
> >>>>>>>> equivalent probably. Wdyt?
> >>>>>>>>
> >>>>>>>> (to make it clear client1 would send Cxf-Tracking: host1, if
> >>>>>>>> received
> >>>>>>>>
> >>>>>>>> on
> >>>>>>>
> >>>>>>
> >>>>> host2 the program does another request it will send Cxf-Tracking:
> >>>>>>
> >>>>>>> host1,host2 etc...)
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> --
> >>>>>>> Christian Schneider
> >>>>>>> http://www.liquid-reality.de
> >>>>>>>
> >>>>>>> Open Source Architect
> >>>>>>> http://www.talend.com
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>> --
> >>> Sergey Beryozkin
> >>>
> >>> Talend Community Coders
> >>> http://coders.talend.com/
> >>>
> >>>
> >>
> >
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Andrey Redko <dr...@gmail.com>.
That's right, Sergey, we have done some work around span manipulation in
case of async calls. The brave-cxf supports that as well but in any case
things may get a bit more complicated. I agree with you.

On Thu, Dec 8, 2016 at 10:32 AM, Sergey Beryozkin <sb...@gmail.com>
wrote:

> Hi Romain
>
> At least for CXF hTrace I know Andriy did some context switching to keep
> the track of the spans/etc. The span is detached, etc, I wonder how does it
> work under the hood
>
> Sergey
>
> On 08/12/16 14:34, Romain Manni-Bucau wrote:
>
>> 2016-12-08 15:14 GMT+01:00 Sergey Beryozkin <sb...@gmail.com>:
>>
>> Hi Romain
>>>
>>> Light-weight tracing (capturing few headers. etc) can be done with basic
>>> custom features/interceptors, do you reckon there's a scope for shipping
>>> something in CXF ?
>>>
>>> Yes
>>>
>>
>>
>> I suppose adding few basic interceptors to rt/management can work
>>>
>>>
>> Yes,
>>
>> only trick is to support @Suspended case, see
>> https://gist.github.com/rmannibucau/8c48d4182388b228046586fd6785a2f2
>>
>>
>>
>>> Cheers, Sergey
>>>
>>> On 08/12/16 13:29, Romain Manni-Bucau wrote:
>>>
>>> 2016-12-08 14:24 GMT+01:00 Andrey Redko <dr...@gmail.com>:
>>>>
>>>> Right, it looks like really light version of tracing, which essentially
>>>>
>>>>> allows to figure out which service/host is the problem. I am not sure
>>>>> how
>>>>> useful it could be in practice, and there is a large overlap with
>>>>> logging
>>>>> in this case.
>>>>>
>>>>>
>>>>> - light: sure
>>>>>
>>>> - overlap with logging: no. Of course it ends up in a log (or aggregator
>>>> or
>>>> even other kind of storage) but the point is not "where to put it" but
>>>> "where to take the data from". Whatever logging system you use you will
>>>> never get the full tracing if you dont handle it and the point of the
>>>> code
>>>> is just to maintain the value and make it available for logging or other
>>>>  (a request header works well there)
>>>> - how useful: if you have zipkin it is useless, if you have anything
>>>> else
>>>> (including an aggregator) it saves time and allows some auto-analysis to
>>>> be
>>>> in place saving time for not that rare but easy errors
>>>>
>>>> Personally I see it as a kind of level 0 of analysis but surprisingly if
>>>> you compare the light vs powerful solutions, the light solves a lot of
>>>> cases in a simpler manner (Pareto?).
>>>>
>>>>
>>>> On Thu, Dec 8, 2016 at 2:13 AM, Romain Manni-Bucau <
>>>> rmannibucau@gmail.com
>>>>
>>>>>
>>>>>> wrote:
>>>>>
>>>>> 2016-12-08 9:10 GMT+01:00 Christian Schneider <chris@die-schneider.net
>>>>> >:
>>>>>
>>>>>>
>>>>>> The new logging support in rt/features/logging already creates
>>>>>> exchange
>>>>>>
>>>>>>>
>>>>>>> id
>>>>>>
>>>>>> and message id. It also allows to send the message id over the wire.
>>>>>>> I have already fed the data into elastic search. There I was able to
>>>>>>> correlate request to reply and request sent out from the client to
>>>>>>>
>>>>>>> request
>>>>>>
>>>>>> received on the server.
>>>>>>>
>>>>>>> Would that already work?
>>>>>>>
>>>>>>> See http://cxf.apache.org/docs/message-logging.html
>>>>>>>
>>>>>>>
>>>>>>> It is closer to zipkin I think. The point of the previous solution is
>>>>>>>
>>>>>> to
>>>>>> "pre-stack" (pre-compute) the data to have an immediate reading of it
>>>>>> vs
>>>>>> requiring to rely on an aggregator to exploit it. It is generally
>>>>>> added
>>>>>>
>>>>>> to
>>>>>
>>>>> the access log and allows to associate immediately a request to its
>>>>>>
>>>>>> origin
>>>>>
>>>>> (if you start getting a bunch of 500 or 401 and have a pipeline of > 3
>>>>>>
>>>>>> hops
>>>>>
>>>>> it makes the diagnostic very efficient compared to going to your
>>>>>>
>>>>>> aggregator
>>>>>
>>>>> in general). Makes sense?
>>>>>>
>>>>>>
>>>>>>
>>>>>> Christian
>>>>>>
>>>>>>>
>>>>>>> On 08.12.2016 08:58, Romain Manni-Bucau wrote:
>>>>>>>
>>>>>>> Hello guys,
>>>>>>>
>>>>>>>>
>>>>>>>> would it make sense to have a lighter tracker in cxf? idea is just
>>>>>>>> to
>>>>>>>>
>>>>>>>> have
>>>>>>>
>>>>>>
>>>>>> a header accumulator but not all the data zipkin requires. I often saw
>>>>>>>
>>>>>>>>
>>>>>>>> it
>>>>>>>
>>>>>>
>>>>>> used in companies to track the data path but often it is self
>>>>>>>
>>>>>>>>
>>>>>>>> contained
>>>>>>>
>>>>>>
>>>>> and
>>>>>>
>>>>>>> only contains the host list. In term of delivery it would be a jaxrs
>>>>>>>> client/server provider (or interceptor) to handle the header and
>>>>>>>> soap
>>>>>>>> equivalent probably. Wdyt?
>>>>>>>>
>>>>>>>> (to make it clear client1 would send Cxf-Tracking: host1, if
>>>>>>>> received
>>>>>>>>
>>>>>>>> on
>>>>>>>
>>>>>>
>>>>> host2 the program does another request it will send Cxf-Tracking:
>>>>>>
>>>>>>> host1,host2 etc...)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>> Christian Schneider
>>>>>>> http://www.liquid-reality.de
>>>>>>>
>>>>>>> Open Source Architect
>>>>>>> http://www.talend.com
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>> --
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>>
>>
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Romain

At least for CXF hTrace I know Andriy did some context switching to keep 
the track of the spans/etc. The span is detached, etc, I wonder how does 
it work under the hood

Sergey
On 08/12/16 14:34, Romain Manni-Bucau wrote:
> 2016-12-08 15:14 GMT+01:00 Sergey Beryozkin <sb...@gmail.com>:
>
>> Hi Romain
>>
>> Light-weight tracing (capturing few headers. etc) can be done with basic
>> custom features/interceptors, do you reckon there's a scope for shipping
>> something in CXF ?
>>
>> Yes
>
>
>> I suppose adding few basic interceptors to rt/management can work
>>
>
> Yes,
>
> only trick is to support @Suspended case, see
> https://gist.github.com/rmannibucau/8c48d4182388b228046586fd6785a2f2
>
>
>>
>> Cheers, Sergey
>>
>> On 08/12/16 13:29, Romain Manni-Bucau wrote:
>>
>>> 2016-12-08 14:24 GMT+01:00 Andrey Redko <dr...@gmail.com>:
>>>
>>> Right, it looks like really light version of tracing, which essentially
>>>> allows to figure out which service/host is the problem. I am not sure how
>>>> useful it could be in practice, and there is a large overlap with logging
>>>> in this case.
>>>>
>>>>
>>>> - light: sure
>>> - overlap with logging: no. Of course it ends up in a log (or aggregator
>>> or
>>> even other kind of storage) but the point is not "where to put it" but
>>> "where to take the data from". Whatever logging system you use you will
>>> never get the full tracing if you dont handle it and the point of the code
>>> is just to maintain the value and make it available for logging or other
>>>  (a request header works well there)
>>> - how useful: if you have zipkin it is useless, if you have anything else
>>> (including an aggregator) it saves time and allows some auto-analysis to
>>> be
>>> in place saving time for not that rare but easy errors
>>>
>>> Personally I see it as a kind of level 0 of analysis but surprisingly if
>>> you compare the light vs powerful solutions, the light solves a lot of
>>> cases in a simpler manner (Pareto?).
>>>
>>>
>>> On Thu, Dec 8, 2016 at 2:13 AM, Romain Manni-Bucau <rmannibucau@gmail.com
>>>>>
>>>> wrote:
>>>>
>>>> 2016-12-08 9:10 GMT+01:00 Christian Schneider <ch...@die-schneider.net>:
>>>>>
>>>>> The new logging support in rt/features/logging already creates exchange
>>>>>>
>>>>> id
>>>>>
>>>>>> and message id. It also allows to send the message id over the wire.
>>>>>> I have already fed the data into elastic search. There I was able to
>>>>>> correlate request to reply and request sent out from the client to
>>>>>>
>>>>> request
>>>>>
>>>>>> received on the server.
>>>>>>
>>>>>> Would that already work?
>>>>>>
>>>>>> See http://cxf.apache.org/docs/message-logging.html
>>>>>>
>>>>>>
>>>>>> It is closer to zipkin I think. The point of the previous solution is
>>>>> to
>>>>> "pre-stack" (pre-compute) the data to have an immediate reading of it vs
>>>>> requiring to rely on an aggregator to exploit it. It is generally added
>>>>>
>>>> to
>>>>
>>>>> the access log and allows to associate immediately a request to its
>>>>>
>>>> origin
>>>>
>>>>> (if you start getting a bunch of 500 or 401 and have a pipeline of > 3
>>>>>
>>>> hops
>>>>
>>>>> it makes the diagnostic very efficient compared to going to your
>>>>>
>>>> aggregator
>>>>
>>>>> in general). Makes sense?
>>>>>
>>>>>
>>>>>
>>>>> Christian
>>>>>>
>>>>>> On 08.12.2016 08:58, Romain Manni-Bucau wrote:
>>>>>>
>>>>>> Hello guys,
>>>>>>>
>>>>>>> would it make sense to have a lighter tracker in cxf? idea is just to
>>>>>>>
>>>>>> have
>>>>>
>>>>>> a header accumulator but not all the data zipkin requires. I often saw
>>>>>>>
>>>>>> it
>>>>>
>>>>>> used in companies to track the data path but often it is self
>>>>>>>
>>>>>> contained
>>>>
>>>>> and
>>>>>>> only contains the host list. In term of delivery it would be a jaxrs
>>>>>>> client/server provider (or interceptor) to handle the header and soap
>>>>>>> equivalent probably. Wdyt?
>>>>>>>
>>>>>>> (to make it clear client1 would send Cxf-Tracking: host1, if received
>>>>>>>
>>>>>> on
>>>>
>>>>> host2 the program does another request it will send Cxf-Tracking:
>>>>>>> host1,host2 etc...)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> Christian Schneider
>>>>>> http://www.liquid-reality.de
>>>>>>
>>>>>> Open Source Architect
>>>>>> http://www.talend.com
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
>


Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2016-12-08 15:14 GMT+01:00 Sergey Beryozkin <sb...@gmail.com>:

> Hi Romain
>
> Light-weight tracing (capturing few headers. etc) can be done with basic
> custom features/interceptors, do you reckon there's a scope for shipping
> something in CXF ?
>
> Yes


> I suppose adding few basic interceptors to rt/management can work
>

Yes,

only trick is to support @Suspended case, see
https://gist.github.com/rmannibucau/8c48d4182388b228046586fd6785a2f2


>
> Cheers, Sergey
>
> On 08/12/16 13:29, Romain Manni-Bucau wrote:
>
>> 2016-12-08 14:24 GMT+01:00 Andrey Redko <dr...@gmail.com>:
>>
>> Right, it looks like really light version of tracing, which essentially
>>> allows to figure out which service/host is the problem. I am not sure how
>>> useful it could be in practice, and there is a large overlap with logging
>>> in this case.
>>>
>>>
>>> - light: sure
>> - overlap with logging: no. Of course it ends up in a log (or aggregator
>> or
>> even other kind of storage) but the point is not "where to put it" but
>> "where to take the data from". Whatever logging system you use you will
>> never get the full tracing if you dont handle it and the point of the code
>> is just to maintain the value and make it available for logging or other
>>  (a request header works well there)
>> - how useful: if you have zipkin it is useless, if you have anything else
>> (including an aggregator) it saves time and allows some auto-analysis to
>> be
>> in place saving time for not that rare but easy errors
>>
>> Personally I see it as a kind of level 0 of analysis but surprisingly if
>> you compare the light vs powerful solutions, the light solves a lot of
>> cases in a simpler manner (Pareto?).
>>
>>
>> On Thu, Dec 8, 2016 at 2:13 AM, Romain Manni-Bucau <rmannibucau@gmail.com
>>> >
>>> wrote:
>>>
>>> 2016-12-08 9:10 GMT+01:00 Christian Schneider <ch...@die-schneider.net>:
>>>>
>>>> The new logging support in rt/features/logging already creates exchange
>>>>>
>>>> id
>>>>
>>>>> and message id. It also allows to send the message id over the wire.
>>>>> I have already fed the data into elastic search. There I was able to
>>>>> correlate request to reply and request sent out from the client to
>>>>>
>>>> request
>>>>
>>>>> received on the server.
>>>>>
>>>>> Would that already work?
>>>>>
>>>>> See http://cxf.apache.org/docs/message-logging.html
>>>>>
>>>>>
>>>>> It is closer to zipkin I think. The point of the previous solution is
>>>> to
>>>> "pre-stack" (pre-compute) the data to have an immediate reading of it vs
>>>> requiring to rely on an aggregator to exploit it. It is generally added
>>>>
>>> to
>>>
>>>> the access log and allows to associate immediately a request to its
>>>>
>>> origin
>>>
>>>> (if you start getting a bunch of 500 or 401 and have a pipeline of > 3
>>>>
>>> hops
>>>
>>>> it makes the diagnostic very efficient compared to going to your
>>>>
>>> aggregator
>>>
>>>> in general). Makes sense?
>>>>
>>>>
>>>>
>>>> Christian
>>>>>
>>>>> On 08.12.2016 08:58, Romain Manni-Bucau wrote:
>>>>>
>>>>> Hello guys,
>>>>>>
>>>>>> would it make sense to have a lighter tracker in cxf? idea is just to
>>>>>>
>>>>> have
>>>>
>>>>> a header accumulator but not all the data zipkin requires. I often saw
>>>>>>
>>>>> it
>>>>
>>>>> used in companies to track the data path but often it is self
>>>>>>
>>>>> contained
>>>
>>>> and
>>>>>> only contains the host list. In term of delivery it would be a jaxrs
>>>>>> client/server provider (or interceptor) to handle the header and soap
>>>>>> equivalent probably. Wdyt?
>>>>>>
>>>>>> (to make it clear client1 would send Cxf-Tracking: host1, if received
>>>>>>
>>>>> on
>>>
>>>> host2 the program does another request it will send Cxf-Tracking:
>>>>>> host1,host2 etc...)
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> --
>>>>> Christian Schneider
>>>>> http://www.liquid-reality.de
>>>>>
>>>>> Open Source Architect
>>>>> http://www.talend.com
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Romain

Light-weight tracing (capturing few headers. etc) can be done with basic 
custom features/interceptors, do you reckon there's a scope for shipping 
something in CXF ?

I suppose adding few basic interceptors to rt/management can work

Cheers, Sergey
On 08/12/16 13:29, Romain Manni-Bucau wrote:
> 2016-12-08 14:24 GMT+01:00 Andrey Redko <dr...@gmail.com>:
>
>> Right, it looks like really light version of tracing, which essentially
>> allows to figure out which service/host is the problem. I am not sure how
>> useful it could be in practice, and there is a large overlap with logging
>> in this case.
>>
>>
> - light: sure
> - overlap with logging: no. Of course it ends up in a log (or aggregator or
> even other kind of storage) but the point is not "where to put it" but
> "where to take the data from". Whatever logging system you use you will
> never get the full tracing if you dont handle it and the point of the code
> is just to maintain the value and make it available for logging or other
>  (a request header works well there)
> - how useful: if you have zipkin it is useless, if you have anything else
> (including an aggregator) it saves time and allows some auto-analysis to be
> in place saving time for not that rare but easy errors
>
> Personally I see it as a kind of level 0 of analysis but surprisingly if
> you compare the light vs powerful solutions, the light solves a lot of
> cases in a simpler manner (Pareto?).
>
>
>> On Thu, Dec 8, 2016 at 2:13 AM, Romain Manni-Bucau <rm...@gmail.com>
>> wrote:
>>
>>> 2016-12-08 9:10 GMT+01:00 Christian Schneider <ch...@die-schneider.net>:
>>>
>>>> The new logging support in rt/features/logging already creates exchange
>>> id
>>>> and message id. It also allows to send the message id over the wire.
>>>> I have already fed the data into elastic search. There I was able to
>>>> correlate request to reply and request sent out from the client to
>>> request
>>>> received on the server.
>>>>
>>>> Would that already work?
>>>>
>>>> See http://cxf.apache.org/docs/message-logging.html
>>>>
>>>>
>>> It is closer to zipkin I think. The point of the previous solution is to
>>> "pre-stack" (pre-compute) the data to have an immediate reading of it vs
>>> requiring to rely on an aggregator to exploit it. It is generally added
>> to
>>> the access log and allows to associate immediately a request to its
>> origin
>>> (if you start getting a bunch of 500 or 401 and have a pipeline of > 3
>> hops
>>> it makes the diagnostic very efficient compared to going to your
>> aggregator
>>> in general). Makes sense?
>>>
>>>
>>>
>>>> Christian
>>>>
>>>> On 08.12.2016 08:58, Romain Manni-Bucau wrote:
>>>>
>>>>> Hello guys,
>>>>>
>>>>> would it make sense to have a lighter tracker in cxf? idea is just to
>>> have
>>>>> a header accumulator but not all the data zipkin requires. I often saw
>>> it
>>>>> used in companies to track the data path but often it is self
>> contained
>>>>> and
>>>>> only contains the host list. In term of delivery it would be a jaxrs
>>>>> client/server provider (or interceptor) to handle the header and soap
>>>>> equivalent probably. Wdyt?
>>>>>
>>>>> (to make it clear client1 would send Cxf-Tracking: host1, if received
>> on
>>>>> host2 the program does another request it will send Cxf-Tracking:
>>>>> host1,host2 etc...)
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> Christian Schneider
>>>> http://www.liquid-reality.de
>>>>
>>>> Open Source Architect
>>>> http://www.talend.com
>>>>
>>>>
>>>
>>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2016-12-08 14:24 GMT+01:00 Andrey Redko <dr...@gmail.com>:

> Right, it looks like really light version of tracing, which essentially
> allows to figure out which service/host is the problem. I am not sure how
> useful it could be in practice, and there is a large overlap with logging
> in this case.
>
>
- light: sure
- overlap with logging: no. Of course it ends up in a log (or aggregator or
even other kind of storage) but the point is not "where to put it" but
"where to take the data from". Whatever logging system you use you will
never get the full tracing if you dont handle it and the point of the code
is just to maintain the value and make it available for logging or other
 (a request header works well there)
- how useful: if you have zipkin it is useless, if you have anything else
(including an aggregator) it saves time and allows some auto-analysis to be
in place saving time for not that rare but easy errors

Personally I see it as a kind of level 0 of analysis but surprisingly if
you compare the light vs powerful solutions, the light solves a lot of
cases in a simpler manner (Pareto?).


> On Thu, Dec 8, 2016 at 2:13 AM, Romain Manni-Bucau <rm...@gmail.com>
> wrote:
>
> > 2016-12-08 9:10 GMT+01:00 Christian Schneider <ch...@die-schneider.net>:
> >
> > > The new logging support in rt/features/logging already creates exchange
> > id
> > > and message id. It also allows to send the message id over the wire.
> > > I have already fed the data into elastic search. There I was able to
> > > correlate request to reply and request sent out from the client to
> > request
> > > received on the server.
> > >
> > > Would that already work?
> > >
> > > See http://cxf.apache.org/docs/message-logging.html
> > >
> > >
> > It is closer to zipkin I think. The point of the previous solution is to
> > "pre-stack" (pre-compute) the data to have an immediate reading of it vs
> > requiring to rely on an aggregator to exploit it. It is generally added
> to
> > the access log and allows to associate immediately a request to its
> origin
> > (if you start getting a bunch of 500 or 401 and have a pipeline of > 3
> hops
> > it makes the diagnostic very efficient compared to going to your
> aggregator
> > in general). Makes sense?
> >
> >
> >
> > > Christian
> > >
> > > On 08.12.2016 08:58, Romain Manni-Bucau wrote:
> > >
> > >> Hello guys,
> > >>
> > >> would it make sense to have a lighter tracker in cxf? idea is just to
> > have
> > >> a header accumulator but not all the data zipkin requires. I often saw
> > it
> > >> used in companies to track the data path but often it is self
> contained
> > >> and
> > >> only contains the host list. In term of delivery it would be a jaxrs
> > >> client/server provider (or interceptor) to handle the header and soap
> > >> equivalent probably. Wdyt?
> > >>
> > >> (to make it clear client1 would send Cxf-Tracking: host1, if received
> on
> > >> host2 the program does another request it will send Cxf-Tracking:
> > >> host1,host2 etc...)
> > >>
> > >>
> > >>
> > >
> > > --
> > > Christian Schneider
> > > http://www.liquid-reality.de
> > >
> > > Open Source Architect
> > > http://www.talend.com
> > >
> > >
> >
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Andrey Redko <dr...@gmail.com>.
Right, it looks like really light version of tracing, which essentially
allows to figure out which service/host is the problem. I am not sure how
useful it could be in practice, and there is a large overlap with logging
in this case.

On Thu, Dec 8, 2016 at 2:13 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> 2016-12-08 9:10 GMT+01:00 Christian Schneider <ch...@die-schneider.net>:
>
> > The new logging support in rt/features/logging already creates exchange
> id
> > and message id. It also allows to send the message id over the wire.
> > I have already fed the data into elastic search. There I was able to
> > correlate request to reply and request sent out from the client to
> request
> > received on the server.
> >
> > Would that already work?
> >
> > See http://cxf.apache.org/docs/message-logging.html
> >
> >
> It is closer to zipkin I think. The point of the previous solution is to
> "pre-stack" (pre-compute) the data to have an immediate reading of it vs
> requiring to rely on an aggregator to exploit it. It is generally added to
> the access log and allows to associate immediately a request to its origin
> (if you start getting a bunch of 500 or 401 and have a pipeline of > 3 hops
> it makes the diagnostic very efficient compared to going to your aggregator
> in general). Makes sense?
>
>
>
> > Christian
> >
> > On 08.12.2016 08:58, Romain Manni-Bucau wrote:
> >
> >> Hello guys,
> >>
> >> would it make sense to have a lighter tracker in cxf? idea is just to
> have
> >> a header accumulator but not all the data zipkin requires. I often saw
> it
> >> used in companies to track the data path but often it is self contained
> >> and
> >> only contains the host list. In term of delivery it would be a jaxrs
> >> client/server provider (or interceptor) to handle the header and soap
> >> equivalent probably. Wdyt?
> >>
> >> (to make it clear client1 would send Cxf-Tracking: host1, if received on
> >> host2 the program does another request it will send Cxf-Tracking:
> >> host1,host2 etc...)
> >>
> >>
> >>
> >
> > --
> > Christian Schneider
> > http://www.liquid-reality.de
> >
> > Open Source Architect
> > http://www.talend.com
> >
> >
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Romain Manni-Bucau <rm...@gmail.com>.
2016-12-08 9:10 GMT+01:00 Christian Schneider <ch...@die-schneider.net>:

> The new logging support in rt/features/logging already creates exchange id
> and message id. It also allows to send the message id over the wire.
> I have already fed the data into elastic search. There I was able to
> correlate request to reply and request sent out from the client to request
> received on the server.
>
> Would that already work?
>
> See http://cxf.apache.org/docs/message-logging.html
>
>
It is closer to zipkin I think. The point of the previous solution is to
"pre-stack" (pre-compute) the data to have an immediate reading of it vs
requiring to rely on an aggregator to exploit it. It is generally added to
the access log and allows to associate immediately a request to its origin
(if you start getting a bunch of 500 or 401 and have a pipeline of > 3 hops
it makes the diagnostic very efficient compared to going to your aggregator
in general). Makes sense?



> Christian
>
> On 08.12.2016 08:58, Romain Manni-Bucau wrote:
>
>> Hello guys,
>>
>> would it make sense to have a lighter tracker in cxf? idea is just to have
>> a header accumulator but not all the data zipkin requires. I often saw it
>> used in companies to track the data path but often it is self contained
>> and
>> only contains the host list. In term of delivery it would be a jaxrs
>> client/server provider (or interceptor) to handle the header and soap
>> equivalent probably. Wdyt?
>>
>> (to make it clear client1 would send Cxf-Tracking: host1, if received on
>> host2 the program does another request it will send Cxf-Tracking:
>> host1,host2 etc...)
>>
>>
>>
>
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> http://www.talend.com
>
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Christian Schneider <ch...@die-schneider.net>.
The new logging support in rt/features/logging already creates exchange 
id and message id. It also allows to send the message id over the wire.
I have already fed the data into elastic search. There I was able to 
correlate request to reply and request sent out from the client to 
request received on the server.

Would that already work?

See http://cxf.apache.org/docs/message-logging.html

Christian

On 08.12.2016 08:58, Romain Manni-Bucau wrote:
> Hello guys,
>
> would it make sense to have a lighter tracker in cxf? idea is just to have
> a header accumulator but not all the data zipkin requires. I often saw it
> used in companies to track the data path but often it is self contained and
> only contains the host list. In term of delivery it would be a jaxrs
> client/server provider (or interceptor) to handle the header and soap
> equivalent probably. Wdyt?
>
> (to make it clear client1 would send Cxf-Tracking: host1, if received on
> host2 the program does another request it will send Cxf-Tracking:
> host1,host2 etc...)
>
>


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hello guys,

would it make sense to have a lighter tracker in cxf? idea is just to have
a header accumulator but not all the data zipkin requires. I often saw it
used in companies to track the data path but often it is self contained and
only contains the host list. In term of delivery it would be a jaxrs
client/server provider (or interceptor) to handle the header and soap
equivalent probably. Wdyt?

(to make it clear client1 would send Cxf-Tracking: host1, if received on
host2 the program does another request it will send Cxf-Tracking:
host1,host2 etc...)


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-12-08 3:13 GMT+01:00 Andrey Redko <dr...@gmail.com>:

> Absolutely, I would be happy to help you out. I will take another look on
> brave-cxf to understand
> which pieces should be kept in brave, which make sense to move to CXF.
> Thanks!
>
> Best Regards,
>     Andriy Redko
>
> On Wed, Dec 7, 2016 at 12:29 PM, Christian Schneider <
> chris@die-schneider.net> wrote:
>
> > Would be great if we could work together on this. I saw that you were
> part
> > of the brave-cxf development.
> > Maybe you could start with the actual tracing in cxf.
> > For me another important part is the brave OSGi integration and CXF-DOSGi
> > integration. So I could start with that.
> >
> > I am not sure where to put the brave OSGi part as it is not really
> related
> > to CXF but an important prerequisite to get it working in OSGi.
> > Maybe this can go to brave itself. I am thinking about a config driven
> > Brave OSGi service. So you simply need to create a config and get a
> working
> > service. The CXF tracing could then simply inject the Brave service
> instead
> > of taking care of the Brave setup directly.
> >
> > Christian
> >
> >
> > 2016-12-07 15:50 GMT+01:00 Andrey Redko <dr...@gmail.com>:
> >
> > > I think it is very good idea to integrate brave-cxf into CXF.
> Christian,
> > do
> > > you have enough time to work on that? I think I could help you out with
> > > that, I have reviewed brave-cxf PRs awhile back. Thanks.
> > >
> > > On Wed, Dec 7, 2016 at 5:00 AM, Christian Schneider <
> > > chris@die-schneider.net
> > > > wrote:
> > >
> > > > I just talked to Adrian Cole. He prefers to have the brave cxf
> > > integration
> > > > in cxf instead of brave. So we can go ahead and improve the module in
> > cxf
> > > > and he will deprecate the
> > > > brave-cxf module in brave once ours is good enough to cover all
> cases.
> > > >
> > > > Christian
> > > >
> > > > On 07.12.2016 11:46, Sergey Beryozkin wrote:
> > > >
> > > >> Hi Christian
> > > >>
> > > >> May be you can contribute your CXF Brave Feature code to the Brave
> > CXF 3
> > > >> module (the docs show the interceptors are registered directly) ?
> > > Otherwise
> > > >> Brave and CXF own Brave interceptors will start competing for who
> has
> > > the
> > > >> latest code :-)
> > > >>
> > > >> CXF HTrace is quite advanced thanks to the work Andriy did. But I
> > > believe
> > > >> your reservation about it was that HTrace was not working well in
> > OSGI.
> > > >>
> > > >> But if CXF RS/WS services are running in Spring Boot or other
> non-OSGI
> > > >> containers then what we have with HTrace is good. We'd like to
> > consider
> > > >> enhancing it a bit:
> > > >>
> > > >> https://issues.apache.org/jira/browse/CXF-7129
> > > >>
> > > >> so that the hTrac-ing can be optionally implicit.
> > > >>
> > > >> Cheers, Sergey
> > > >>
> > > >
> > > > --
> > > > Christian Schneider
> > > > http://www.liquid-reality.de
> > > >
> > > > Open Source Architect
> > > > http://www.talend.com
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > --
> > Christian Schneider
> > http://www.liquid-reality.de
> > <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e
> > 46&URL=http%3a%2f%2fwww.liquid-reality.de>
> >
> > Open Source Architect
> > http://www.talend.com
> > <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e
> > 46&URL=http%3a%2f%2fwww.talend.com>
> >
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Andrey Redko <dr...@gmail.com>.
Absolutely, I would be happy to help you out. I will take another look on
brave-cxf to understand
which pieces should be kept in brave, which make sense to move to CXF.
Thanks!

Best Regards,
    Andriy Redko

On Wed, Dec 7, 2016 at 12:29 PM, Christian Schneider <
chris@die-schneider.net> wrote:

> Would be great if we could work together on this. I saw that you were part
> of the brave-cxf development.
> Maybe you could start with the actual tracing in cxf.
> For me another important part is the brave OSGi integration and CXF-DOSGi
> integration. So I could start with that.
>
> I am not sure where to put the brave OSGi part as it is not really related
> to CXF but an important prerequisite to get it working in OSGi.
> Maybe this can go to brave itself. I am thinking about a config driven
> Brave OSGi service. So you simply need to create a config and get a working
> service. The CXF tracing could then simply inject the Brave service instead
> of taking care of the Brave setup directly.
>
> Christian
>
>
> 2016-12-07 15:50 GMT+01:00 Andrey Redko <dr...@gmail.com>:
>
> > I think it is very good idea to integrate brave-cxf into CXF. Christian,
> do
> > you have enough time to work on that? I think I could help you out with
> > that, I have reviewed brave-cxf PRs awhile back. Thanks.
> >
> > On Wed, Dec 7, 2016 at 5:00 AM, Christian Schneider <
> > chris@die-schneider.net
> > > wrote:
> >
> > > I just talked to Adrian Cole. He prefers to have the brave cxf
> > integration
> > > in cxf instead of brave. So we can go ahead and improve the module in
> cxf
> > > and he will deprecate the
> > > brave-cxf module in brave once ours is good enough to cover all cases.
> > >
> > > Christian
> > >
> > > On 07.12.2016 11:46, Sergey Beryozkin wrote:
> > >
> > >> Hi Christian
> > >>
> > >> May be you can contribute your CXF Brave Feature code to the Brave
> CXF 3
> > >> module (the docs show the interceptors are registered directly) ?
> > Otherwise
> > >> Brave and CXF own Brave interceptors will start competing for who has
> > the
> > >> latest code :-)
> > >>
> > >> CXF HTrace is quite advanced thanks to the work Andriy did. But I
> > believe
> > >> your reservation about it was that HTrace was not working well in
> OSGI.
> > >>
> > >> But if CXF RS/WS services are running in Spring Boot or other non-OSGI
> > >> containers then what we have with HTrace is good. We'd like to
> consider
> > >> enhancing it a bit:
> > >>
> > >> https://issues.apache.org/jira/browse/CXF-7129
> > >>
> > >> so that the hTrac-ing can be optionally implicit.
> > >>
> > >> Cheers, Sergey
> > >>
> > >
> > > --
> > > Christian Schneider
> > > http://www.liquid-reality.de
> > >
> > > Open Source Architect
> > > http://www.talend.com
> > >
> > >
> >
>
>
>
> --
> --
> Christian Schneider
> http://www.liquid-reality.de
> <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e
> 46&URL=http%3a%2f%2fwww.liquid-reality.de>
>
> Open Source Architect
> http://www.talend.com
> <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e
> 46&URL=http%3a%2f%2fwww.talend.com>
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Christian Schneider <ch...@die-schneider.net>.
Would be great if we could work together on this. I saw that you were part
of the brave-cxf development.
Maybe you could start with the actual tracing in cxf.
For me another important part is the brave OSGi integration and CXF-DOSGi
integration. So I could start with that.

I am not sure where to put the brave OSGi part as it is not really related
to CXF but an important prerequisite to get it working in OSGi.
Maybe this can go to brave itself. I am thinking about a config driven
Brave OSGi service. So you simply need to create a config and get a working
service. The CXF tracing could then simply inject the Brave service instead
of taking care of the Brave setup directly.

Christian


2016-12-07 15:50 GMT+01:00 Andrey Redko <dr...@gmail.com>:

> I think it is very good idea to integrate brave-cxf into CXF. Christian, do
> you have enough time to work on that? I think I could help you out with
> that, I have reviewed brave-cxf PRs awhile back. Thanks.
>
> On Wed, Dec 7, 2016 at 5:00 AM, Christian Schneider <
> chris@die-schneider.net
> > wrote:
>
> > I just talked to Adrian Cole. He prefers to have the brave cxf
> integration
> > in cxf instead of brave. So we can go ahead and improve the module in cxf
> > and he will deprecate the
> > brave-cxf module in brave once ours is good enough to cover all cases.
> >
> > Christian
> >
> > On 07.12.2016 11:46, Sergey Beryozkin wrote:
> >
> >> Hi Christian
> >>
> >> May be you can contribute your CXF Brave Feature code to the Brave CXF 3
> >> module (the docs show the interceptors are registered directly) ?
> Otherwise
> >> Brave and CXF own Brave interceptors will start competing for who has
> the
> >> latest code :-)
> >>
> >> CXF HTrace is quite advanced thanks to the work Andriy did. But I
> believe
> >> your reservation about it was that HTrace was not working well in OSGI.
> >>
> >> But if CXF RS/WS services are running in Spring Boot or other non-OSGI
> >> containers then what we have with HTrace is good. We'd like to consider
> >> enhancing it a bit:
> >>
> >> https://issues.apache.org/jira/browse/CXF-7129
> >>
> >> so that the hTrac-ing can be optionally implicit.
> >>
> >> Cheers, Sergey
> >>
> >
> > --
> > Christian Schneider
> > http://www.liquid-reality.de
> >
> > Open Source Architect
> > http://www.talend.com
> >
> >
>



-- 
-- 
Christian Schneider
http://www.liquid-reality.de
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.liquid-reality.de>

Open Source Architect
http://www.talend.com
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.talend.com>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Andrey Redko <dr...@gmail.com>.
I think it is very good idea to integrate brave-cxf into CXF. Christian, do
you have enough time to work on that? I think I could help you out with
that, I have reviewed brave-cxf PRs awhile back. Thanks.

On Wed, Dec 7, 2016 at 5:00 AM, Christian Schneider <chris@die-schneider.net
> wrote:

> I just talked to Adrian Cole. He prefers to have the brave cxf integration
> in cxf instead of brave. So we can go ahead and improve the module in cxf
> and he will deprecate the
> brave-cxf module in brave once ours is good enough to cover all cases.
>
> Christian
>
> On 07.12.2016 11:46, Sergey Beryozkin wrote:
>
>> Hi Christian
>>
>> May be you can contribute your CXF Brave Feature code to the Brave CXF 3
>> module (the docs show the interceptors are registered directly) ? Otherwise
>> Brave and CXF own Brave interceptors will start competing for who has the
>> latest code :-)
>>
>> CXF HTrace is quite advanced thanks to the work Andriy did. But I believe
>> your reservation about it was that HTrace was not working well in OSGI.
>>
>> But if CXF RS/WS services are running in Spring Boot or other non-OSGI
>> containers then what we have with HTrace is good. We'd like to consider
>> enhancing it a bit:
>>
>> https://issues.apache.org/jira/browse/CXF-7129
>>
>> so that the hTrac-ing can be optionally implicit.
>>
>> Cheers, Sergey
>>
>
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> http://www.talend.com
>
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Christian Schneider <ch...@die-schneider.net>.
I just talked to Adrian Cole. He prefers to have the brave cxf 
integration in cxf instead of brave. So we can go ahead and improve the 
module in cxf and he will deprecate the
brave-cxf module in brave once ours is good enough to cover all cases.

Christian

On 07.12.2016 11:46, Sergey Beryozkin wrote:
> Hi Christian
>
> May be you can contribute your CXF Brave Feature code to the Brave CXF 
> 3 module (the docs show the interceptors are registered directly) ? 
> Otherwise Brave and CXF own Brave interceptors will start competing 
> for who has the latest code :-)
>
> CXF HTrace is quite advanced thanks to the work Andriy did. But I 
> believe your reservation about it was that HTrace was not working well 
> in OSGI.
>
> But if CXF RS/WS services are running in Spring Boot or other non-OSGI 
> containers then what we have with HTrace is good. We'd like to 
> consider enhancing it a bit:
>
> https://issues.apache.org/jira/browse/CXF-7129
>
> so that the hTrac-ing can be optionally implicit.
>
> Cheers, Sergey 

-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Christian

May be you can contribute your CXF Brave Feature code to the Brave CXF 3 
module (the docs show the interceptors are registered directly) ? 
Otherwise Brave and CXF own Brave interceptors will start competing for 
who has the latest code :-)

CXF HTrace is quite advanced thanks to the work Andriy did. But I 
believe your reservation about it was that HTrace was not working well 
in OSGI.

But if CXF RS/WS services are running in Spring Boot or other non-OSGI 
containers then what we have with HTrace is good. We'd like to consider 
enhancing it a bit:

https://issues.apache.org/jira/browse/CXF-7129

so that the hTrac-ing can be optionally implicit.

Cheers, Sergey

On 07/12/16 06:34, Christian Schneider wrote:
> Damn ... I just found there is also general CXF support for brave at
> https://github.com/openzipkin/brave/tree/master/brave-cxf3 . So maybe this
> already solved the problem before.
> We should decide how to proceed.
>
> I think one approach is to help at brave-cxf3 to make it as good as
> possible and revert the cxf module I created.
> The other is to focus on the cxf trace zipkin module .. Actually I am not
> sure what is the better option.
>
> Any opinions?
>
> Christian
>
> 2016-12-06 20:49 GMT+01:00 Andrey Redko <dr...@gmail.com>:
>
>> That's right, the JAX-RS part should be supported by Brave already thanks
>> to dedicated CXF integration (I was involved in late-stage discussions for
>> the PR in question but not in the implementation).
>>
>> Best Regards,
>>     Andriy Redko
>>
>> On Tue, Dec 6, 2016 at 12:09 PM, Christian Schneider <
>> chris@die-schneider.net> wrote:
>>
>>> My orignal plan was to just support SOAP as REST is well supported by
>> brave
>>> rest support already.
>>> In the end my code was able to support both REST and SOAP without much
>>> overhead so I removed the soap package again.
>>>
>>> Christian
>>>
>>> 2016-12-06 14:41 GMT+01:00 Sergey Beryozkin <sb...@gmail.com>:
>>>
>>>> Christian, what is SOAP specific in this code ?
>>>> Looks like that can work with JAX-RS too ?
>>>>
>>>> Usually we try to accommodate both frontends, example, Andriy Redko
>> made
>>>> sure HTrace interceptors work for JAXWS, similarly for Bean validation
>>>>
>>>> Sergey
>>>>
>>>>
>>>>
>>>> On 06/12/16 13:36, cschneider@apache.org wrote:
>>>>
>>>>> Repository: cxf
>>>>> Updated Branches:
>>>>>   refs/heads/master 892a4ca84 -> fd77d3f33
>>>>>
>>>>>
>>>>> [CXF-7164] Support tracing using Zipkin Brave
>>>>>
>>>>>
>>>>> Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
>>>>> Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fd77d3f3
>>>>> Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fd77d3f3
>>>>> Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fd77d3f3
>>>>>
>>>>> Branch: refs/heads/master
>>>>> Commit: fd77d3f3380f805db3547d37cbb2ff72bd033ad0
>>>>> Parents: 892a4ca
>>>>> Author: Christian Schneider <ch...@die-schneider.net>
>>>>> Authored: Tue Dec 6 14:35:35 2016 +0100
>>>>> Committer: Christian Schneider <ch...@die-schneider.net>
>>>>> Committed: Tue Dec 6 14:36:01 2016 +0100
>>>>>
>>>>> ------------------------------------------------------------
>> ----------
>>>>>  rt/features/pom.xml                             |   1 +
>>>>>  rt/features/tracing-brave/pom.xml               |  87 +++++++++++++
>>>>>  .../brave/soap/CxfHttpClientRequest.java        |  49 ++++++++
>>>>>  .../tracing/brave/soap/CxfServerRequest.java    |  48 ++++++++
>>>>>  .../cxf/tracing/brave/soap/HttpResponse200.java |  28 +++++
>>>>>  .../cxf/tracing/brave/soap/ParsedMessage.java   | 121
>>>>> +++++++++++++++++++
>>>>>  .../cxf/tracing/brave/soap/TraceFeature.java    |  50 ++++++++
>>>>>  .../tracing/brave/soap/TraceInInterceptor.java  |  58 +++++++++
>>>>>  .../tracing/brave/soap/TraceOutInterceptor.java |  57 +++++++++
>>>>>  .../cxf/tracing/brave/soap/BraveTraceTest.java  |  99
>> +++++++++++++++
>>>>>  .../brave/soap/LoggingSpanNameProvider.java     |  31 +++++
>>>>>  .../cxf/tracing/brave/soap/MyService.java       |  26 ++++
>>>>>  .../cxf/tracing/brave/soap/MyServiceImpl.java   |  28 +++++
>>>>>  13 files changed, 683 insertions(+)
>>>>> ------------------------------------------------------------
>> ----------
>>>>>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/pom.xml
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/pom.xml b/rt/features/pom.xml
>>>>> index 0365bf6..a4cfdff 100644
>>>>> --- a/rt/features/pom.xml
>>>>> +++ b/rt/features/pom.xml
>>>>> @@ -34,5 +34,6 @@
>>>>>          <module>logging</module>
>>>>>          <module>metrics</module>
>>>>>          <module>throttling</module>
>>>>> +        <module>tracing-brave</module>
>>>>>      </modules>
>>>>>  </project>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/pom.xml
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/pom.xml
>>>>> b/rt/features/tracing-brave/pom.xml
>>>>> new file mode 100644
>>>>> index 0000000..9af22e4
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/pom.xml
>>>>> @@ -0,0 +1,87 @@
>>>>> +<?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://mav
>>>>> en.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
>>>>> +    <modelVersion>4.0.0</modelVersion>
>>>>> +    <artifactId>cxf-rt-features-tracing-brave</artifactId>
>>>>> +    <packaging>jar</packaging>
>>>>> +    <name>Apache CXF Tracing using Zipkin Brave</name>
>>>>> +    <url>http://cxf.apache.org</url>
>>>>> +    <parent>
>>>>> +        <groupId>org.apache.cxf</groupId>
>>>>> +        <artifactId>cxf-parent</artifactId>
>>>>> +        <version>3.2.0-SNAPSHOT</version>
>>>>> +        <relativePath>../../../parent/pom.xml</relativePath>
>>>>> +    </parent>
>>>>> +
>>>>> +    <properties>
>>>>> +        <cxf.osgi.export>
>>>>> +            org.apache.cxf.tracing.brave.soap
>>>>> +        </cxf.osgi.export>
>>>>> +        <brave.version>3.15.1</brave.version>
>>>>> +    </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-features-logging</artifactId>
>>>>> +            <version>${project.version}</version>
>>>>> +        </dependency>
>>>>> +        <dependency>
>>>>> +               <groupId>io.zipkin.brave</groupId>
>>>>> +               <artifactId>brave-core</artifactId>
>>>>> +               <version>${brave.version}</version>
>>>>> +        </dependency>
>>>>> +        <dependency>
>>>>> +               <groupId>io.zipkin.brave</groupId>
>>>>> +               <artifactId>brave-http</artifactId>
>>>>> +               <version>${brave.version}</version>
>>>>> +        </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>
>>>>> +        <dependency>
>>>>> +            <groupId>org.apache.cxf</groupId>
>>>>> +            <artifactId>cxf-rt-frontend-jaxws</artifactId>
>>>>> +            <version>${project.version}</version>
>>>>> +            <scope>test</scope>
>>>>> +        </dependency>
>>>>> +    </dependencies>
>>>>> +</project>
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>>>>> brave/soap/CxfHttpClientRequest.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
>> tra
>>>>> cing/brave/soap/CxfHttpClientRequest.java
>>> b/rt/features/tracing-brave/sr
>>>>> c/main/java/org/apache/cxf/tracing/brave/soap/
>> CxfHttpClientRequest.java
>>>>> new file mode 100644
>>>>> index 0000000..78a40fd
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>>>>> cing/brave/soap/CxfHttpClientRequest.java
>>>>> @@ -0,0 +1,49 @@
>>>>> +/**
>>>>> + * 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.soap;
>>>>> +
>>>>> +import java.net.URI;
>>>>> +
>>>>> +import com.github.kristofa.brave.http.HttpClientRequest;
>>>>> +import org.apache.cxf.message.Message;
>>>>> +
>>>>> +public class CxfHttpClientRequest implements HttpClientRequest {
>>>>> +
>>>>> +    private ParsedMessage message;
>>>>> +
>>>>> +    public CxfHttpClientRequest(Message message) {
>>>>> +        this.message = new ParsedMessage(message);
>>>>> +    }
>>>>> +
>>>>> +    @Override
>>>>> +    public URI getUri() {
>>>>> +        return message.getUri();
>>>>> +    }
>>>>> +
>>>>> +    @Override
>>>>> +    public String getHttpMethod() {
>>>>> +        return message.getHttpMethod();
>>>>> +    }
>>>>> +
>>>>> +    @Override
>>>>> +    public void addHeader(String header, String value) {
>>>>> +        message.addHeader(header, value);
>>>>> +    }
>>>>> +
>>>>> +}
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>>>>> brave/soap/CxfServerRequest.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
>> tra
>>>>> cing/brave/soap/CxfServerRequest.java b/rt/features/tracing-brave/sr
>>>>> c/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java
>>>>> new file mode 100644
>>>>> index 0000000..fcc8797
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>>>>> cing/brave/soap/CxfServerRequest.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 org.apache.cxf.tracing.brave.soap;
>>>>> +
>>>>> +import java.net.URI;
>>>>> +
>>>>> +import com.github.kristofa.brave.http.HttpServerRequest;
>>>>> +
>>>>> +public class CxfServerRequest implements HttpServerRequest {
>>>>> +
>>>>> +    private ParsedMessage message;
>>>>> +
>>>>> +    public CxfServerRequest(ParsedMessage message) {
>>>>> +        this.message = message;
>>>>> +    }
>>>>> +
>>>>> +    @Override
>>>>> +    public URI getUri() {
>>>>> +        return message.getUri();
>>>>> +    }
>>>>> +
>>>>> +    @Override
>>>>> +    public String getHttpMethod() {
>>>>> +        return message.getHttpMethod();
>>>>> +    }
>>>>> +
>>>>> +    @Override
>>>>> +    public String getHttpHeaderValue(String headerName) {
>>>>> +        return message.getHeaders().get(headerName);
>>>>> +    }
>>>>> +
>>>>> +}
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>>>>> brave/soap/HttpResponse200.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
>> tra
>>>>> cing/brave/soap/HttpResponse200.java b/rt/features/tracing-brave/sr
>>>>> c/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java
>>>>> new file mode 100644
>>>>> index 0000000..f50dbde
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>>>>> cing/brave/soap/HttpResponse200.java
>>>>> @@ -0,0 +1,28 @@
>>>>> +/**
>>>>> + * 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.soap;
>>>>> +
>>>>> +import com.github.kristofa.brave.http.HttpResponse;
>>>>> +
>>>>> +final class HttpResponse200 implements HttpResponse {
>>>>> +    @Override
>>>>> +    public int getHttpStatusCode() {
>>>>> +        return 200;
>>>>> +    }
>>>>> +}
>>>>> \ No newline at end of file
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>>>>> brave/soap/ParsedMessage.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
>> tra
>>>>> cing/brave/soap/ParsedMessage.java b/rt/features/tracing-brave/sr
>>>>> c/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java
>>>>> new file mode 100644
>>>>> index 0000000..8967375
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>>>>> cing/brave/soap/ParsedMessage.java
>>>>> @@ -0,0 +1,121 @@
>>>>> +/**
>>>>> + * 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.soap;
>>>>> +
>>>>> +import java.net.URI;
>>>>> +import java.net.URISyntaxException;
>>>>> +import java.util.Arrays;
>>>>> +import java.util.HashMap;
>>>>> +import java.util.List;
>>>>> +import java.util.Map;
>>>>> +
>>>>> +import org.apache.cxf.helpers.CastUtils;
>>>>> +import org.apache.cxf.message.Message;
>>>>> +import org.apache.cxf.message.MessageUtils;
>>>>> +
>>>>> +public class ParsedMessage {
>>>>> +
>>>>> +    private Message message;
>>>>> +
>>>>> +    public 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;
>>>>> +    }
>>>>> +
>>>>> +    public 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;
>>>>> +        }
>>>>> +    }
>>>>> +
>>>>> +    public 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().getOutMe
>>>>> ssage();
>>>>> +        } else {
>>>>> +            return isOutbound ? message.getExchange().getInMessage()
>> :
>>>>> message;
>>>>> +        }
>>>>> +    }
>>>>> +
>>>>> +    Map<String, String> getHeaders() {
>>>>> +        Map<String, List<String>> headers = CastUtils.cast((Map<?,
>>>>> ?>)message.get(Message.PROTOCOL_HEADERS));
>>>>> +        Map<String, String> result = new HashMap<>();
>>>>> +        if (headers == null) {
>>>>> +            return result;
>>>>> +        }
>>>>> +        for (Map.Entry<String, List<String>> entry :
>>> headers.entrySet())
>>>>> {
>>>>> +            if (entry.getValue().size() == 1) {
>>>>> +                result.put(entry.getKey(), entry.getValue().get(0));
>>>>> +            } else {
>>>>> +                String[] valueAr = entry.getValue().toArray(new
>>> String[]
>>>>> {});
>>>>> +                result.put(entry.getKey(), valueAr.toString());
>>>>> +            }
>>>>> +        }
>>>>> +        return result;
>>>>> +    }
>>>>> +
>>>>> +    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<String, List<String>>();
>>>>> +            message.put(Message.PROTOCOL_HEADERS, headers);
>>>>> +        }
>>>>> +        headers.put(key, Arrays.asList(value));
>>>>> +    }
>>>>> +
>>>>> +    public String getHttpMethod() {
>>>>> +        ParsedMessage eMessage = new ParsedMessage(getEffectiveMess
>>>>> age());
>>>>> +        return eMessage.safeGet(Message.HTTP_REQUEST_METHOD);
>>>>> +    }
>>>>> +}
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>>>>> brave/soap/TraceFeature.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
>> tra
>>>>> cing/brave/soap/TraceFeature.java b/rt/features/tracing-brave/sr
>>>>> c/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java
>>>>> new file mode 100644
>>>>> index 0000000..fbaca07
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>>>>> cing/brave/soap/TraceFeature.java
>>>>> @@ -0,0 +1,50 @@
>>>>> +/**
>>>>> + * 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.soap;
>>>>> +
>>>>> +import com.github.kristofa.brave.Brave;
>>>>> +import com.github.kristofa.brave.http.DefaultSpanNameProvider;
>>>>> +import org.apache.cxf.Bus;
>>>>> +import org.apache.cxf.annotations.Provider;
>>>>> +import org.apache.cxf.annotations.Provider.Type;
>>>>> +import org.apache.cxf.common.injection.NoJSR250Annotations;
>>>>> +import org.apache.cxf.feature.AbstractFeature;
>>>>> +import org.apache.cxf.interceptor.InterceptorProvider;
>>>>> +
>>>>> +@NoJSR250Annotations
>>>>> +@Provider(value = Type.Feature)
>>>>> +public class TraceFeature extends AbstractFeature {
>>>>> +    private TraceInInterceptor in;
>>>>> +    private TraceOutInterceptor out;
>>>>> +
>>>>> +    public TraceFeature(Brave brave) {
>>>>> +        DefaultSpanNameProvider nameProvider = new
>>>>> DefaultSpanNameProvider();
>>>>> +        in = new TraceInInterceptor(brave, nameProvider);
>>>>> +        out = new TraceOutInterceptor(brave, nameProvider);
>>>>> +    }
>>>>> +
>>>>> +    @Override
>>>>> +    protected void initializeProvider(InterceptorProvider provider,
>>> Bus
>>>>> bus) {
>>>>> +        provider.getInInterceptors().add(in);
>>>>> +        provider.getInFaultInterceptors().add(in);
>>>>> +
>>>>> +        provider.getOutInterceptors().add(out);
>>>>> +        provider.getOutFaultInterceptors().add(out);
>>>>> +    }
>>>>> +}
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>>>>> brave/soap/TraceInInterceptor.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
>> tra
>>>>> cing/brave/soap/TraceInInterceptor.java
>> b/rt/features/tracing-brave/sr
>>>>> c/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java
>>>>> new file mode 100644
>>>>> index 0000000..4b84eb3
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>>>>> cing/brave/soap/TraceInInterceptor.java
>>>>> @@ -0,0 +1,58 @@
>>>>> +/**
>>>>> + * 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.soap;
>>>>> +
>>>>> +import com.github.kristofa.brave.Brave;
>>>>> +import com.github.kristofa.brave.http.HttpClientResponseAdapter;
>>>>> +import com.github.kristofa.brave.http.HttpServerRequestAdapter;
>>>>> +import com.github.kristofa.brave.http.SpanNameProvider;
>>>>> +import org.apache.cxf.common.injection.NoJSR250Annotations;
>>>>> +import org.apache.cxf.interceptor.Fault;
>>>>> +import org.apache.cxf.message.Message;
>>>>> +import org.apache.cxf.message.MessageUtils;
>>>>> +import org.apache.cxf.phase.AbstractPhaseInterceptor;
>>>>> +import org.apache.cxf.phase.Phase;
>>>>> +
>>>>> +/**
>>>>> + *
>>>>> + */
>>>>> +@NoJSR250Annotations
>>>>> +public class TraceInInterceptor extends AbstractPhaseInterceptor<
>>> Message>
>>>>> {
>>>>> +
>>>>> +    private Brave brave;
>>>>> +    private SpanNameProvider spanNameProvider;
>>>>> +
>>>>> +    public TraceInInterceptor(Brave brave, SpanNameProvider
>>>>> spanNameProvider) {
>>>>> +        super(Phase.PRE_INVOKE);
>>>>> +        this.brave = brave;
>>>>> +        this.spanNameProvider = spanNameProvider;
>>>>> +    }
>>>>> +
>>>>> +    public void handleMessage(Message cxfMessage) throws Fault {
>>>>> +        ParsedMessage message = new ParsedMessage(cxfMessage);
>>>>> +        if (MessageUtils.isRequestor(cxfMessage)) {
>>>>> +            brave.clientResponseInterceptor().handle(new
>>>>> HttpClientResponseAdapter(new HttpResponse200()));
>>>>> +        } else {
>>>>> +            HttpServerRequestAdapter adapter =
>>>>> +                new HttpServerRequestAdapter(new
>>>>> CxfServerRequest(message), spanNameProvider);
>>>>> +            brave.serverRequestInterceptor().handle(adapter);
>>>>> +        }
>>>>> +    }
>>>>> +
>>>>> +}
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>>>>> brave/soap/TraceOutInterceptor.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
>> tra
>>>>> cing/brave/soap/TraceOutInterceptor.java
>> b/rt/features/tracing-brave/sr
>>>>> c/main/java/org/apache/cxf/tracing/brave/soap/
>> TraceOutInterceptor.java
>>>>> new file mode 100644
>>>>> index 0000000..17f76d0
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>>>>> cing/brave/soap/TraceOutInterceptor.java
>>>>> @@ -0,0 +1,57 @@
>>>>> +/**
>>>>> + * 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.soap;
>>>>> +
>>>>> +import com.github.kristofa.brave.Brave;
>>>>> +import com.github.kristofa.brave.http.HttpClientRequest;
>>>>> +import com.github.kristofa.brave.http.HttpClientRequestAdapter;
>>>>> +import com.github.kristofa.brave.http.HttpServerResponseAdapter;
>>>>> +import com.github.kristofa.brave.http.SpanNameProvider;
>>>>> +import org.apache.cxf.common.injection.NoJSR250Annotations;
>>>>> +import org.apache.cxf.interceptor.Fault;
>>>>> +import org.apache.cxf.message.Message;
>>>>> +import org.apache.cxf.message.MessageUtils;
>>>>> +import org.apache.cxf.phase.AbstractPhaseInterceptor;
>>>>> +import org.apache.cxf.phase.Phase;
>>>>> +
>>>>> +/**
>>>>> + *
>>>>> + */
>>>>> +@NoJSR250Annotations
>>>>> +public class TraceOutInterceptor extends AbstractPhaseInterceptor<
>>> Message>
>>>>> {
>>>>> +
>>>>> +    private Brave brave;
>>>>> +    private SpanNameProvider spanNameProvider;
>>>>> +
>>>>> +    public TraceOutInterceptor(Brave brave, SpanNameProvider
>>>>> spanNameProvider) {
>>>>> +        super(Phase.PRE_PROTOCOL);
>>>>> +        this.brave = brave;
>>>>> +        this.spanNameProvider = spanNameProvider;
>>>>> +    }
>>>>> +
>>>>> +    public void handleMessage(Message message) throws Fault {
>>>>> +        if (MessageUtils.isRequestor(message)) {
>>>>> +            final HttpClientRequest req = new
>>>>> CxfHttpClientRequest(message);
>>>>> +            brave.clientRequestInterceptor().handle(new
>>>>> HttpClientRequestAdapter(req, spanNameProvider));
>>>>> +        } else {
>>>>> +            brave.serverResponseInterceptor().handle(new
>>>>> HttpServerResponseAdapter(new HttpResponse200()));
>>>>> +        }
>>>>> +    }
>>>>> +
>>>>> +}
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
>>>>> brave/soap/BraveTraceTest.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/
>> tra
>>>>> cing/brave/soap/BraveTraceTest.java b/rt/features/tracing-brave/sr
>>>>> c/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java
>>>>> new file mode 100644
>>>>> index 0000000..5bac5f7
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>>>>> cing/brave/soap/BraveTraceTest.java
>>>>> @@ -0,0 +1,99 @@
>>>>> +/**
>>>>> + * 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.soap;
>>>>> +
>>>>> +import java.util.ArrayList;
>>>>> +import java.util.Arrays;
>>>>> +import java.util.List;
>>>>> +
>>>>> +import com.github.kristofa.brave.Brave;
>>>>> +import org.apache.cxf.endpoint.Server;
>>>>> +import org.apache.cxf.ext.logging.LoggingFeature;
>>>>> +import org.apache.cxf.feature.Feature;
>>>>> +import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
>>>>> +import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
>>>>> +import org.junit.After;
>>>>> +import org.junit.Assert;
>>>>> +import org.junit.Before;
>>>>> +import org.junit.Test;
>>>>> +import zipkin.Span;
>>>>> +import zipkin.reporter.Reporter;
>>>>> +
>>>>> +public class BraveTraceTest {
>>>>> +
>>>>> +    private static final String ADDRESS = "http://localhost:8182";
>>>>> +    private Server server;
>>>>> +    private TraceFeature logging;
>>>>> +    private Localreporter localReporter;
>>>>> +
>>>>> +    @Before
>>>>> +    public void startServer() {
>>>>> +        localReporter = new Localreporter();
>>>>> +        logging = createLoggingFeature(localReporter);
>>>>> +        server = createServer(logging);
>>>>> +    }
>>>>> +
>>>>> +    @Test
>>>>> +    public void testMyService() {
>>>>> +        MyService myService = createProxy(logging);
>>>>> +        myService.echo("test");
>>>>> +        for (Span span : localReporter.spans) {
>>>>> +            System.out.println(span);
>>>>> +        }
>>>>> +        Assert.assertEquals(2, localReporter.spans.size());
>>>>> +
>>>>> +    }
>>>>> +
>>>>> +    @After
>>>>> +    public void stopServer() {
>>>>> +        server.destroy();
>>>>> +    }
>>>>> +
>>>>> +    private static Server createServer(Feature logging) {
>>>>> +        JaxWsServerFactoryBean factory = new
>> JaxWsServerFactoryBean();
>>>>> +        factory.setAddress(ADDRESS);
>>>>> +        factory.setServiceBean(new MyServiceImpl());
>>>>> +        factory.setFeatures(Arrays.asList(logging));
>>>>> +        return factory.create();
>>>>> +    }
>>>>> +
>>>>> +    private static MyService createProxy(Feature trace) {
>>>>> +        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>>>>> +        factory.setServiceClass(MyService.class);
>>>>> +        factory.setAddress(ADDRESS);
>>>>> +        factory.setFeatures(Arrays.asList(trace, new
>>> LoggingFeature()));
>>>>> +        return (MyService)factory.create();
>>>>> +    }
>>>>> +
>>>>> +    private static TraceFeature createLoggingFeature(Reporter<Span>
>>>>> reporter) {
>>>>> +        Brave brave = new Brave.Builder("myservice").rep
>>>>> orter(reporter).build();
>>>>> +        return new TraceFeature(brave);
>>>>> +    }
>>>>> +
>>>>> +    static final class Localreporter implements Reporter<Span> {
>>>>> +        List<Span> spans = new ArrayList<Span>();
>>>>> +
>>>>> +        @Override
>>>>> +        public void report(Span span) {
>>>>> +            spans.add(span);
>>>>> +        }
>>>>> +
>>>>> +    }
>>>>> +
>>>>> +}
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
>>>>> brave/soap/LoggingSpanNameProvider.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/
>> tra
>>>>> cing/brave/soap/LoggingSpanNameProvider.java
>>>>> b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>>>>> cing/brave/soap/LoggingSpanNameProvider.java
>>>>> new file mode 100644
>>>>> index 0000000..86fa25a
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>>>>> cing/brave/soap/LoggingSpanNameProvider.java
>>>>> @@ -0,0 +1,31 @@
>>>>> +/**
>>>>> + * 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.soap;
>>>>> +
>>>>> +import com.github.kristofa.brave.http.HttpRequest;
>>>>> +import com.github.kristofa.brave.http.SpanNameProvider;
>>>>> +
>>>>> +public class LoggingSpanNameProvider implements SpanNameProvider {
>>>>> +
>>>>> +    @Override
>>>>> +    public String spanName(HttpRequest request) {
>>>>> +        return (request instanceof SpanNameProvider) ?
>>>>> ((SpanNameProvider)request).spanName(request) : "";
>>>>> +    }
>>>>> +
>>>>> +}
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
>>>>> brave/soap/MyService.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/
>>> tracing/brave/soap/MyService.java
>>>>> b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>>>>> cing/brave/soap/MyService.java
>>>>> new file mode 100644
>>>>> index 0000000..2001164
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>>>>> cing/brave/soap/MyService.java
>>>>> @@ -0,0 +1,26 @@
>>>>> +/**
>>>>> + * 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.soap;
>>>>> +
>>>>> +import javax.jws.WebService;
>>>>> +
>>>>> +@WebService
>>>>> +public interface MyService {
>>>>> +    String echo(String msg);
>>>>> +}
>>>>>
>>>>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>>>>> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
>>>>> brave/soap/MyServiceImpl.java
>>>>> ------------------------------------------------------------
>> ----------
>>>>> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/
>> tra
>>>>> cing/brave/soap/MyServiceImpl.java b/rt/features/tracing-brave/sr
>>>>> c/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java
>>>>> new file mode 100644
>>>>> index 0000000..e9f901a
>>>>> --- /dev/null
>>>>> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>>>>> cing/brave/soap/MyServiceImpl.java
>>>>> @@ -0,0 +1,28 @@
>>>>> +/**
>>>>> + * 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.soap;
>>>>> +
>>>>> +public class MyServiceImpl implements MyService {
>>>>> +
>>>>> +    @Override
>>>>> +    public String echo(String msg) {
>>>>> +        return msg;
>>>>> +    }
>>>>> +
>>>>> +}
>>>>>
>>>>>
>>>>
>>>> --
>>>> Sergey Beryozkin
>>>>
>>>> Talend Community Coders
>>>> http://coders.talend.com/
>>>>
>>>>
>>>
>>>
>>> --
>>> --
>>> Christian Schneider
>>> http://www.liquid-reality.de
>>> <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e
>>> 46&URL=http%3a%2f%2fwww.liquid-reality.de>
>>>
>>> Open Source Architect
>>> http://www.talend.com
>>> <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e
>>> 46&URL=http%3a%2f%2fwww.talend.com>
>>>
>>
>
>
>



Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Christian Schneider <ch...@die-schneider.net>.
Damn ... I just found there is also general CXF support for brave at
https://github.com/openzipkin/brave/tree/master/brave-cxf3 . So maybe this
already solved the problem before.
We should decide how to proceed.

I think one approach is to help at brave-cxf3 to make it as good as
possible and revert the cxf module I created.
The other is to focus on the cxf trace zipkin module .. Actually I am not
sure what is the better option.

Any opinions?

Christian

2016-12-06 20:49 GMT+01:00 Andrey Redko <dr...@gmail.com>:

> That's right, the JAX-RS part should be supported by Brave already thanks
> to dedicated CXF integration (I was involved in late-stage discussions for
> the PR in question but not in the implementation).
>
> Best Regards,
>     Andriy Redko
>
> On Tue, Dec 6, 2016 at 12:09 PM, Christian Schneider <
> chris@die-schneider.net> wrote:
>
> > My orignal plan was to just support SOAP as REST is well supported by
> brave
> > rest support already.
> > In the end my code was able to support both REST and SOAP without much
> > overhead so I removed the soap package again.
> >
> > Christian
> >
> > 2016-12-06 14:41 GMT+01:00 Sergey Beryozkin <sb...@gmail.com>:
> >
> > > Christian, what is SOAP specific in this code ?
> > > Looks like that can work with JAX-RS too ?
> > >
> > > Usually we try to accommodate both frontends, example, Andriy Redko
> made
> > > sure HTrace interceptors work for JAXWS, similarly for Bean validation
> > >
> > > Sergey
> > >
> > >
> > >
> > > On 06/12/16 13:36, cschneider@apache.org wrote:
> > >
> > >> Repository: cxf
> > >> Updated Branches:
> > >>   refs/heads/master 892a4ca84 -> fd77d3f33
> > >>
> > >>
> > >> [CXF-7164] Support tracing using Zipkin Brave
> > >>
> > >>
> > >> Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
> > >> Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fd77d3f3
> > >> Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fd77d3f3
> > >> Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fd77d3f3
> > >>
> > >> Branch: refs/heads/master
> > >> Commit: fd77d3f3380f805db3547d37cbb2ff72bd033ad0
> > >> Parents: 892a4ca
> > >> Author: Christian Schneider <ch...@die-schneider.net>
> > >> Authored: Tue Dec 6 14:35:35 2016 +0100
> > >> Committer: Christian Schneider <ch...@die-schneider.net>
> > >> Committed: Tue Dec 6 14:36:01 2016 +0100
> > >>
> > >> ------------------------------------------------------------
> ----------
> > >>  rt/features/pom.xml                             |   1 +
> > >>  rt/features/tracing-brave/pom.xml               |  87 +++++++++++++
> > >>  .../brave/soap/CxfHttpClientRequest.java        |  49 ++++++++
> > >>  .../tracing/brave/soap/CxfServerRequest.java    |  48 ++++++++
> > >>  .../cxf/tracing/brave/soap/HttpResponse200.java |  28 +++++
> > >>  .../cxf/tracing/brave/soap/ParsedMessage.java   | 121
> > >> +++++++++++++++++++
> > >>  .../cxf/tracing/brave/soap/TraceFeature.java    |  50 ++++++++
> > >>  .../tracing/brave/soap/TraceInInterceptor.java  |  58 +++++++++
> > >>  .../tracing/brave/soap/TraceOutInterceptor.java |  57 +++++++++
> > >>  .../cxf/tracing/brave/soap/BraveTraceTest.java  |  99
> +++++++++++++++
> > >>  .../brave/soap/LoggingSpanNameProvider.java     |  31 +++++
> > >>  .../cxf/tracing/brave/soap/MyService.java       |  26 ++++
> > >>  .../cxf/tracing/brave/soap/MyServiceImpl.java   |  28 +++++
> > >>  13 files changed, 683 insertions(+)
> > >> ------------------------------------------------------------
> ----------
> > >>
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/pom.xml
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/pom.xml b/rt/features/pom.xml
> > >> index 0365bf6..a4cfdff 100644
> > >> --- a/rt/features/pom.xml
> > >> +++ b/rt/features/pom.xml
> > >> @@ -34,5 +34,6 @@
> > >>          <module>logging</module>
> > >>          <module>metrics</module>
> > >>          <module>throttling</module>
> > >> +        <module>tracing-brave</module>
> > >>      </modules>
> > >>  </project>
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/pom.xml
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/pom.xml
> > >> b/rt/features/tracing-brave/pom.xml
> > >> new file mode 100644
> > >> index 0000000..9af22e4
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/pom.xml
> > >> @@ -0,0 +1,87 @@
> > >> +<?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://mav
> > >> en.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
> > >> +    <modelVersion>4.0.0</modelVersion>
> > >> +    <artifactId>cxf-rt-features-tracing-brave</artifactId>
> > >> +    <packaging>jar</packaging>
> > >> +    <name>Apache CXF Tracing using Zipkin Brave</name>
> > >> +    <url>http://cxf.apache.org</url>
> > >> +    <parent>
> > >> +        <groupId>org.apache.cxf</groupId>
> > >> +        <artifactId>cxf-parent</artifactId>
> > >> +        <version>3.2.0-SNAPSHOT</version>
> > >> +        <relativePath>../../../parent/pom.xml</relativePath>
> > >> +    </parent>
> > >> +
> > >> +    <properties>
> > >> +        <cxf.osgi.export>
> > >> +            org.apache.cxf.tracing.brave.soap
> > >> +        </cxf.osgi.export>
> > >> +        <brave.version>3.15.1</brave.version>
> > >> +    </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-features-logging</artifactId>
> > >> +            <version>${project.version}</version>
> > >> +        </dependency>
> > >> +        <dependency>
> > >> +               <groupId>io.zipkin.brave</groupId>
> > >> +               <artifactId>brave-core</artifactId>
> > >> +               <version>${brave.version}</version>
> > >> +        </dependency>
> > >> +        <dependency>
> > >> +               <groupId>io.zipkin.brave</groupId>
> > >> +               <artifactId>brave-http</artifactId>
> > >> +               <version>${brave.version}</version>
> > >> +        </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>
> > >> +        <dependency>
> > >> +            <groupId>org.apache.cxf</groupId>
> > >> +            <artifactId>cxf-rt-frontend-jaxws</artifactId>
> > >> +            <version>${project.version}</version>
> > >> +            <scope>test</scope>
> > >> +        </dependency>
> > >> +    </dependencies>
> > >> +</project>
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> > >> brave/soap/CxfHttpClientRequest.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
> tra
> > >> cing/brave/soap/CxfHttpClientRequest.java
> > b/rt/features/tracing-brave/sr
> > >> c/main/java/org/apache/cxf/tracing/brave/soap/
> CxfHttpClientRequest.java
> > >> new file mode 100644
> > >> index 0000000..78a40fd
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> > >> cing/brave/soap/CxfHttpClientRequest.java
> > >> @@ -0,0 +1,49 @@
> > >> +/**
> > >> + * 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.soap;
> > >> +
> > >> +import java.net.URI;
> > >> +
> > >> +import com.github.kristofa.brave.http.HttpClientRequest;
> > >> +import org.apache.cxf.message.Message;
> > >> +
> > >> +public class CxfHttpClientRequest implements HttpClientRequest {
> > >> +
> > >> +    private ParsedMessage message;
> > >> +
> > >> +    public CxfHttpClientRequest(Message message) {
> > >> +        this.message = new ParsedMessage(message);
> > >> +    }
> > >> +
> > >> +    @Override
> > >> +    public URI getUri() {
> > >> +        return message.getUri();
> > >> +    }
> > >> +
> > >> +    @Override
> > >> +    public String getHttpMethod() {
> > >> +        return message.getHttpMethod();
> > >> +    }
> > >> +
> > >> +    @Override
> > >> +    public void addHeader(String header, String value) {
> > >> +        message.addHeader(header, value);
> > >> +    }
> > >> +
> > >> +}
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> > >> brave/soap/CxfServerRequest.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
> tra
> > >> cing/brave/soap/CxfServerRequest.java b/rt/features/tracing-brave/sr
> > >> c/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java
> > >> new file mode 100644
> > >> index 0000000..fcc8797
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> > >> cing/brave/soap/CxfServerRequest.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 org.apache.cxf.tracing.brave.soap;
> > >> +
> > >> +import java.net.URI;
> > >> +
> > >> +import com.github.kristofa.brave.http.HttpServerRequest;
> > >> +
> > >> +public class CxfServerRequest implements HttpServerRequest {
> > >> +
> > >> +    private ParsedMessage message;
> > >> +
> > >> +    public CxfServerRequest(ParsedMessage message) {
> > >> +        this.message = message;
> > >> +    }
> > >> +
> > >> +    @Override
> > >> +    public URI getUri() {
> > >> +        return message.getUri();
> > >> +    }
> > >> +
> > >> +    @Override
> > >> +    public String getHttpMethod() {
> > >> +        return message.getHttpMethod();
> > >> +    }
> > >> +
> > >> +    @Override
> > >> +    public String getHttpHeaderValue(String headerName) {
> > >> +        return message.getHeaders().get(headerName);
> > >> +    }
> > >> +
> > >> +}
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> > >> brave/soap/HttpResponse200.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
> tra
> > >> cing/brave/soap/HttpResponse200.java b/rt/features/tracing-brave/sr
> > >> c/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java
> > >> new file mode 100644
> > >> index 0000000..f50dbde
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> > >> cing/brave/soap/HttpResponse200.java
> > >> @@ -0,0 +1,28 @@
> > >> +/**
> > >> + * 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.soap;
> > >> +
> > >> +import com.github.kristofa.brave.http.HttpResponse;
> > >> +
> > >> +final class HttpResponse200 implements HttpResponse {
> > >> +    @Override
> > >> +    public int getHttpStatusCode() {
> > >> +        return 200;
> > >> +    }
> > >> +}
> > >> \ No newline at end of file
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> > >> brave/soap/ParsedMessage.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
> tra
> > >> cing/brave/soap/ParsedMessage.java b/rt/features/tracing-brave/sr
> > >> c/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java
> > >> new file mode 100644
> > >> index 0000000..8967375
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> > >> cing/brave/soap/ParsedMessage.java
> > >> @@ -0,0 +1,121 @@
> > >> +/**
> > >> + * 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.soap;
> > >> +
> > >> +import java.net.URI;
> > >> +import java.net.URISyntaxException;
> > >> +import java.util.Arrays;
> > >> +import java.util.HashMap;
> > >> +import java.util.List;
> > >> +import java.util.Map;
> > >> +
> > >> +import org.apache.cxf.helpers.CastUtils;
> > >> +import org.apache.cxf.message.Message;
> > >> +import org.apache.cxf.message.MessageUtils;
> > >> +
> > >> +public class ParsedMessage {
> > >> +
> > >> +    private Message message;
> > >> +
> > >> +    public 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;
> > >> +    }
> > >> +
> > >> +    public 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;
> > >> +        }
> > >> +    }
> > >> +
> > >> +    public 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().getOutMe
> > >> ssage();
> > >> +        } else {
> > >> +            return isOutbound ? message.getExchange().getInMessage()
> :
> > >> message;
> > >> +        }
> > >> +    }
> > >> +
> > >> +    Map<String, String> getHeaders() {
> > >> +        Map<String, List<String>> headers = CastUtils.cast((Map<?,
> > >> ?>)message.get(Message.PROTOCOL_HEADERS));
> > >> +        Map<String, String> result = new HashMap<>();
> > >> +        if (headers == null) {
> > >> +            return result;
> > >> +        }
> > >> +        for (Map.Entry<String, List<String>> entry :
> > headers.entrySet())
> > >> {
> > >> +            if (entry.getValue().size() == 1) {
> > >> +                result.put(entry.getKey(), entry.getValue().get(0));
> > >> +            } else {
> > >> +                String[] valueAr = entry.getValue().toArray(new
> > String[]
> > >> {});
> > >> +                result.put(entry.getKey(), valueAr.toString());
> > >> +            }
> > >> +        }
> > >> +        return result;
> > >> +    }
> > >> +
> > >> +    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<String, List<String>>();
> > >> +            message.put(Message.PROTOCOL_HEADERS, headers);
> > >> +        }
> > >> +        headers.put(key, Arrays.asList(value));
> > >> +    }
> > >> +
> > >> +    public String getHttpMethod() {
> > >> +        ParsedMessage eMessage = new ParsedMessage(getEffectiveMess
> > >> age());
> > >> +        return eMessage.safeGet(Message.HTTP_REQUEST_METHOD);
> > >> +    }
> > >> +}
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> > >> brave/soap/TraceFeature.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
> tra
> > >> cing/brave/soap/TraceFeature.java b/rt/features/tracing-brave/sr
> > >> c/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java
> > >> new file mode 100644
> > >> index 0000000..fbaca07
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> > >> cing/brave/soap/TraceFeature.java
> > >> @@ -0,0 +1,50 @@
> > >> +/**
> > >> + * 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.soap;
> > >> +
> > >> +import com.github.kristofa.brave.Brave;
> > >> +import com.github.kristofa.brave.http.DefaultSpanNameProvider;
> > >> +import org.apache.cxf.Bus;
> > >> +import org.apache.cxf.annotations.Provider;
> > >> +import org.apache.cxf.annotations.Provider.Type;
> > >> +import org.apache.cxf.common.injection.NoJSR250Annotations;
> > >> +import org.apache.cxf.feature.AbstractFeature;
> > >> +import org.apache.cxf.interceptor.InterceptorProvider;
> > >> +
> > >> +@NoJSR250Annotations
> > >> +@Provider(value = Type.Feature)
> > >> +public class TraceFeature extends AbstractFeature {
> > >> +    private TraceInInterceptor in;
> > >> +    private TraceOutInterceptor out;
> > >> +
> > >> +    public TraceFeature(Brave brave) {
> > >> +        DefaultSpanNameProvider nameProvider = new
> > >> DefaultSpanNameProvider();
> > >> +        in = new TraceInInterceptor(brave, nameProvider);
> > >> +        out = new TraceOutInterceptor(brave, nameProvider);
> > >> +    }
> > >> +
> > >> +    @Override
> > >> +    protected void initializeProvider(InterceptorProvider provider,
> > Bus
> > >> bus) {
> > >> +        provider.getInInterceptors().add(in);
> > >> +        provider.getInFaultInterceptors().add(in);
> > >> +
> > >> +        provider.getOutInterceptors().add(out);
> > >> +        provider.getOutFaultInterceptors().add(out);
> > >> +    }
> > >> +}
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> > >> brave/soap/TraceInInterceptor.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
> tra
> > >> cing/brave/soap/TraceInInterceptor.java
> b/rt/features/tracing-brave/sr
> > >> c/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java
> > >> new file mode 100644
> > >> index 0000000..4b84eb3
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> > >> cing/brave/soap/TraceInInterceptor.java
> > >> @@ -0,0 +1,58 @@
> > >> +/**
> > >> + * 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.soap;
> > >> +
> > >> +import com.github.kristofa.brave.Brave;
> > >> +import com.github.kristofa.brave.http.HttpClientResponseAdapter;
> > >> +import com.github.kristofa.brave.http.HttpServerRequestAdapter;
> > >> +import com.github.kristofa.brave.http.SpanNameProvider;
> > >> +import org.apache.cxf.common.injection.NoJSR250Annotations;
> > >> +import org.apache.cxf.interceptor.Fault;
> > >> +import org.apache.cxf.message.Message;
> > >> +import org.apache.cxf.message.MessageUtils;
> > >> +import org.apache.cxf.phase.AbstractPhaseInterceptor;
> > >> +import org.apache.cxf.phase.Phase;
> > >> +
> > >> +/**
> > >> + *
> > >> + */
> > >> +@NoJSR250Annotations
> > >> +public class TraceInInterceptor extends AbstractPhaseInterceptor<
> > Message>
> > >> {
> > >> +
> > >> +    private Brave brave;
> > >> +    private SpanNameProvider spanNameProvider;
> > >> +
> > >> +    public TraceInInterceptor(Brave brave, SpanNameProvider
> > >> spanNameProvider) {
> > >> +        super(Phase.PRE_INVOKE);
> > >> +        this.brave = brave;
> > >> +        this.spanNameProvider = spanNameProvider;
> > >> +    }
> > >> +
> > >> +    public void handleMessage(Message cxfMessage) throws Fault {
> > >> +        ParsedMessage message = new ParsedMessage(cxfMessage);
> > >> +        if (MessageUtils.isRequestor(cxfMessage)) {
> > >> +            brave.clientResponseInterceptor().handle(new
> > >> HttpClientResponseAdapter(new HttpResponse200()));
> > >> +        } else {
> > >> +            HttpServerRequestAdapter adapter =
> > >> +                new HttpServerRequestAdapter(new
> > >> CxfServerRequest(message), spanNameProvider);
> > >> +            brave.serverRequestInterceptor().handle(adapter);
> > >> +        }
> > >> +    }
> > >> +
> > >> +}
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> > >> brave/soap/TraceOutInterceptor.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/
> tra
> > >> cing/brave/soap/TraceOutInterceptor.java
> b/rt/features/tracing-brave/sr
> > >> c/main/java/org/apache/cxf/tracing/brave/soap/
> TraceOutInterceptor.java
> > >> new file mode 100644
> > >> index 0000000..17f76d0
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> > >> cing/brave/soap/TraceOutInterceptor.java
> > >> @@ -0,0 +1,57 @@
> > >> +/**
> > >> + * 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.soap;
> > >> +
> > >> +import com.github.kristofa.brave.Brave;
> > >> +import com.github.kristofa.brave.http.HttpClientRequest;
> > >> +import com.github.kristofa.brave.http.HttpClientRequestAdapter;
> > >> +import com.github.kristofa.brave.http.HttpServerResponseAdapter;
> > >> +import com.github.kristofa.brave.http.SpanNameProvider;
> > >> +import org.apache.cxf.common.injection.NoJSR250Annotations;
> > >> +import org.apache.cxf.interceptor.Fault;
> > >> +import org.apache.cxf.message.Message;
> > >> +import org.apache.cxf.message.MessageUtils;
> > >> +import org.apache.cxf.phase.AbstractPhaseInterceptor;
> > >> +import org.apache.cxf.phase.Phase;
> > >> +
> > >> +/**
> > >> + *
> > >> + */
> > >> +@NoJSR250Annotations
> > >> +public class TraceOutInterceptor extends AbstractPhaseInterceptor<
> > Message>
> > >> {
> > >> +
> > >> +    private Brave brave;
> > >> +    private SpanNameProvider spanNameProvider;
> > >> +
> > >> +    public TraceOutInterceptor(Brave brave, SpanNameProvider
> > >> spanNameProvider) {
> > >> +        super(Phase.PRE_PROTOCOL);
> > >> +        this.brave = brave;
> > >> +        this.spanNameProvider = spanNameProvider;
> > >> +    }
> > >> +
> > >> +    public void handleMessage(Message message) throws Fault {
> > >> +        if (MessageUtils.isRequestor(message)) {
> > >> +            final HttpClientRequest req = new
> > >> CxfHttpClientRequest(message);
> > >> +            brave.clientRequestInterceptor().handle(new
> > >> HttpClientRequestAdapter(req, spanNameProvider));
> > >> +        } else {
> > >> +            brave.serverResponseInterceptor().handle(new
> > >> HttpServerResponseAdapter(new HttpResponse200()));
> > >> +        }
> > >> +    }
> > >> +
> > >> +}
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
> > >> brave/soap/BraveTraceTest.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/
> tra
> > >> cing/brave/soap/BraveTraceTest.java b/rt/features/tracing-brave/sr
> > >> c/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java
> > >> new file mode 100644
> > >> index 0000000..5bac5f7
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> > >> cing/brave/soap/BraveTraceTest.java
> > >> @@ -0,0 +1,99 @@
> > >> +/**
> > >> + * 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.soap;
> > >> +
> > >> +import java.util.ArrayList;
> > >> +import java.util.Arrays;
> > >> +import java.util.List;
> > >> +
> > >> +import com.github.kristofa.brave.Brave;
> > >> +import org.apache.cxf.endpoint.Server;
> > >> +import org.apache.cxf.ext.logging.LoggingFeature;
> > >> +import org.apache.cxf.feature.Feature;
> > >> +import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
> > >> +import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
> > >> +import org.junit.After;
> > >> +import org.junit.Assert;
> > >> +import org.junit.Before;
> > >> +import org.junit.Test;
> > >> +import zipkin.Span;
> > >> +import zipkin.reporter.Reporter;
> > >> +
> > >> +public class BraveTraceTest {
> > >> +
> > >> +    private static final String ADDRESS = "http://localhost:8182";
> > >> +    private Server server;
> > >> +    private TraceFeature logging;
> > >> +    private Localreporter localReporter;
> > >> +
> > >> +    @Before
> > >> +    public void startServer() {
> > >> +        localReporter = new Localreporter();
> > >> +        logging = createLoggingFeature(localReporter);
> > >> +        server = createServer(logging);
> > >> +    }
> > >> +
> > >> +    @Test
> > >> +    public void testMyService() {
> > >> +        MyService myService = createProxy(logging);
> > >> +        myService.echo("test");
> > >> +        for (Span span : localReporter.spans) {
> > >> +            System.out.println(span);
> > >> +        }
> > >> +        Assert.assertEquals(2, localReporter.spans.size());
> > >> +
> > >> +    }
> > >> +
> > >> +    @After
> > >> +    public void stopServer() {
> > >> +        server.destroy();
> > >> +    }
> > >> +
> > >> +    private static Server createServer(Feature logging) {
> > >> +        JaxWsServerFactoryBean factory = new
> JaxWsServerFactoryBean();
> > >> +        factory.setAddress(ADDRESS);
> > >> +        factory.setServiceBean(new MyServiceImpl());
> > >> +        factory.setFeatures(Arrays.asList(logging));
> > >> +        return factory.create();
> > >> +    }
> > >> +
> > >> +    private static MyService createProxy(Feature trace) {
> > >> +        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> > >> +        factory.setServiceClass(MyService.class);
> > >> +        factory.setAddress(ADDRESS);
> > >> +        factory.setFeatures(Arrays.asList(trace, new
> > LoggingFeature()));
> > >> +        return (MyService)factory.create();
> > >> +    }
> > >> +
> > >> +    private static TraceFeature createLoggingFeature(Reporter<Span>
> > >> reporter) {
> > >> +        Brave brave = new Brave.Builder("myservice").rep
> > >> orter(reporter).build();
> > >> +        return new TraceFeature(brave);
> > >> +    }
> > >> +
> > >> +    static final class Localreporter implements Reporter<Span> {
> > >> +        List<Span> spans = new ArrayList<Span>();
> > >> +
> > >> +        @Override
> > >> +        public void report(Span span) {
> > >> +            spans.add(span);
> > >> +        }
> > >> +
> > >> +    }
> > >> +
> > >> +}
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
> > >> brave/soap/LoggingSpanNameProvider.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/
> tra
> > >> cing/brave/soap/LoggingSpanNameProvider.java
> > >> b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> > >> cing/brave/soap/LoggingSpanNameProvider.java
> > >> new file mode 100644
> > >> index 0000000..86fa25a
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> > >> cing/brave/soap/LoggingSpanNameProvider.java
> > >> @@ -0,0 +1,31 @@
> > >> +/**
> > >> + * 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.soap;
> > >> +
> > >> +import com.github.kristofa.brave.http.HttpRequest;
> > >> +import com.github.kristofa.brave.http.SpanNameProvider;
> > >> +
> > >> +public class LoggingSpanNameProvider implements SpanNameProvider {
> > >> +
> > >> +    @Override
> > >> +    public String spanName(HttpRequest request) {
> > >> +        return (request instanceof SpanNameProvider) ?
> > >> ((SpanNameProvider)request).spanName(request) : "";
> > >> +    }
> > >> +
> > >> +}
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
> > >> brave/soap/MyService.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/
> > tracing/brave/soap/MyService.java
> > >> b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> > >> cing/brave/soap/MyService.java
> > >> new file mode 100644
> > >> index 0000000..2001164
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> > >> cing/brave/soap/MyService.java
> > >> @@ -0,0 +1,26 @@
> > >> +/**
> > >> + * 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.soap;
> > >> +
> > >> +import javax.jws.WebService;
> > >> +
> > >> +@WebService
> > >> +public interface MyService {
> > >> +    String echo(String msg);
> > >> +}
> > >>
> > >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> > >> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
> > >> brave/soap/MyServiceImpl.java
> > >> ------------------------------------------------------------
> ----------
> > >> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/
> tra
> > >> cing/brave/soap/MyServiceImpl.java b/rt/features/tracing-brave/sr
> > >> c/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java
> > >> new file mode 100644
> > >> index 0000000..e9f901a
> > >> --- /dev/null
> > >> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> > >> cing/brave/soap/MyServiceImpl.java
> > >> @@ -0,0 +1,28 @@
> > >> +/**
> > >> + * 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.soap;
> > >> +
> > >> +public class MyServiceImpl implements MyService {
> > >> +
> > >> +    @Override
> > >> +    public String echo(String msg) {
> > >> +        return msg;
> > >> +    }
> > >> +
> > >> +}
> > >>
> > >>
> > >
> > > --
> > > Sergey Beryozkin
> > >
> > > Talend Community Coders
> > > http://coders.talend.com/
> > >
> > >
> >
> >
> > --
> > --
> > Christian Schneider
> > http://www.liquid-reality.de
> > <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e
> > 46&URL=http%3a%2f%2fwww.liquid-reality.de>
> >
> > Open Source Architect
> > http://www.talend.com
> > <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e
> > 46&URL=http%3a%2f%2fwww.talend.com>
> >
>



-- 
-- 
Christian Schneider
http://www.liquid-reality.de
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.liquid-reality.de>

Open Source Architect
http://www.talend.com
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.talend.com>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Andrey Redko <dr...@gmail.com>.
That's right, the JAX-RS part should be supported by Brave already thanks
to dedicated CXF integration (I was involved in late-stage discussions for
the PR in question but not in the implementation).

Best Regards,
    Andriy Redko

On Tue, Dec 6, 2016 at 12:09 PM, Christian Schneider <
chris@die-schneider.net> wrote:

> My orignal plan was to just support SOAP as REST is well supported by brave
> rest support already.
> In the end my code was able to support both REST and SOAP without much
> overhead so I removed the soap package again.
>
> Christian
>
> 2016-12-06 14:41 GMT+01:00 Sergey Beryozkin <sb...@gmail.com>:
>
> > Christian, what is SOAP specific in this code ?
> > Looks like that can work with JAX-RS too ?
> >
> > Usually we try to accommodate both frontends, example, Andriy Redko made
> > sure HTrace interceptors work for JAXWS, similarly for Bean validation
> >
> > Sergey
> >
> >
> >
> > On 06/12/16 13:36, cschneider@apache.org wrote:
> >
> >> Repository: cxf
> >> Updated Branches:
> >>   refs/heads/master 892a4ca84 -> fd77d3f33
> >>
> >>
> >> [CXF-7164] Support tracing using Zipkin Brave
> >>
> >>
> >> Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
> >> Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fd77d3f3
> >> Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fd77d3f3
> >> Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fd77d3f3
> >>
> >> Branch: refs/heads/master
> >> Commit: fd77d3f3380f805db3547d37cbb2ff72bd033ad0
> >> Parents: 892a4ca
> >> Author: Christian Schneider <ch...@die-schneider.net>
> >> Authored: Tue Dec 6 14:35:35 2016 +0100
> >> Committer: Christian Schneider <ch...@die-schneider.net>
> >> Committed: Tue Dec 6 14:36:01 2016 +0100
> >>
> >> ----------------------------------------------------------------------
> >>  rt/features/pom.xml                             |   1 +
> >>  rt/features/tracing-brave/pom.xml               |  87 +++++++++++++
> >>  .../brave/soap/CxfHttpClientRequest.java        |  49 ++++++++
> >>  .../tracing/brave/soap/CxfServerRequest.java    |  48 ++++++++
> >>  .../cxf/tracing/brave/soap/HttpResponse200.java |  28 +++++
> >>  .../cxf/tracing/brave/soap/ParsedMessage.java   | 121
> >> +++++++++++++++++++
> >>  .../cxf/tracing/brave/soap/TraceFeature.java    |  50 ++++++++
> >>  .../tracing/brave/soap/TraceInInterceptor.java  |  58 +++++++++
> >>  .../tracing/brave/soap/TraceOutInterceptor.java |  57 +++++++++
> >>  .../cxf/tracing/brave/soap/BraveTraceTest.java  |  99 +++++++++++++++
> >>  .../brave/soap/LoggingSpanNameProvider.java     |  31 +++++
> >>  .../cxf/tracing/brave/soap/MyService.java       |  26 ++++
> >>  .../cxf/tracing/brave/soap/MyServiceImpl.java   |  28 +++++
> >>  13 files changed, 683 insertions(+)
> >> ----------------------------------------------------------------------
> >>
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/pom.xml
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/pom.xml b/rt/features/pom.xml
> >> index 0365bf6..a4cfdff 100644
> >> --- a/rt/features/pom.xml
> >> +++ b/rt/features/pom.xml
> >> @@ -34,5 +34,6 @@
> >>          <module>logging</module>
> >>          <module>metrics</module>
> >>          <module>throttling</module>
> >> +        <module>tracing-brave</module>
> >>      </modules>
> >>  </project>
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/pom.xml
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/pom.xml
> >> b/rt/features/tracing-brave/pom.xml
> >> new file mode 100644
> >> index 0000000..9af22e4
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/pom.xml
> >> @@ -0,0 +1,87 @@
> >> +<?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://mav
> >> en.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
> >> +    <modelVersion>4.0.0</modelVersion>
> >> +    <artifactId>cxf-rt-features-tracing-brave</artifactId>
> >> +    <packaging>jar</packaging>
> >> +    <name>Apache CXF Tracing using Zipkin Brave</name>
> >> +    <url>http://cxf.apache.org</url>
> >> +    <parent>
> >> +        <groupId>org.apache.cxf</groupId>
> >> +        <artifactId>cxf-parent</artifactId>
> >> +        <version>3.2.0-SNAPSHOT</version>
> >> +        <relativePath>../../../parent/pom.xml</relativePath>
> >> +    </parent>
> >> +
> >> +    <properties>
> >> +        <cxf.osgi.export>
> >> +            org.apache.cxf.tracing.brave.soap
> >> +        </cxf.osgi.export>
> >> +        <brave.version>3.15.1</brave.version>
> >> +    </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-features-logging</artifactId>
> >> +            <version>${project.version}</version>
> >> +        </dependency>
> >> +        <dependency>
> >> +               <groupId>io.zipkin.brave</groupId>
> >> +               <artifactId>brave-core</artifactId>
> >> +               <version>${brave.version}</version>
> >> +        </dependency>
> >> +        <dependency>
> >> +               <groupId>io.zipkin.brave</groupId>
> >> +               <artifactId>brave-http</artifactId>
> >> +               <version>${brave.version}</version>
> >> +        </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>
> >> +        <dependency>
> >> +            <groupId>org.apache.cxf</groupId>
> >> +            <artifactId>cxf-rt-frontend-jaxws</artifactId>
> >> +            <version>${project.version}</version>
> >> +            <scope>test</scope>
> >> +        </dependency>
> >> +    </dependencies>
> >> +</project>
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> >> brave/soap/CxfHttpClientRequest.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/CxfHttpClientRequest.java
> b/rt/features/tracing-brave/sr
> >> c/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java
> >> new file mode 100644
> >> index 0000000..78a40fd
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/CxfHttpClientRequest.java
> >> @@ -0,0 +1,49 @@
> >> +/**
> >> + * 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.soap;
> >> +
> >> +import java.net.URI;
> >> +
> >> +import com.github.kristofa.brave.http.HttpClientRequest;
> >> +import org.apache.cxf.message.Message;
> >> +
> >> +public class CxfHttpClientRequest implements HttpClientRequest {
> >> +
> >> +    private ParsedMessage message;
> >> +
> >> +    public CxfHttpClientRequest(Message message) {
> >> +        this.message = new ParsedMessage(message);
> >> +    }
> >> +
> >> +    @Override
> >> +    public URI getUri() {
> >> +        return message.getUri();
> >> +    }
> >> +
> >> +    @Override
> >> +    public String getHttpMethod() {
> >> +        return message.getHttpMethod();
> >> +    }
> >> +
> >> +    @Override
> >> +    public void addHeader(String header, String value) {
> >> +        message.addHeader(header, value);
> >> +    }
> >> +
> >> +}
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> >> brave/soap/CxfServerRequest.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/CxfServerRequest.java b/rt/features/tracing-brave/sr
> >> c/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java
> >> new file mode 100644
> >> index 0000000..fcc8797
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/CxfServerRequest.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 org.apache.cxf.tracing.brave.soap;
> >> +
> >> +import java.net.URI;
> >> +
> >> +import com.github.kristofa.brave.http.HttpServerRequest;
> >> +
> >> +public class CxfServerRequest implements HttpServerRequest {
> >> +
> >> +    private ParsedMessage message;
> >> +
> >> +    public CxfServerRequest(ParsedMessage message) {
> >> +        this.message = message;
> >> +    }
> >> +
> >> +    @Override
> >> +    public URI getUri() {
> >> +        return message.getUri();
> >> +    }
> >> +
> >> +    @Override
> >> +    public String getHttpMethod() {
> >> +        return message.getHttpMethod();
> >> +    }
> >> +
> >> +    @Override
> >> +    public String getHttpHeaderValue(String headerName) {
> >> +        return message.getHeaders().get(headerName);
> >> +    }
> >> +
> >> +}
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> >> brave/soap/HttpResponse200.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/HttpResponse200.java b/rt/features/tracing-brave/sr
> >> c/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java
> >> new file mode 100644
> >> index 0000000..f50dbde
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/HttpResponse200.java
> >> @@ -0,0 +1,28 @@
> >> +/**
> >> + * 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.soap;
> >> +
> >> +import com.github.kristofa.brave.http.HttpResponse;
> >> +
> >> +final class HttpResponse200 implements HttpResponse {
> >> +    @Override
> >> +    public int getHttpStatusCode() {
> >> +        return 200;
> >> +    }
> >> +}
> >> \ No newline at end of file
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> >> brave/soap/ParsedMessage.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/ParsedMessage.java b/rt/features/tracing-brave/sr
> >> c/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java
> >> new file mode 100644
> >> index 0000000..8967375
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/ParsedMessage.java
> >> @@ -0,0 +1,121 @@
> >> +/**
> >> + * 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.soap;
> >> +
> >> +import java.net.URI;
> >> +import java.net.URISyntaxException;
> >> +import java.util.Arrays;
> >> +import java.util.HashMap;
> >> +import java.util.List;
> >> +import java.util.Map;
> >> +
> >> +import org.apache.cxf.helpers.CastUtils;
> >> +import org.apache.cxf.message.Message;
> >> +import org.apache.cxf.message.MessageUtils;
> >> +
> >> +public class ParsedMessage {
> >> +
> >> +    private Message message;
> >> +
> >> +    public 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;
> >> +    }
> >> +
> >> +    public 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;
> >> +        }
> >> +    }
> >> +
> >> +    public 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().getOutMe
> >> ssage();
> >> +        } else {
> >> +            return isOutbound ? message.getExchange().getInMessage() :
> >> message;
> >> +        }
> >> +    }
> >> +
> >> +    Map<String, String> getHeaders() {
> >> +        Map<String, List<String>> headers = CastUtils.cast((Map<?,
> >> ?>)message.get(Message.PROTOCOL_HEADERS));
> >> +        Map<String, String> result = new HashMap<>();
> >> +        if (headers == null) {
> >> +            return result;
> >> +        }
> >> +        for (Map.Entry<String, List<String>> entry :
> headers.entrySet())
> >> {
> >> +            if (entry.getValue().size() == 1) {
> >> +                result.put(entry.getKey(), entry.getValue().get(0));
> >> +            } else {
> >> +                String[] valueAr = entry.getValue().toArray(new
> String[]
> >> {});
> >> +                result.put(entry.getKey(), valueAr.toString());
> >> +            }
> >> +        }
> >> +        return result;
> >> +    }
> >> +
> >> +    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<String, List<String>>();
> >> +            message.put(Message.PROTOCOL_HEADERS, headers);
> >> +        }
> >> +        headers.put(key, Arrays.asList(value));
> >> +    }
> >> +
> >> +    public String getHttpMethod() {
> >> +        ParsedMessage eMessage = new ParsedMessage(getEffectiveMess
> >> age());
> >> +        return eMessage.safeGet(Message.HTTP_REQUEST_METHOD);
> >> +    }
> >> +}
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> >> brave/soap/TraceFeature.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/TraceFeature.java b/rt/features/tracing-brave/sr
> >> c/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java
> >> new file mode 100644
> >> index 0000000..fbaca07
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/TraceFeature.java
> >> @@ -0,0 +1,50 @@
> >> +/**
> >> + * 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.soap;
> >> +
> >> +import com.github.kristofa.brave.Brave;
> >> +import com.github.kristofa.brave.http.DefaultSpanNameProvider;
> >> +import org.apache.cxf.Bus;
> >> +import org.apache.cxf.annotations.Provider;
> >> +import org.apache.cxf.annotations.Provider.Type;
> >> +import org.apache.cxf.common.injection.NoJSR250Annotations;
> >> +import org.apache.cxf.feature.AbstractFeature;
> >> +import org.apache.cxf.interceptor.InterceptorProvider;
> >> +
> >> +@NoJSR250Annotations
> >> +@Provider(value = Type.Feature)
> >> +public class TraceFeature extends AbstractFeature {
> >> +    private TraceInInterceptor in;
> >> +    private TraceOutInterceptor out;
> >> +
> >> +    public TraceFeature(Brave brave) {
> >> +        DefaultSpanNameProvider nameProvider = new
> >> DefaultSpanNameProvider();
> >> +        in = new TraceInInterceptor(brave, nameProvider);
> >> +        out = new TraceOutInterceptor(brave, nameProvider);
> >> +    }
> >> +
> >> +    @Override
> >> +    protected void initializeProvider(InterceptorProvider provider,
> Bus
> >> bus) {
> >> +        provider.getInInterceptors().add(in);
> >> +        provider.getInFaultInterceptors().add(in);
> >> +
> >> +        provider.getOutInterceptors().add(out);
> >> +        provider.getOutFaultInterceptors().add(out);
> >> +    }
> >> +}
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> >> brave/soap/TraceInInterceptor.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/TraceInInterceptor.java b/rt/features/tracing-brave/sr
> >> c/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java
> >> new file mode 100644
> >> index 0000000..4b84eb3
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/TraceInInterceptor.java
> >> @@ -0,0 +1,58 @@
> >> +/**
> >> + * 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.soap;
> >> +
> >> +import com.github.kristofa.brave.Brave;
> >> +import com.github.kristofa.brave.http.HttpClientResponseAdapter;
> >> +import com.github.kristofa.brave.http.HttpServerRequestAdapter;
> >> +import com.github.kristofa.brave.http.SpanNameProvider;
> >> +import org.apache.cxf.common.injection.NoJSR250Annotations;
> >> +import org.apache.cxf.interceptor.Fault;
> >> +import org.apache.cxf.message.Message;
> >> +import org.apache.cxf.message.MessageUtils;
> >> +import org.apache.cxf.phase.AbstractPhaseInterceptor;
> >> +import org.apache.cxf.phase.Phase;
> >> +
> >> +/**
> >> + *
> >> + */
> >> +@NoJSR250Annotations
> >> +public class TraceInInterceptor extends AbstractPhaseInterceptor<
> Message>
> >> {
> >> +
> >> +    private Brave brave;
> >> +    private SpanNameProvider spanNameProvider;
> >> +
> >> +    public TraceInInterceptor(Brave brave, SpanNameProvider
> >> spanNameProvider) {
> >> +        super(Phase.PRE_INVOKE);
> >> +        this.brave = brave;
> >> +        this.spanNameProvider = spanNameProvider;
> >> +    }
> >> +
> >> +    public void handleMessage(Message cxfMessage) throws Fault {
> >> +        ParsedMessage message = new ParsedMessage(cxfMessage);
> >> +        if (MessageUtils.isRequestor(cxfMessage)) {
> >> +            brave.clientResponseInterceptor().handle(new
> >> HttpClientResponseAdapter(new HttpResponse200()));
> >> +        } else {
> >> +            HttpServerRequestAdapter adapter =
> >> +                new HttpServerRequestAdapter(new
> >> CxfServerRequest(message), spanNameProvider);
> >> +            brave.serverRequestInterceptor().handle(adapter);
> >> +        }
> >> +    }
> >> +
> >> +}
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
> >> brave/soap/TraceOutInterceptor.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/TraceOutInterceptor.java b/rt/features/tracing-brave/sr
> >> c/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java
> >> new file mode 100644
> >> index 0000000..17f76d0
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
> >> cing/brave/soap/TraceOutInterceptor.java
> >> @@ -0,0 +1,57 @@
> >> +/**
> >> + * 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.soap;
> >> +
> >> +import com.github.kristofa.brave.Brave;
> >> +import com.github.kristofa.brave.http.HttpClientRequest;
> >> +import com.github.kristofa.brave.http.HttpClientRequestAdapter;
> >> +import com.github.kristofa.brave.http.HttpServerResponseAdapter;
> >> +import com.github.kristofa.brave.http.SpanNameProvider;
> >> +import org.apache.cxf.common.injection.NoJSR250Annotations;
> >> +import org.apache.cxf.interceptor.Fault;
> >> +import org.apache.cxf.message.Message;
> >> +import org.apache.cxf.message.MessageUtils;
> >> +import org.apache.cxf.phase.AbstractPhaseInterceptor;
> >> +import org.apache.cxf.phase.Phase;
> >> +
> >> +/**
> >> + *
> >> + */
> >> +@NoJSR250Annotations
> >> +public class TraceOutInterceptor extends AbstractPhaseInterceptor<
> Message>
> >> {
> >> +
> >> +    private Brave brave;
> >> +    private SpanNameProvider spanNameProvider;
> >> +
> >> +    public TraceOutInterceptor(Brave brave, SpanNameProvider
> >> spanNameProvider) {
> >> +        super(Phase.PRE_PROTOCOL);
> >> +        this.brave = brave;
> >> +        this.spanNameProvider = spanNameProvider;
> >> +    }
> >> +
> >> +    public void handleMessage(Message message) throws Fault {
> >> +        if (MessageUtils.isRequestor(message)) {
> >> +            final HttpClientRequest req = new
> >> CxfHttpClientRequest(message);
> >> +            brave.clientRequestInterceptor().handle(new
> >> HttpClientRequestAdapter(req, spanNameProvider));
> >> +        } else {
> >> +            brave.serverResponseInterceptor().handle(new
> >> HttpServerResponseAdapter(new HttpResponse200()));
> >> +        }
> >> +    }
> >> +
> >> +}
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
> >> brave/soap/BraveTraceTest.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> >> cing/brave/soap/BraveTraceTest.java b/rt/features/tracing-brave/sr
> >> c/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java
> >> new file mode 100644
> >> index 0000000..5bac5f7
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> >> cing/brave/soap/BraveTraceTest.java
> >> @@ -0,0 +1,99 @@
> >> +/**
> >> + * 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.soap;
> >> +
> >> +import java.util.ArrayList;
> >> +import java.util.Arrays;
> >> +import java.util.List;
> >> +
> >> +import com.github.kristofa.brave.Brave;
> >> +import org.apache.cxf.endpoint.Server;
> >> +import org.apache.cxf.ext.logging.LoggingFeature;
> >> +import org.apache.cxf.feature.Feature;
> >> +import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
> >> +import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
> >> +import org.junit.After;
> >> +import org.junit.Assert;
> >> +import org.junit.Before;
> >> +import org.junit.Test;
> >> +import zipkin.Span;
> >> +import zipkin.reporter.Reporter;
> >> +
> >> +public class BraveTraceTest {
> >> +
> >> +    private static final String ADDRESS = "http://localhost:8182";
> >> +    private Server server;
> >> +    private TraceFeature logging;
> >> +    private Localreporter localReporter;
> >> +
> >> +    @Before
> >> +    public void startServer() {
> >> +        localReporter = new Localreporter();
> >> +        logging = createLoggingFeature(localReporter);
> >> +        server = createServer(logging);
> >> +    }
> >> +
> >> +    @Test
> >> +    public void testMyService() {
> >> +        MyService myService = createProxy(logging);
> >> +        myService.echo("test");
> >> +        for (Span span : localReporter.spans) {
> >> +            System.out.println(span);
> >> +        }
> >> +        Assert.assertEquals(2, localReporter.spans.size());
> >> +
> >> +    }
> >> +
> >> +    @After
> >> +    public void stopServer() {
> >> +        server.destroy();
> >> +    }
> >> +
> >> +    private static Server createServer(Feature logging) {
> >> +        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
> >> +        factory.setAddress(ADDRESS);
> >> +        factory.setServiceBean(new MyServiceImpl());
> >> +        factory.setFeatures(Arrays.asList(logging));
> >> +        return factory.create();
> >> +    }
> >> +
> >> +    private static MyService createProxy(Feature trace) {
> >> +        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> >> +        factory.setServiceClass(MyService.class);
> >> +        factory.setAddress(ADDRESS);
> >> +        factory.setFeatures(Arrays.asList(trace, new
> LoggingFeature()));
> >> +        return (MyService)factory.create();
> >> +    }
> >> +
> >> +    private static TraceFeature createLoggingFeature(Reporter<Span>
> >> reporter) {
> >> +        Brave brave = new Brave.Builder("myservice").rep
> >> orter(reporter).build();
> >> +        return new TraceFeature(brave);
> >> +    }
> >> +
> >> +    static final class Localreporter implements Reporter<Span> {
> >> +        List<Span> spans = new ArrayList<Span>();
> >> +
> >> +        @Override
> >> +        public void report(Span span) {
> >> +            spans.add(span);
> >> +        }
> >> +
> >> +    }
> >> +
> >> +}
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
> >> brave/soap/LoggingSpanNameProvider.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> >> cing/brave/soap/LoggingSpanNameProvider.java
> >> b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> >> cing/brave/soap/LoggingSpanNameProvider.java
> >> new file mode 100644
> >> index 0000000..86fa25a
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> >> cing/brave/soap/LoggingSpanNameProvider.java
> >> @@ -0,0 +1,31 @@
> >> +/**
> >> + * 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.soap;
> >> +
> >> +import com.github.kristofa.brave.http.HttpRequest;
> >> +import com.github.kristofa.brave.http.SpanNameProvider;
> >> +
> >> +public class LoggingSpanNameProvider implements SpanNameProvider {
> >> +
> >> +    @Override
> >> +    public String spanName(HttpRequest request) {
> >> +        return (request instanceof SpanNameProvider) ?
> >> ((SpanNameProvider)request).spanName(request) : "";
> >> +    }
> >> +
> >> +}
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
> >> brave/soap/MyService.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/
> tracing/brave/soap/MyService.java
> >> b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> >> cing/brave/soap/MyService.java
> >> new file mode 100644
> >> index 0000000..2001164
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> >> cing/brave/soap/MyService.java
> >> @@ -0,0 +1,26 @@
> >> +/**
> >> + * 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.soap;
> >> +
> >> +import javax.jws.WebService;
> >> +
> >> +@WebService
> >> +public interface MyService {
> >> +    String echo(String msg);
> >> +}
> >>
> >> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
> >> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
> >> brave/soap/MyServiceImpl.java
> >> ----------------------------------------------------------------------
> >> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> >> cing/brave/soap/MyServiceImpl.java b/rt/features/tracing-brave/sr
> >> c/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java
> >> new file mode 100644
> >> index 0000000..e9f901a
> >> --- /dev/null
> >> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
> >> cing/brave/soap/MyServiceImpl.java
> >> @@ -0,0 +1,28 @@
> >> +/**
> >> + * 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.soap;
> >> +
> >> +public class MyServiceImpl implements MyService {
> >> +
> >> +    @Override
> >> +    public String echo(String msg) {
> >> +        return msg;
> >> +    }
> >> +
> >> +}
> >>
> >>
> >
> > --
> > Sergey Beryozkin
> >
> > Talend Community Coders
> > http://coders.talend.com/
> >
> >
>
>
> --
> --
> Christian Schneider
> http://www.liquid-reality.de
> <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e
> 46&URL=http%3a%2f%2fwww.liquid-reality.de>
>
> Open Source Architect
> http://www.talend.com
> <https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e
> 46&URL=http%3a%2f%2fwww.talend.com>
>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Christian Schneider <ch...@die-schneider.net>.
My orignal plan was to just support SOAP as REST is well supported by brave
rest support already.
In the end my code was able to support both REST and SOAP without much
overhead so I removed the soap package again.

Christian

2016-12-06 14:41 GMT+01:00 Sergey Beryozkin <sb...@gmail.com>:

> Christian, what is SOAP specific in this code ?
> Looks like that can work with JAX-RS too ?
>
> Usually we try to accommodate both frontends, example, Andriy Redko made
> sure HTrace interceptors work for JAXWS, similarly for Bean validation
>
> Sergey
>
>
>
> On 06/12/16 13:36, cschneider@apache.org wrote:
>
>> Repository: cxf
>> Updated Branches:
>>   refs/heads/master 892a4ca84 -> fd77d3f33
>>
>>
>> [CXF-7164] Support tracing using Zipkin Brave
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fd77d3f3
>> Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fd77d3f3
>> Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fd77d3f3
>>
>> Branch: refs/heads/master
>> Commit: fd77d3f3380f805db3547d37cbb2ff72bd033ad0
>> Parents: 892a4ca
>> Author: Christian Schneider <ch...@die-schneider.net>
>> Authored: Tue Dec 6 14:35:35 2016 +0100
>> Committer: Christian Schneider <ch...@die-schneider.net>
>> Committed: Tue Dec 6 14:36:01 2016 +0100
>>
>> ----------------------------------------------------------------------
>>  rt/features/pom.xml                             |   1 +
>>  rt/features/tracing-brave/pom.xml               |  87 +++++++++++++
>>  .../brave/soap/CxfHttpClientRequest.java        |  49 ++++++++
>>  .../tracing/brave/soap/CxfServerRequest.java    |  48 ++++++++
>>  .../cxf/tracing/brave/soap/HttpResponse200.java |  28 +++++
>>  .../cxf/tracing/brave/soap/ParsedMessage.java   | 121
>> +++++++++++++++++++
>>  .../cxf/tracing/brave/soap/TraceFeature.java    |  50 ++++++++
>>  .../tracing/brave/soap/TraceInInterceptor.java  |  58 +++++++++
>>  .../tracing/brave/soap/TraceOutInterceptor.java |  57 +++++++++
>>  .../cxf/tracing/brave/soap/BraveTraceTest.java  |  99 +++++++++++++++
>>  .../brave/soap/LoggingSpanNameProvider.java     |  31 +++++
>>  .../cxf/tracing/brave/soap/MyService.java       |  26 ++++
>>  .../cxf/tracing/brave/soap/MyServiceImpl.java   |  28 +++++
>>  13 files changed, 683 insertions(+)
>> ----------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/pom.xml
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/pom.xml b/rt/features/pom.xml
>> index 0365bf6..a4cfdff 100644
>> --- a/rt/features/pom.xml
>> +++ b/rt/features/pom.xml
>> @@ -34,5 +34,6 @@
>>          <module>logging</module>
>>          <module>metrics</module>
>>          <module>throttling</module>
>> +        <module>tracing-brave</module>
>>      </modules>
>>  </project>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/pom.xml
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/pom.xml
>> b/rt/features/tracing-brave/pom.xml
>> new file mode 100644
>> index 0000000..9af22e4
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/pom.xml
>> @@ -0,0 +1,87 @@
>> +<?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://mav
>> en.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
>> +    <modelVersion>4.0.0</modelVersion>
>> +    <artifactId>cxf-rt-features-tracing-brave</artifactId>
>> +    <packaging>jar</packaging>
>> +    <name>Apache CXF Tracing using Zipkin Brave</name>
>> +    <url>http://cxf.apache.org</url>
>> +    <parent>
>> +        <groupId>org.apache.cxf</groupId>
>> +        <artifactId>cxf-parent</artifactId>
>> +        <version>3.2.0-SNAPSHOT</version>
>> +        <relativePath>../../../parent/pom.xml</relativePath>
>> +    </parent>
>> +
>> +    <properties>
>> +        <cxf.osgi.export>
>> +            org.apache.cxf.tracing.brave.soap
>> +        </cxf.osgi.export>
>> +        <brave.version>3.15.1</brave.version>
>> +    </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-features-logging</artifactId>
>> +            <version>${project.version}</version>
>> +        </dependency>
>> +        <dependency>
>> +               <groupId>io.zipkin.brave</groupId>
>> +               <artifactId>brave-core</artifactId>
>> +               <version>${brave.version}</version>
>> +        </dependency>
>> +        <dependency>
>> +               <groupId>io.zipkin.brave</groupId>
>> +               <artifactId>brave-http</artifactId>
>> +               <version>${brave.version}</version>
>> +        </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>
>> +        <dependency>
>> +            <groupId>org.apache.cxf</groupId>
>> +            <artifactId>cxf-rt-frontend-jaxws</artifactId>
>> +            <version>${project.version}</version>
>> +            <scope>test</scope>
>> +        </dependency>
>> +    </dependencies>
>> +</project>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>> brave/soap/CxfHttpClientRequest.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/CxfHttpClientRequest.java b/rt/features/tracing-brave/sr
>> c/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java
>> new file mode 100644
>> index 0000000..78a40fd
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/CxfHttpClientRequest.java
>> @@ -0,0 +1,49 @@
>> +/**
>> + * 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.soap;
>> +
>> +import java.net.URI;
>> +
>> +import com.github.kristofa.brave.http.HttpClientRequest;
>> +import org.apache.cxf.message.Message;
>> +
>> +public class CxfHttpClientRequest implements HttpClientRequest {
>> +
>> +    private ParsedMessage message;
>> +
>> +    public CxfHttpClientRequest(Message message) {
>> +        this.message = new ParsedMessage(message);
>> +    }
>> +
>> +    @Override
>> +    public URI getUri() {
>> +        return message.getUri();
>> +    }
>> +
>> +    @Override
>> +    public String getHttpMethod() {
>> +        return message.getHttpMethod();
>> +    }
>> +
>> +    @Override
>> +    public void addHeader(String header, String value) {
>> +        message.addHeader(header, value);
>> +    }
>> +
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>> brave/soap/CxfServerRequest.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/CxfServerRequest.java b/rt/features/tracing-brave/sr
>> c/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java
>> new file mode 100644
>> index 0000000..fcc8797
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/CxfServerRequest.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 org.apache.cxf.tracing.brave.soap;
>> +
>> +import java.net.URI;
>> +
>> +import com.github.kristofa.brave.http.HttpServerRequest;
>> +
>> +public class CxfServerRequest implements HttpServerRequest {
>> +
>> +    private ParsedMessage message;
>> +
>> +    public CxfServerRequest(ParsedMessage message) {
>> +        this.message = message;
>> +    }
>> +
>> +    @Override
>> +    public URI getUri() {
>> +        return message.getUri();
>> +    }
>> +
>> +    @Override
>> +    public String getHttpMethod() {
>> +        return message.getHttpMethod();
>> +    }
>> +
>> +    @Override
>> +    public String getHttpHeaderValue(String headerName) {
>> +        return message.getHeaders().get(headerName);
>> +    }
>> +
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>> brave/soap/HttpResponse200.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/HttpResponse200.java b/rt/features/tracing-brave/sr
>> c/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java
>> new file mode 100644
>> index 0000000..f50dbde
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/HttpResponse200.java
>> @@ -0,0 +1,28 @@
>> +/**
>> + * 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.soap;
>> +
>> +import com.github.kristofa.brave.http.HttpResponse;
>> +
>> +final class HttpResponse200 implements HttpResponse {
>> +    @Override
>> +    public int getHttpStatusCode() {
>> +        return 200;
>> +    }
>> +}
>> \ No newline at end of file
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>> brave/soap/ParsedMessage.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/ParsedMessage.java b/rt/features/tracing-brave/sr
>> c/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java
>> new file mode 100644
>> index 0000000..8967375
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/ParsedMessage.java
>> @@ -0,0 +1,121 @@
>> +/**
>> + * 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.soap;
>> +
>> +import java.net.URI;
>> +import java.net.URISyntaxException;
>> +import java.util.Arrays;
>> +import java.util.HashMap;
>> +import java.util.List;
>> +import java.util.Map;
>> +
>> +import org.apache.cxf.helpers.CastUtils;
>> +import org.apache.cxf.message.Message;
>> +import org.apache.cxf.message.MessageUtils;
>> +
>> +public class ParsedMessage {
>> +
>> +    private Message message;
>> +
>> +    public 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;
>> +    }
>> +
>> +    public 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;
>> +        }
>> +    }
>> +
>> +    public 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().getOutMe
>> ssage();
>> +        } else {
>> +            return isOutbound ? message.getExchange().getInMessage() :
>> message;
>> +        }
>> +    }
>> +
>> +    Map<String, String> getHeaders() {
>> +        Map<String, List<String>> headers = CastUtils.cast((Map<?,
>> ?>)message.get(Message.PROTOCOL_HEADERS));
>> +        Map<String, String> result = new HashMap<>();
>> +        if (headers == null) {
>> +            return result;
>> +        }
>> +        for (Map.Entry<String, List<String>> entry : headers.entrySet())
>> {
>> +            if (entry.getValue().size() == 1) {
>> +                result.put(entry.getKey(), entry.getValue().get(0));
>> +            } else {
>> +                String[] valueAr = entry.getValue().toArray(new String[]
>> {});
>> +                result.put(entry.getKey(), valueAr.toString());
>> +            }
>> +        }
>> +        return result;
>> +    }
>> +
>> +    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<String, List<String>>();
>> +            message.put(Message.PROTOCOL_HEADERS, headers);
>> +        }
>> +        headers.put(key, Arrays.asList(value));
>> +    }
>> +
>> +    public String getHttpMethod() {
>> +        ParsedMessage eMessage = new ParsedMessage(getEffectiveMess
>> age());
>> +        return eMessage.safeGet(Message.HTTP_REQUEST_METHOD);
>> +    }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>> brave/soap/TraceFeature.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/TraceFeature.java b/rt/features/tracing-brave/sr
>> c/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java
>> new file mode 100644
>> index 0000000..fbaca07
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/TraceFeature.java
>> @@ -0,0 +1,50 @@
>> +/**
>> + * 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.soap;
>> +
>> +import com.github.kristofa.brave.Brave;
>> +import com.github.kristofa.brave.http.DefaultSpanNameProvider;
>> +import org.apache.cxf.Bus;
>> +import org.apache.cxf.annotations.Provider;
>> +import org.apache.cxf.annotations.Provider.Type;
>> +import org.apache.cxf.common.injection.NoJSR250Annotations;
>> +import org.apache.cxf.feature.AbstractFeature;
>> +import org.apache.cxf.interceptor.InterceptorProvider;
>> +
>> +@NoJSR250Annotations
>> +@Provider(value = Type.Feature)
>> +public class TraceFeature extends AbstractFeature {
>> +    private TraceInInterceptor in;
>> +    private TraceOutInterceptor out;
>> +
>> +    public TraceFeature(Brave brave) {
>> +        DefaultSpanNameProvider nameProvider = new
>> DefaultSpanNameProvider();
>> +        in = new TraceInInterceptor(brave, nameProvider);
>> +        out = new TraceOutInterceptor(brave, nameProvider);
>> +    }
>> +
>> +    @Override
>> +    protected void initializeProvider(InterceptorProvider provider, Bus
>> bus) {
>> +        provider.getInInterceptors().add(in);
>> +        provider.getInFaultInterceptors().add(in);
>> +
>> +        provider.getOutInterceptors().add(out);
>> +        provider.getOutFaultInterceptors().add(out);
>> +    }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>> brave/soap/TraceInInterceptor.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/TraceInInterceptor.java b/rt/features/tracing-brave/sr
>> c/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java
>> new file mode 100644
>> index 0000000..4b84eb3
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/TraceInInterceptor.java
>> @@ -0,0 +1,58 @@
>> +/**
>> + * 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.soap;
>> +
>> +import com.github.kristofa.brave.Brave;
>> +import com.github.kristofa.brave.http.HttpClientResponseAdapter;
>> +import com.github.kristofa.brave.http.HttpServerRequestAdapter;
>> +import com.github.kristofa.brave.http.SpanNameProvider;
>> +import org.apache.cxf.common.injection.NoJSR250Annotations;
>> +import org.apache.cxf.interceptor.Fault;
>> +import org.apache.cxf.message.Message;
>> +import org.apache.cxf.message.MessageUtils;
>> +import org.apache.cxf.phase.AbstractPhaseInterceptor;
>> +import org.apache.cxf.phase.Phase;
>> +
>> +/**
>> + *
>> + */
>> +@NoJSR250Annotations
>> +public class TraceInInterceptor extends AbstractPhaseInterceptor<Message>
>> {
>> +
>> +    private Brave brave;
>> +    private SpanNameProvider spanNameProvider;
>> +
>> +    public TraceInInterceptor(Brave brave, SpanNameProvider
>> spanNameProvider) {
>> +        super(Phase.PRE_INVOKE);
>> +        this.brave = brave;
>> +        this.spanNameProvider = spanNameProvider;
>> +    }
>> +
>> +    public void handleMessage(Message cxfMessage) throws Fault {
>> +        ParsedMessage message = new ParsedMessage(cxfMessage);
>> +        if (MessageUtils.isRequestor(cxfMessage)) {
>> +            brave.clientResponseInterceptor().handle(new
>> HttpClientResponseAdapter(new HttpResponse200()));
>> +        } else {
>> +            HttpServerRequestAdapter adapter =
>> +                new HttpServerRequestAdapter(new
>> CxfServerRequest(message), spanNameProvider);
>> +            brave.serverRequestInterceptor().handle(adapter);
>> +        }
>> +    }
>> +
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/main/java/org/apache/cxf/tracing/
>> brave/soap/TraceOutInterceptor.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/TraceOutInterceptor.java b/rt/features/tracing-brave/sr
>> c/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java
>> new file mode 100644
>> index 0000000..17f76d0
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tra
>> cing/brave/soap/TraceOutInterceptor.java
>> @@ -0,0 +1,57 @@
>> +/**
>> + * 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.soap;
>> +
>> +import com.github.kristofa.brave.Brave;
>> +import com.github.kristofa.brave.http.HttpClientRequest;
>> +import com.github.kristofa.brave.http.HttpClientRequestAdapter;
>> +import com.github.kristofa.brave.http.HttpServerResponseAdapter;
>> +import com.github.kristofa.brave.http.SpanNameProvider;
>> +import org.apache.cxf.common.injection.NoJSR250Annotations;
>> +import org.apache.cxf.interceptor.Fault;
>> +import org.apache.cxf.message.Message;
>> +import org.apache.cxf.message.MessageUtils;
>> +import org.apache.cxf.phase.AbstractPhaseInterceptor;
>> +import org.apache.cxf.phase.Phase;
>> +
>> +/**
>> + *
>> + */
>> +@NoJSR250Annotations
>> +public class TraceOutInterceptor extends AbstractPhaseInterceptor<Message>
>> {
>> +
>> +    private Brave brave;
>> +    private SpanNameProvider spanNameProvider;
>> +
>> +    public TraceOutInterceptor(Brave brave, SpanNameProvider
>> spanNameProvider) {
>> +        super(Phase.PRE_PROTOCOL);
>> +        this.brave = brave;
>> +        this.spanNameProvider = spanNameProvider;
>> +    }
>> +
>> +    public void handleMessage(Message message) throws Fault {
>> +        if (MessageUtils.isRequestor(message)) {
>> +            final HttpClientRequest req = new
>> CxfHttpClientRequest(message);
>> +            brave.clientRequestInterceptor().handle(new
>> HttpClientRequestAdapter(req, spanNameProvider));
>> +        } else {
>> +            brave.serverResponseInterceptor().handle(new
>> HttpServerResponseAdapter(new HttpResponse200()));
>> +        }
>> +    }
>> +
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
>> brave/soap/BraveTraceTest.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>> cing/brave/soap/BraveTraceTest.java b/rt/features/tracing-brave/sr
>> c/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java
>> new file mode 100644
>> index 0000000..5bac5f7
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>> cing/brave/soap/BraveTraceTest.java
>> @@ -0,0 +1,99 @@
>> +/**
>> + * 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.soap;
>> +
>> +import java.util.ArrayList;
>> +import java.util.Arrays;
>> +import java.util.List;
>> +
>> +import com.github.kristofa.brave.Brave;
>> +import org.apache.cxf.endpoint.Server;
>> +import org.apache.cxf.ext.logging.LoggingFeature;
>> +import org.apache.cxf.feature.Feature;
>> +import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
>> +import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
>> +import org.junit.After;
>> +import org.junit.Assert;
>> +import org.junit.Before;
>> +import org.junit.Test;
>> +import zipkin.Span;
>> +import zipkin.reporter.Reporter;
>> +
>> +public class BraveTraceTest {
>> +
>> +    private static final String ADDRESS = "http://localhost:8182";
>> +    private Server server;
>> +    private TraceFeature logging;
>> +    private Localreporter localReporter;
>> +
>> +    @Before
>> +    public void startServer() {
>> +        localReporter = new Localreporter();
>> +        logging = createLoggingFeature(localReporter);
>> +        server = createServer(logging);
>> +    }
>> +
>> +    @Test
>> +    public void testMyService() {
>> +        MyService myService = createProxy(logging);
>> +        myService.echo("test");
>> +        for (Span span : localReporter.spans) {
>> +            System.out.println(span);
>> +        }
>> +        Assert.assertEquals(2, localReporter.spans.size());
>> +
>> +    }
>> +
>> +    @After
>> +    public void stopServer() {
>> +        server.destroy();
>> +    }
>> +
>> +    private static Server createServer(Feature logging) {
>> +        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
>> +        factory.setAddress(ADDRESS);
>> +        factory.setServiceBean(new MyServiceImpl());
>> +        factory.setFeatures(Arrays.asList(logging));
>> +        return factory.create();
>> +    }
>> +
>> +    private static MyService createProxy(Feature trace) {
>> +        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
>> +        factory.setServiceClass(MyService.class);
>> +        factory.setAddress(ADDRESS);
>> +        factory.setFeatures(Arrays.asList(trace, new LoggingFeature()));
>> +        return (MyService)factory.create();
>> +    }
>> +
>> +    private static TraceFeature createLoggingFeature(Reporter<Span>
>> reporter) {
>> +        Brave brave = new Brave.Builder("myservice").rep
>> orter(reporter).build();
>> +        return new TraceFeature(brave);
>> +    }
>> +
>> +    static final class Localreporter implements Reporter<Span> {
>> +        List<Span> spans = new ArrayList<Span>();
>> +
>> +        @Override
>> +        public void report(Span span) {
>> +            spans.add(span);
>> +        }
>> +
>> +    }
>> +
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
>> brave/soap/LoggingSpanNameProvider.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>> cing/brave/soap/LoggingSpanNameProvider.java
>> b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>> cing/brave/soap/LoggingSpanNameProvider.java
>> new file mode 100644
>> index 0000000..86fa25a
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>> cing/brave/soap/LoggingSpanNameProvider.java
>> @@ -0,0 +1,31 @@
>> +/**
>> + * 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.soap;
>> +
>> +import com.github.kristofa.brave.http.HttpRequest;
>> +import com.github.kristofa.brave.http.SpanNameProvider;
>> +
>> +public class LoggingSpanNameProvider implements SpanNameProvider {
>> +
>> +    @Override
>> +    public String spanName(HttpRequest request) {
>> +        return (request instanceof SpanNameProvider) ?
>> ((SpanNameProvider)request).spanName(request) : "";
>> +    }
>> +
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
>> brave/soap/MyService.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java
>> b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>> cing/brave/soap/MyService.java
>> new file mode 100644
>> index 0000000..2001164
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>> cing/brave/soap/MyService.java
>> @@ -0,0 +1,26 @@
>> +/**
>> + * 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.soap;
>> +
>> +import javax.jws.WebService;
>> +
>> +@WebService
>> +public interface MyService {
>> +    String echo(String msg);
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/
>> features/tracing-brave/src/test/java/org/apache/cxf/tracing/
>> brave/soap/MyServiceImpl.java
>> ----------------------------------------------------------------------
>> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>> cing/brave/soap/MyServiceImpl.java b/rt/features/tracing-brave/sr
>> c/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java
>> new file mode 100644
>> index 0000000..e9f901a
>> --- /dev/null
>> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tra
>> cing/brave/soap/MyServiceImpl.java
>> @@ -0,0 +1,28 @@
>> +/**
>> + * 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.soap;
>> +
>> +public class MyServiceImpl implements MyService {
>> +
>> +    @Override
>> +    public String echo(String msg) {
>> +        return msg;
>> +    }
>> +
>> +}
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
>


-- 
-- 
Christian Schneider
http://www.liquid-reality.de
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.liquid-reality.de>

Open Source Architect
http://www.talend.com
<https://owa.talend.com/owa/redir.aspx?C=3aa4083e0c744ae1ba52bd062c5a7e46&URL=http%3a%2f%2fwww.talend.com>

Re: cxf git commit: [CXF-7164] Support tracing using Zipkin Brave

Posted by Sergey Beryozkin <sb...@gmail.com>.
Christian, what is SOAP specific in this code ?
Looks like that can work with JAX-RS too ?

Usually we try to accommodate both frontends, example, Andriy Redko made 
sure HTrace interceptors work for JAXWS, similarly for Bean validation

Sergey



On 06/12/16 13:36, cschneider@apache.org wrote:
> Repository: cxf
> Updated Branches:
>   refs/heads/master 892a4ca84 -> fd77d3f33
>
>
> [CXF-7164] Support tracing using Zipkin Brave
>
>
> Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
> Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fd77d3f3
> Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fd77d3f3
> Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fd77d3f3
>
> Branch: refs/heads/master
> Commit: fd77d3f3380f805db3547d37cbb2ff72bd033ad0
> Parents: 892a4ca
> Author: Christian Schneider <ch...@die-schneider.net>
> Authored: Tue Dec 6 14:35:35 2016 +0100
> Committer: Christian Schneider <ch...@die-schneider.net>
> Committed: Tue Dec 6 14:36:01 2016 +0100
>
> ----------------------------------------------------------------------
>  rt/features/pom.xml                             |   1 +
>  rt/features/tracing-brave/pom.xml               |  87 +++++++++++++
>  .../brave/soap/CxfHttpClientRequest.java        |  49 ++++++++
>  .../tracing/brave/soap/CxfServerRequest.java    |  48 ++++++++
>  .../cxf/tracing/brave/soap/HttpResponse200.java |  28 +++++
>  .../cxf/tracing/brave/soap/ParsedMessage.java   | 121 +++++++++++++++++++
>  .../cxf/tracing/brave/soap/TraceFeature.java    |  50 ++++++++
>  .../tracing/brave/soap/TraceInInterceptor.java  |  58 +++++++++
>  .../tracing/brave/soap/TraceOutInterceptor.java |  57 +++++++++
>  .../cxf/tracing/brave/soap/BraveTraceTest.java  |  99 +++++++++++++++
>  .../brave/soap/LoggingSpanNameProvider.java     |  31 +++++
>  .../cxf/tracing/brave/soap/MyService.java       |  26 ++++
>  .../cxf/tracing/brave/soap/MyServiceImpl.java   |  28 +++++
>  13 files changed, 683 insertions(+)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/pom.xml
> ----------------------------------------------------------------------
> diff --git a/rt/features/pom.xml b/rt/features/pom.xml
> index 0365bf6..a4cfdff 100644
> --- a/rt/features/pom.xml
> +++ b/rt/features/pom.xml
> @@ -34,5 +34,6 @@
>          <module>logging</module>
>          <module>metrics</module>
>          <module>throttling</module>
> +        <module>tracing-brave</module>
>      </modules>
>  </project>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/pom.xml
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/pom.xml b/rt/features/tracing-brave/pom.xml
> new file mode 100644
> index 0000000..9af22e4
> --- /dev/null
> +++ b/rt/features/tracing-brave/pom.xml
> @@ -0,0 +1,87 @@
> +<?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-rt-features-tracing-brave</artifactId>
> +    <packaging>jar</packaging>
> +    <name>Apache CXF Tracing using Zipkin Brave</name>
> +    <url>http://cxf.apache.org</url>
> +    <parent>
> +        <groupId>org.apache.cxf</groupId>
> +        <artifactId>cxf-parent</artifactId>
> +        <version>3.2.0-SNAPSHOT</version>
> +        <relativePath>../../../parent/pom.xml</relativePath>
> +    </parent>
> +
> +    <properties>
> +        <cxf.osgi.export>
> +            org.apache.cxf.tracing.brave.soap
> +        </cxf.osgi.export>
> +        <brave.version>3.15.1</brave.version>
> +    </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-features-logging</artifactId>
> +            <version>${project.version}</version>
> +        </dependency>
> +        <dependency>
> +        	<groupId>io.zipkin.brave</groupId>
> +        	<artifactId>brave-core</artifactId>
> +        	<version>${brave.version}</version>
> +        </dependency>
> +        <dependency>
> +        	<groupId>io.zipkin.brave</groupId>
> +        	<artifactId>brave-http</artifactId>
> +        	<version>${brave.version}</version>
> +        </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>
> +        <dependency>
> +            <groupId>org.apache.cxf</groupId>
> +            <artifactId>cxf-rt-frontend-jaxws</artifactId>
> +            <version>${project.version}</version>
> +            <scope>test</scope>
> +        </dependency>
> +    </dependencies>
> +</project>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java
> new file mode 100644
> index 0000000..78a40fd
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfHttpClientRequest.java
> @@ -0,0 +1,49 @@
> +/**
> + * 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.soap;
> +
> +import java.net.URI;
> +
> +import com.github.kristofa.brave.http.HttpClientRequest;
> +import org.apache.cxf.message.Message;
> +
> +public class CxfHttpClientRequest implements HttpClientRequest {
> +
> +    private ParsedMessage message;
> +
> +    public CxfHttpClientRequest(Message message) {
> +        this.message = new ParsedMessage(message);
> +    }
> +
> +    @Override
> +    public URI getUri() {
> +        return message.getUri();
> +    }
> +
> +    @Override
> +    public String getHttpMethod() {
> +        return message.getHttpMethod();
> +    }
> +
> +    @Override
> +    public void addHeader(String header, String value) {
> +        message.addHeader(header, value);
> +    }
> +
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.java
> new file mode 100644
> index 0000000..fcc8797
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/CxfServerRequest.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 org.apache.cxf.tracing.brave.soap;
> +
> +import java.net.URI;
> +
> +import com.github.kristofa.brave.http.HttpServerRequest;
> +
> +public class CxfServerRequest implements HttpServerRequest {
> +
> +    private ParsedMessage message;
> +
> +    public CxfServerRequest(ParsedMessage message) {
> +        this.message = message;
> +    }
> +
> +    @Override
> +    public URI getUri() {
> +        return message.getUri();
> +    }
> +
> +    @Override
> +    public String getHttpMethod() {
> +        return message.getHttpMethod();
> +    }
> +
> +    @Override
> +    public String getHttpHeaderValue(String headerName) {
> +        return message.getHeaders().get(headerName);
> +    }
> +
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java
> new file mode 100644
> index 0000000..f50dbde
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/HttpResponse200.java
> @@ -0,0 +1,28 @@
> +/**
> + * 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.soap;
> +
> +import com.github.kristofa.brave.http.HttpResponse;
> +
> +final class HttpResponse200 implements HttpResponse {
> +    @Override
> +    public int getHttpStatusCode() {
> +        return 200;
> +    }
> +}
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java
> new file mode 100644
> index 0000000..8967375
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/ParsedMessage.java
> @@ -0,0 +1,121 @@
> +/**
> + * 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.soap;
> +
> +import java.net.URI;
> +import java.net.URISyntaxException;
> +import java.util.Arrays;
> +import java.util.HashMap;
> +import java.util.List;
> +import java.util.Map;
> +
> +import org.apache.cxf.helpers.CastUtils;
> +import org.apache.cxf.message.Message;
> +import org.apache.cxf.message.MessageUtils;
> +
> +public class ParsedMessage {
> +
> +    private Message message;
> +
> +    public 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;
> +    }
> +
> +    public 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;
> +        }
> +    }
> +
> +    public 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, String> getHeaders() {
> +        Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
> +        Map<String, String> result = new HashMap<>();
> +        if (headers == null) {
> +            return result;
> +        }
> +        for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
> +            if (entry.getValue().size() == 1) {
> +                result.put(entry.getKey(), entry.getValue().get(0));
> +            } else {
> +                String[] valueAr = entry.getValue().toArray(new String[] {});
> +                result.put(entry.getKey(), valueAr.toString());
> +            }
> +        }
> +        return result;
> +    }
> +
> +    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<String, List<String>>();
> +            message.put(Message.PROTOCOL_HEADERS, headers);
> +        }
> +        headers.put(key, Arrays.asList(value));
> +    }
> +
> +    public String getHttpMethod() {
> +        ParsedMessage eMessage = new ParsedMessage(getEffectiveMessage());
> +        return eMessage.safeGet(Message.HTTP_REQUEST_METHOD);
> +    }
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java
> new file mode 100644
> index 0000000..fbaca07
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceFeature.java
> @@ -0,0 +1,50 @@
> +/**
> + * 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.soap;
> +
> +import com.github.kristofa.brave.Brave;
> +import com.github.kristofa.brave.http.DefaultSpanNameProvider;
> +import org.apache.cxf.Bus;
> +import org.apache.cxf.annotations.Provider;
> +import org.apache.cxf.annotations.Provider.Type;
> +import org.apache.cxf.common.injection.NoJSR250Annotations;
> +import org.apache.cxf.feature.AbstractFeature;
> +import org.apache.cxf.interceptor.InterceptorProvider;
> +
> +@NoJSR250Annotations
> +@Provider(value = Type.Feature)
> +public class TraceFeature extends AbstractFeature {
> +    private TraceInInterceptor in;
> +    private TraceOutInterceptor out;
> +
> +    public TraceFeature(Brave brave) {
> +        DefaultSpanNameProvider nameProvider = new DefaultSpanNameProvider();
> +        in = new TraceInInterceptor(brave, nameProvider);
> +        out = new TraceOutInterceptor(brave, nameProvider);
> +    }
> +
> +    @Override
> +    protected void initializeProvider(InterceptorProvider provider, Bus bus) {
> +        provider.getInInterceptors().add(in);
> +        provider.getInFaultInterceptors().add(in);
> +
> +        provider.getOutInterceptors().add(out);
> +        provider.getOutFaultInterceptors().add(out);
> +    }
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java
> new file mode 100644
> index 0000000..4b84eb3
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceInInterceptor.java
> @@ -0,0 +1,58 @@
> +/**
> + * 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.soap;
> +
> +import com.github.kristofa.brave.Brave;
> +import com.github.kristofa.brave.http.HttpClientResponseAdapter;
> +import com.github.kristofa.brave.http.HttpServerRequestAdapter;
> +import com.github.kristofa.brave.http.SpanNameProvider;
> +import org.apache.cxf.common.injection.NoJSR250Annotations;
> +import org.apache.cxf.interceptor.Fault;
> +import org.apache.cxf.message.Message;
> +import org.apache.cxf.message.MessageUtils;
> +import org.apache.cxf.phase.AbstractPhaseInterceptor;
> +import org.apache.cxf.phase.Phase;
> +
> +/**
> + *
> + */
> +@NoJSR250Annotations
> +public class TraceInInterceptor extends AbstractPhaseInterceptor<Message> {
> +
> +    private Brave brave;
> +    private SpanNameProvider spanNameProvider;
> +
> +    public TraceInInterceptor(Brave brave, SpanNameProvider spanNameProvider) {
> +        super(Phase.PRE_INVOKE);
> +        this.brave = brave;
> +        this.spanNameProvider = spanNameProvider;
> +    }
> +
> +    public void handleMessage(Message cxfMessage) throws Fault {
> +        ParsedMessage message = new ParsedMessage(cxfMessage);
> +        if (MessageUtils.isRequestor(cxfMessage)) {
> +            brave.clientResponseInterceptor().handle(new HttpClientResponseAdapter(new HttpResponse200()));
> +        } else {
> +            HttpServerRequestAdapter adapter =
> +                new HttpServerRequestAdapter(new CxfServerRequest(message), spanNameProvider);
> +            brave.serverRequestInterceptor().handle(adapter);
> +        }
> +    }
> +
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java
> new file mode 100644
> index 0000000..17f76d0
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/main/java/org/apache/cxf/tracing/brave/soap/TraceOutInterceptor.java
> @@ -0,0 +1,57 @@
> +/**
> + * 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.soap;
> +
> +import com.github.kristofa.brave.Brave;
> +import com.github.kristofa.brave.http.HttpClientRequest;
> +import com.github.kristofa.brave.http.HttpClientRequestAdapter;
> +import com.github.kristofa.brave.http.HttpServerResponseAdapter;
> +import com.github.kristofa.brave.http.SpanNameProvider;
> +import org.apache.cxf.common.injection.NoJSR250Annotations;
> +import org.apache.cxf.interceptor.Fault;
> +import org.apache.cxf.message.Message;
> +import org.apache.cxf.message.MessageUtils;
> +import org.apache.cxf.phase.AbstractPhaseInterceptor;
> +import org.apache.cxf.phase.Phase;
> +
> +/**
> + *
> + */
> +@NoJSR250Annotations
> +public class TraceOutInterceptor extends AbstractPhaseInterceptor<Message> {
> +
> +    private Brave brave;
> +    private SpanNameProvider spanNameProvider;
> +
> +    public TraceOutInterceptor(Brave brave, SpanNameProvider spanNameProvider) {
> +        super(Phase.PRE_PROTOCOL);
> +        this.brave = brave;
> +        this.spanNameProvider = spanNameProvider;
> +    }
> +
> +    public void handleMessage(Message message) throws Fault {
> +        if (MessageUtils.isRequestor(message)) {
> +            final HttpClientRequest req = new CxfHttpClientRequest(message);
> +            brave.clientRequestInterceptor().handle(new HttpClientRequestAdapter(req, spanNameProvider));
> +        } else {
> +            brave.serverResponseInterceptor().handle(new HttpServerResponseAdapter(new HttpResponse200()));
> +        }
> +    }
> +
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java
> new file mode 100644
> index 0000000..5bac5f7
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/BraveTraceTest.java
> @@ -0,0 +1,99 @@
> +/**
> + * 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.soap;
> +
> +import java.util.ArrayList;
> +import java.util.Arrays;
> +import java.util.List;
> +
> +import com.github.kristofa.brave.Brave;
> +import org.apache.cxf.endpoint.Server;
> +import org.apache.cxf.ext.logging.LoggingFeature;
> +import org.apache.cxf.feature.Feature;
> +import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
> +import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
> +import org.junit.After;
> +import org.junit.Assert;
> +import org.junit.Before;
> +import org.junit.Test;
> +import zipkin.Span;
> +import zipkin.reporter.Reporter;
> +
> +public class BraveTraceTest {
> +
> +    private static final String ADDRESS = "http://localhost:8182";
> +    private Server server;
> +    private TraceFeature logging;
> +    private Localreporter localReporter;
> +
> +    @Before
> +    public void startServer() {
> +        localReporter = new Localreporter();
> +        logging = createLoggingFeature(localReporter);
> +        server = createServer(logging);
> +    }
> +
> +    @Test
> +    public void testMyService() {
> +        MyService myService = createProxy(logging);
> +        myService.echo("test");
> +        for (Span span : localReporter.spans) {
> +            System.out.println(span);
> +        }
> +        Assert.assertEquals(2, localReporter.spans.size());
> +
> +    }
> +
> +    @After
> +    public void stopServer() {
> +        server.destroy();
> +    }
> +
> +    private static Server createServer(Feature logging) {
> +        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
> +        factory.setAddress(ADDRESS);
> +        factory.setServiceBean(new MyServiceImpl());
> +        factory.setFeatures(Arrays.asList(logging));
> +        return factory.create();
> +    }
> +
> +    private static MyService createProxy(Feature trace) {
> +        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> +        factory.setServiceClass(MyService.class);
> +        factory.setAddress(ADDRESS);
> +        factory.setFeatures(Arrays.asList(trace, new LoggingFeature()));
> +        return (MyService)factory.create();
> +    }
> +
> +    private static TraceFeature createLoggingFeature(Reporter<Span> reporter) {
> +        Brave brave = new Brave.Builder("myservice").reporter(reporter).build();
> +        return new TraceFeature(brave);
> +    }
> +
> +    static final class Localreporter implements Reporter<Span> {
> +        List<Span> spans = new ArrayList<Span>();
> +
> +        @Override
> +        public void report(Span span) {
> +            spans.add(span);
> +        }
> +
> +    }
> +
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java
> new file mode 100644
> index 0000000..86fa25a
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/LoggingSpanNameProvider.java
> @@ -0,0 +1,31 @@
> +/**
> + * 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.soap;
> +
> +import com.github.kristofa.brave.http.HttpRequest;
> +import com.github.kristofa.brave.http.SpanNameProvider;
> +
> +public class LoggingSpanNameProvider implements SpanNameProvider {
> +
> +    @Override
> +    public String spanName(HttpRequest request) {
> +        return (request instanceof SpanNameProvider) ? ((SpanNameProvider)request).spanName(request) : "";
> +    }
> +
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java
> new file mode 100644
> index 0000000..2001164
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyService.java
> @@ -0,0 +1,26 @@
> +/**
> + * 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.soap;
> +
> +import javax.jws.WebService;
> +
> +@WebService
> +public interface MyService {
> +    String echo(String msg);
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/fd77d3f3/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java
> ----------------------------------------------------------------------
> diff --git a/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java
> new file mode 100644
> index 0000000..e9f901a
> --- /dev/null
> +++ b/rt/features/tracing-brave/src/test/java/org/apache/cxf/tracing/brave/soap/MyServiceImpl.java
> @@ -0,0 +1,28 @@
> +/**
> + * 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.soap;
> +
> +public class MyServiceImpl implements MyService {
> +
> +    @Override
> +    public String echo(String msg) {
> +        return msg;
> +    }
> +
> +}
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/