You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Sergey Beryozkin <sb...@gmail.com> on 2015/05/18 22:03:23 UTC
Re: cxf git commit: CXF-6360: Integration with Apache HTrace
Hi Andriy
Great stuff, thanks for starting this work.
I'm actually not sure we need a tracing-core module at all.
Can we have a TracerContext in rt/management and save on introducing one
more module ?
Thanks, Sergey
On 18/05/15 19:25, reta@apache.org wrote:
> Repository: cxf
> Updated Branches:
> refs/heads/master ab1f363e1 -> 7e82d2f10
>
>
> CXF-6360: Integration with Apache HTrace
>
>
> Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
> Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/7e82d2f1
> Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/7e82d2f1
> Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/7e82d2f1
>
> Branch: refs/heads/master
> Commit: 7e82d2f10a1ca14a939d2c63ca4e620f8870e256
> Parents: ab1f363
> Author: reta <dr...@gmail.com>
> Authored: Mon May 18 14:25:03 2015 -0400
> Committer: reta <dr...@gmail.com>
> Committed: Mon May 18 14:25:03 2015 -0400
>
> ----------------------------------------------------------------------
> integration/pom.xml | 2 +
> integration/tracing/tracing-core/pom.xml | 62 +++++++++
> .../org/apache/cxf/tracing/TracerContext.java | 23 ++++
> integration/tracing/tracing-htrace/pom.xml | 71 ++++++++++
> .../tracing/htrace/HTraceContextProvider.java | 41 ++++++
> .../cxf/jaxrs/tracing/htrace/HTraceFeature.java | 71 ++++++++++
> .../jaxrs/tracing/htrace/HTraceProvider.java | 106 +++++++++++++++
> .../tracing/htrace/HTraceTracerContext.java | 38 ++++++
> parent/pom.xml | 6 +
> systests/pom.xml | 1 +
> systests/tracing/pom.xml | 136 +++++++++++++++++++
> .../apache/cxf/systest/jaxrs/tracing/Book.java | 52 +++++++
> .../cxf/systest/jaxrs/tracing/BookStore.java | 49 +++++++
> .../jaxrs/tracing/htrace/HTraceTracingTest.java | 95 +++++++++++++
> .../jaxrs/tracing/htrace/TestSpanReceiver.java | 61 +++++++++
> 15 files changed, 814 insertions(+)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/pom.xml
> ----------------------------------------------------------------------
> diff --git a/integration/pom.xml b/integration/pom.xml
> index a3ba814..f46fdbb 100644
> --- a/integration/pom.xml
> +++ b/integration/pom.xml
> @@ -32,5 +32,7 @@
> <modules>
> <module>jca</module>
> <module>cdi</module>
> + <module>tracing/tracing-core</module>
> + <module>tracing/tracing-htrace</module>
> </modules>
> </project>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-core/pom.xml
> ----------------------------------------------------------------------
> diff --git a/integration/tracing/tracing-core/pom.xml b/integration/tracing/tracing-core/pom.xml
> new file mode 100644
> index 0000000..e405ebb
> --- /dev/null
> +++ b/integration/tracing/tracing-core/pom.xml
> @@ -0,0 +1,62 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!--
> + Licensed to the Apache Software Foundation (ASF) under one
> + or more contributor license agreements. See the NOTICE file
> + distributed with this work for additional information
> + regarding copyright ownership. The ASF licenses this file
> + to you under the Apache License, Version 2.0 (the
> + "License"); you may not use this file except in compliance
> + with the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing,
> + software distributed under the License is distributed on an
> + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + KIND, either express or implied. See the License for the
> + specific language governing permissions and limitations
> + under the License.
> +-->
> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
> + <modelVersion>4.0.0</modelVersion>
> + <artifactId>cxf-integration-tracing-core</artifactId>
> + <packaging>jar</packaging>
> + <name>Apache CXF Distributed Tracing Integration</name>
> + <description>Apache CXF Distributed Tracing Integration</description>
> + <url>http://cxf.apache.org</url>
> + <parent>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-parent</artifactId>
> + <version>3.1.1-SNAPSHOT</version>
> + <relativePath>../../../parent/pom.xml</relativePath>
> + </parent>
> +
> + <properties>
> + <cxf.osgi.export>
> + org.apache.cxf.tracing
> + </cxf.osgi.export>
> + </properties>
> +
> + <dependencies>
> + <dependency>
> + <groupId>junit</groupId>
> + <artifactId>junit</artifactId>
> + <scope>test</scope>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-core</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-rt-frontend-jaxrs</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.slf4j</groupId>
> + <artifactId>slf4j-jdk14</artifactId>
> + <scope>test</scope>
> + </dependency>
> + </dependencies>
> +</project>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-core/src/main/java/org/apache/cxf/tracing/TracerContext.java
> ----------------------------------------------------------------------
> diff --git a/integration/tracing/tracing-core/src/main/java/org/apache/cxf/tracing/TracerContext.java b/integration/tracing/tracing-core/src/main/java/org/apache/cxf/tracing/TracerContext.java
> new file mode 100644
> index 0000000..2e1f37e
> --- /dev/null
> +++ b/integration/tracing/tracing-core/src/main/java/org/apache/cxf/tracing/TracerContext.java
> @@ -0,0 +1,23 @@
> +/**
> + * 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;
> +
> +public interface TracerContext {
> + <T> T startSpan(final String desription);
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-htrace/pom.xml
> ----------------------------------------------------------------------
> diff --git a/integration/tracing/tracing-htrace/pom.xml b/integration/tracing/tracing-htrace/pom.xml
> new file mode 100644
> index 0000000..b418fb5
> --- /dev/null
> +++ b/integration/tracing/tracing-htrace/pom.xml
> @@ -0,0 +1,71 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!--
> + Licensed to the Apache Software Foundation (ASF) under one
> + or more contributor license agreements. See the NOTICE file
> + distributed with this work for additional information
> + regarding copyright ownership. The ASF licenses this file
> + to you under the Apache License, Version 2.0 (the
> + "License"); you may not use this file except in compliance
> + with the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing,
> + software distributed under the License is distributed on an
> + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + KIND, either express or implied. See the License for the
> + specific language governing permissions and limitations
> + under the License.
> +-->
> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
> + <modelVersion>4.0.0</modelVersion>
> + <artifactId>cxf-integration-tracing-htrace</artifactId>
> + <packaging>jar</packaging>
> + <name>Apache CXF Distributed Tracing using Apache HTrace</name>
> + <description>Apache CXF Distributed using Apache HTrace</description>
> + <url>http://cxf.apache.org</url>
> + <parent>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-parent</artifactId>
> + <version>3.1.1-SNAPSHOT</version>
> + <relativePath>../../../parent/pom.xml</relativePath>
> + </parent>
> +
> + <properties>
> + <cxf.osgi.export>
> + org.apache.cxf.tracing
> + </cxf.osgi.export>
> + </properties>
> +
> + <dependencies>
> + <dependency>
> + <groupId>junit</groupId>
> + <artifactId>junit</artifactId>
> + <scope>test</scope>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-core</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-rt-frontend-jaxrs</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-integration-tracing-core</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.htrace</groupId>
> + <artifactId>htrace-core</artifactId>
> + </dependency>
> + <dependency>
> + <groupId>org.slf4j</groupId>
> + <artifactId>slf4j-jdk14</artifactId>
> + <scope>test</scope>
> + </dependency>
> + </dependencies>
> +</project>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
> ----------------------------------------------------------------------
> diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
> new file mode 100644
> index 0000000..c983f1d
> --- /dev/null
> +++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
> @@ -0,0 +1,41 @@
> +/**
> + * 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.jaxrs.tracing.htrace;
> +
> +import javax.ws.rs.ext.Provider;
> +
> +import org.apache.cxf.jaxrs.ext.ContextProvider;
> +import org.apache.cxf.message.Message;
> +import org.apache.cxf.tracing.TracerContext;
> +import org.apache.htrace.Sampler;
> +import org.apache.htrace.impl.NeverSampler;
> +
> +@Provider
> +public class HTraceContextProvider implements ContextProvider< TracerContext > {
> + private Sampler< ? > sampler = NeverSampler.INSTANCE;
> +
> + public HTraceContextProvider(final Sampler< ? > sampler) {
> + this.sampler = sampler;
> + }
> +
> + @Override
> + public TracerContext createContext(final Message message) {
> + return new HTraceTracerContext(sampler);
> + }
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
> ----------------------------------------------------------------------
> diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
> new file mode 100644
> index 0000000..2b14f99
> --- /dev/null
> +++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
> @@ -0,0 +1,71 @@
> +/**
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +package org.apache.cxf.jaxrs.tracing.htrace;
> +
> +import java.util.Arrays;
> +
> +import org.apache.cxf.Bus;
> +import org.apache.cxf.endpoint.Server;
> +import org.apache.cxf.feature.AbstractFeature;
> +import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
> +import org.apache.htrace.HTraceConfiguration;
> +import org.apache.htrace.Sampler;
> +import org.apache.htrace.SamplerBuilder;
> +import org.apache.htrace.SpanReceiver;
> +import org.apache.htrace.SpanReceiverBuilder;
> +import org.apache.htrace.Trace;
> +
> +public class HTraceFeature extends AbstractFeature {
> + private HTraceConfiguration configuration;
> +
> + public HTraceFeature() {
> + this(HTraceConfiguration.EMPTY);
> + }
> +
> + public HTraceFeature(final HTraceConfiguration configuration) {
> + this.configuration = configuration;
> + }
> +
> + @Override
> + public void initialize(final Server server, final Bus bus) {
> + final ServerProviderFactory providerFactory = (ServerProviderFactory)server
> + .getEndpoint()
> + .get(ServerProviderFactory.class.getName());
> +
> + final Sampler< ? > sampler = new SamplerBuilder(configuration).build();
> + final SpanReceiver spanReceiver = new SpanReceiverBuilder(configuration).build();
> +
> + if (spanReceiver != null) {
> + Trace.addReceiver(spanReceiver);
> + }
> +
> + if (providerFactory != null) {
> + providerFactory.setUserProviders(Arrays.asList(new HTraceProvider(sampler),
> + new HTraceContextProvider(sampler)));
> + }
> + }
> +
> + public void setConfiguration(final HTraceConfiguration configuration) {
> + this.configuration = configuration;
> + }
> +
> + public HTraceConfiguration getConfiguration() {
> + return configuration;
> + }
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
> ----------------------------------------------------------------------
> diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
> new file mode 100644
> index 0000000..a66d93b
> --- /dev/null
> +++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
> @@ -0,0 +1,106 @@
> +/**
> + * 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.jaxrs.tracing.htrace;
> +
> +import java.io.IOException;
> +import java.util.List;
> +import java.util.logging.Level;
> +import java.util.logging.Logger;
> +
> +import javax.ws.rs.container.ContainerRequestContext;
> +import javax.ws.rs.container.ContainerRequestFilter;
> +import javax.ws.rs.container.ContainerResponseContext;
> +import javax.ws.rs.container.ContainerResponseFilter;
> +import javax.ws.rs.core.MultivaluedMap;
> +import javax.ws.rs.ext.Provider;
> +
> +import org.apache.cxf.common.logging.LogUtils;
> +import org.apache.htrace.Sampler;
> +import org.apache.htrace.Trace;
> +import org.apache.htrace.TraceInfo;
> +import org.apache.htrace.Tracer;
> +import org.apache.htrace.impl.NeverSampler;
> +
> +@Provider
> +public class HTraceProvider implements ContainerRequestFilter, ContainerResponseFilter {
> + private static final Logger LOG = LogUtils.getL7dLogger(HTraceProvider.class);
> +
> + private static final String HEADER_TRACE_ID = "X-Trace-Id";
> + private static final String HEADER_SPAN_ID = "X-Span-Id";
> +
> + private final Sampler< ? > sampler;
> +
> + public HTraceProvider() {
> + this(NeverSampler.INSTANCE);
> + }
> +
> + public HTraceProvider(final Sampler< ? > sampler) {
> + this.sampler = sampler;
> + }
> +
> + @SuppressWarnings("unchecked")
> + @Override
> + public void filter(final ContainerRequestContext requestContext) throws IOException {
> + final MultivaluedMap<String, String> headers = requestContext.getHeaders();
> +
> + // Try to extract the Trace Id value from the request header
> + final long traceId = getFirstValueOrDefault(headers, HEADER_TRACE_ID,
> + Tracer.DONT_TRACE.traceId);
> +
> + // Try to extract the Span Id value from the request header
> + final long spanId = getFirstValueOrDefault(headers, HEADER_SPAN_ID,
> + Tracer.DONT_TRACE.spanId);
> +
> + if (traceId != Tracer.DONT_TRACE.traceId && spanId != Tracer.DONT_TRACE.spanId) {
> + Trace.startSpan(requestContext.getUriInfo().getPath(), (Sampler< TraceInfo >)sampler,
> + new TraceInfo(traceId, spanId));
> + }
> + }
> +
> + @Override
> + public void filter(final ContainerRequestContext requestContext,
> + final ContainerResponseContext responseContext) throws IOException {
> + final MultivaluedMap<String, String> headers = requestContext.getHeaders();
> +
> + // Transfer tracing headers into the response headers
> + if (headers.containsKey(HEADER_TRACE_ID) && headers.containsKey(HEADER_SPAN_ID)) {
> + responseContext.getHeaders().add(HEADER_TRACE_ID, headers.getFirst(HEADER_TRACE_ID));
> + responseContext.getHeaders().add(HEADER_SPAN_ID, headers.getFirst(HEADER_SPAN_ID));
> + }
> + }
> +
> + private static Long getFirstValueOrDefault(final MultivaluedMap<String, String> headers,
> + final String header, final long defaultValue) {
> +
> + if (!headers.containsKey(header)) {
> + return defaultValue;
> + }
> +
> + try {
> + final List< String > values = headers.get(header);
> + if (values != null && !values.isEmpty()) {
> + return Long.parseLong(values.get(0));
> + }
> + } catch (NumberFormatException ex) {
> + LOG.log(Level.FINE, String.format("Unable to parse '%s' header value to long number", header), ex);
> + }
> +
> + return defaultValue;
> + }
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceTracerContext.java
> ----------------------------------------------------------------------
> diff --git a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceTracerContext.java b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceTracerContext.java
> new file mode 100644
> index 0000000..4bb6c73
> --- /dev/null
> +++ b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceTracerContext.java
> @@ -0,0 +1,38 @@
> +/**
> + * 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.jaxrs.tracing.htrace;
> +
> +import org.apache.cxf.tracing.TracerContext;
> +import org.apache.htrace.Sampler;
> +import org.apache.htrace.Trace;
> +import org.apache.htrace.TraceScope;
> +
> +public class HTraceTracerContext implements TracerContext {
> + private final Sampler< ? > sampler;
> +
> + public HTraceTracerContext(final Sampler< ? > sampler) {
> + this.sampler = sampler;
> + }
> +
> + @Override
> + @SuppressWarnings("unchecked")
> + public TraceScope startSpan(final String description) {
> + return Trace.startSpan(description, sampler);
> + }
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/parent/pom.xml
> ----------------------------------------------------------------------
> diff --git a/parent/pom.xml b/parent/pom.xml
> index da5efd6..63d5b51 100644
> --- a/parent/pom.xml
> +++ b/parent/pom.xml
> @@ -189,6 +189,7 @@
> <cxf.olingo.version>1.2.0</cxf.olingo.version>
> <cxf.tika.version>1.6</cxf.tika.version>
> <cxf.jexl.version>2.1.1</cxf.jexl.version>
> + <cxf.htrace.version>3.1.0-incubating</cxf.htrace.version>
> <cxf.checkstyle.extension />
> <cxf.jaxb.context.class />
> <cxf.spring.validation.mode>VALIDATION_AUTO</cxf.spring.validation.mode>
> @@ -1778,6 +1779,11 @@
> <artifactId>metrics-core</artifactId>
> <version>${cxf.dropwizard.version}</version>
> </dependency>
> + <dependency>
> + <groupId>org.apache.htrace</groupId>
> + <artifactId>htrace-core</artifactId>
> + <version>${cxf.htrace.version}</version>
> + </dependency>
> </dependencies>
> </dependencyManagement>
> <profiles>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/pom.xml
> ----------------------------------------------------------------------
> diff --git a/systests/pom.xml b/systests/pom.xml
> index e2beb50..da59c9a 100644
> --- a/systests/pom.xml
> +++ b/systests/pom.xml
> @@ -48,6 +48,7 @@
> <module>wsdl_maven</module>
> <module>cdi</module>
> <module>rs-http-sci</module>
> + <module>tracing</module>
> </modules>
>
> <profiles>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/tracing/pom.xml
> ----------------------------------------------------------------------
> diff --git a/systests/tracing/pom.xml b/systests/tracing/pom.xml
> new file mode 100644
> index 0000000..c0fa699
> --- /dev/null
> +++ b/systests/tracing/pom.xml
> @@ -0,0 +1,136 @@
> +<?xml version="1.0"?>
> +<!--
> + Licensed to the Apache Software Foundation (ASF) under one
> + or more contributor license agreements. See the NOTICE file
> + distributed with this work for additional information
> + regarding copyright ownership. The ASF licenses this file
> + to you under the Apache License, Version 2.0 (the
> + "License"); you may not use this file except in compliance
> + with the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing,
> + software distributed under the License is distributed on an
> + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + KIND, either express or implied. See the License for the
> + specific language governing permissions and limitations
> + under the License.
> +-->
> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
> + <parent>
> + <artifactId>cxf-parent</artifactId>
> + <groupId>org.apache.cxf</groupId>
> + <version>3.1.1-SNAPSHOT</version>
> + <relativePath>../../parent/pom.xml</relativePath>
> + </parent>
> + <modelVersion>4.0.0</modelVersion>
> + <groupId>org.apache.cxf.systests</groupId>
> + <artifactId>cxf-systests-tracing</artifactId>
> + <name>Apache CXF Distributed Tracing Integration System Tests</name>
> + <description>Apache CXF Distributed Tracing Integration System Tests</description>
> + <url>http://cxf.apache.org</url>
> + <properties>
> + <cxf.surefire.fork.vmargs>-XX:MaxPermSize=192m</cxf.surefire.fork.vmargs>
> + <cxf.server.launcher.vmargs>-XX:MaxPermSize=192m</cxf.server.launcher.vmargs>
> + </properties>
> + <dependencies>
> + <dependency>
> + <groupId>org.eclipse.jetty</groupId>
> + <artifactId>jetty-server</artifactId>
> + </dependency>
> + <dependency>
> + <groupId>org.eclipse.jetty</groupId>
> + <artifactId>jetty-plus</artifactId>
> + </dependency>
> + <dependency>
> + <groupId>org.eclipse.jetty</groupId>
> + <artifactId>jetty-jsp</artifactId>
> + <version>${cxf.jetty.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.slf4j</groupId>
> + <artifactId>slf4j-jdk14</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-transports-http-jetty</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-rt-frontend-jaxrs</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-rt-rs-client</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-integration-tracing-htrace</artifactId>
> + <version>${project.version}</version>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.cxf</groupId>
> + <artifactId>cxf-testutils</artifactId>
> + <version>${project.version}</version>
> + <scope>test</scope>
> + </dependency>
> + <dependency>
> + <groupId>javax.annotation</groupId>
> + <artifactId>jsr250-api</artifactId>
> + <version>1.0</version>
> + <scope>test</scope>
> + </dependency>
> + <dependency>
> + <groupId>junit</groupId>
> + <artifactId>junit</artifactId>
> + <scope>test</scope>
> + </dependency>
> + <dependency>
> + <groupId>com.fasterxml.jackson.jaxrs</groupId>
> + <artifactId>jackson-jaxrs-json-provider</artifactId>
> + <version>2.2.1</version>
> + </dependency>
> + <dependency>
> + <groupId>org.apache.httpcomponents</groupId>
> + <artifactId>httpclient</artifactId>
> + <scope>test</scope>
> + </dependency>
> + <dependency>
> + <groupId>com.ning</groupId>
> + <artifactId>async-http-client</artifactId>
> + <version>${cxf.ahc.version}</version>
> + <scope>test</scope>
> + <exclusions>
> + <exclusion>
> + <groupId>io.netty</groupId>
> + <artifactId>netty</artifactId>
> + </exclusion>
> + </exclusions>
> + </dependency>
> + </dependencies>
> + <build>
> + <plugins>
> + <plugin>
> + <artifactId>maven-jar-plugin</artifactId>
> + <executions>
> + <execution>
> + <id>attach-sources</id>
> + <goals>
> + <goal>test-jar</goal>
> + </goals>
> + </execution>
> + </executions>
> + </plugin>
> + </plugins>
> + </build>
> +</project>
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/Book.java
> ----------------------------------------------------------------------
> diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/Book.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/Book.java
> new file mode 100644
> index 0000000..baa499c
> --- /dev/null
> +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/Book.java
> @@ -0,0 +1,52 @@
> +/**
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +package org.apache.cxf.systest.jaxrs.tracing;
> +
> +public class Book {
> + private String title;
> + private String id;
> +
> + public Book() {
> + }
> +
> + public Book(String id) {
> + this.id = id;
> + }
> +
> + public Book(String title, String id) {
> + this.title = title;
> + this.id = id;
> + }
> +
> + public String getTitle() {
> + return title;
> + }
> +
> + public void setTitle(String title) {
> + this.title = title;
> + }
> +
> + public void setId(String i) {
> + id = i;
> + }
> +
> + public String getId() {
> + return id;
> + }
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java
> ----------------------------------------------------------------------
> diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java
> new file mode 100644
> index 0000000..d7949dc
> --- /dev/null
> +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.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.systest.jaxrs.tracing;
> +
> +import java.util.Arrays;
> +import java.util.Collection;
> +import java.util.UUID;
> +
> +import javax.ws.rs.GET;
> +import javax.ws.rs.Path;
> +import javax.ws.rs.Produces;
> +import javax.ws.rs.core.Context;
> +import javax.ws.rs.core.MediaType;
> +
> +import org.apache.cxf.tracing.TracerContext;
> +import org.apache.htrace.TraceScope;
> +
> +@Path("/bookstore/")
> +public class BookStore {
> + @Context private TracerContext tracer;
> +
> + @GET
> + @Path("/books")
> + @Produces(MediaType.APPLICATION_JSON)
> + public Collection< Book > getBooks() {
> + try (final TraceScope span = tracer.startSpan("Get Books")) {
> + return Arrays.asList(
> + new Book("Apache CXF in Action", UUID.randomUUID().toString()),
> + new Book("Mastering Apache CXF", UUID.randomUUID().toString())
> + );
> + }
> + }
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
> ----------------------------------------------------------------------
> diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
> new file mode 100644
> index 0000000..7591345
> --- /dev/null
> +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
> @@ -0,0 +1,95 @@
> +/**
> + * 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.systest.jaxrs.tracing.htrace;
> +
> +import java.util.Arrays;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import javax.ws.rs.core.MediaType;
> +import javax.ws.rs.core.Response;
> +import javax.ws.rs.core.Response.Status;
> +
> +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
> +
> +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
> +import org.apache.cxf.jaxrs.client.WebClient;
> +import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
> +import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
> +import org.apache.cxf.jaxrs.tracing.htrace.HTraceFeature;
> +import org.apache.cxf.systest.jaxrs.tracing.BookStore;
> +import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
> +import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
> +import org.apache.htrace.HTraceConfiguration;
> +import org.apache.htrace.impl.AlwaysSampler;
> +import org.junit.Before;
> +import org.junit.BeforeClass;
> +import org.junit.Ignore;
> +import org.junit.Test;
> +
> +import static org.hamcrest.CoreMatchers.equalTo;
> +
> +public class HTraceTracingTest extends AbstractBusClientServerTestBase {
> + public static final String PORT = allocatePort(HTraceTracingTest.class);
> +
> + @Ignore
> + public static class Server extends AbstractBusTestServerBase {
> + protected void run() {
> + final Map<String, String> properties = new HashMap<String, String>();
> + properties.put("span.receiver", TestSpanReceiver.class.getName());
> + properties.put("sampler", AlwaysSampler.class.getName());
> +
> + JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
> + sf.setResourceClasses(BookStore.class);
> + sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore()));
> + sf.setAddress("http://localhost:" + PORT);
> + sf.setProvider(new JacksonJsonProvider());
> + sf.setFeatures(Arrays.asList(new HTraceFeature(HTraceConfiguration.fromMap(properties))));
> + sf.create();
> + }
> + }
> +
> + @BeforeClass
> + public static void startServers() throws Exception {
> + AbstractResourceInfo.clearAllMaps();
> + //keep out of process due to stack traces testing failures
> + assertTrue("server did not launch correctly", launchServer(Server.class, true));
> + createStaticBus();
> + }
> +
> + @Before
> + public void setUp() {
> + TestSpanReceiver.clear();
> + }
> +
> + @Test
> + public void testThatPatternValidationFails() {
> + final Response r = createWebClient("/bookstore/books").get();
> + assertEquals(Status.OK.getStatusCode(), r.getStatus());
> +
> + assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(1));
> + assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(), equalTo("Get Books"));
> + }
> +
> + protected WebClient createWebClient(final String url) {
> + return WebClient
> + .create("http://localhost:" + PORT + url)
> + .accept(MediaType.APPLICATION_JSON);
> + }
> +}
>
> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/TestSpanReceiver.java
> ----------------------------------------------------------------------
> diff --git a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/TestSpanReceiver.java b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/TestSpanReceiver.java
> new file mode 100644
> index 0000000..1f533a7
> --- /dev/null
> +++ b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/TestSpanReceiver.java
> @@ -0,0 +1,61 @@
> +/**
> + * 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.systest.jaxrs.tracing.htrace;
> +
> +import java.io.IOException;
> +import java.util.ArrayList;
> +import java.util.Collection;
> +import java.util.HashSet;
> +import java.util.List;
> +
> +import org.apache.htrace.HTraceConfiguration;
> +import org.apache.htrace.Span;
> +import org.apache.htrace.SpanReceiver;
> +
> +/**
> + * Test HTrace Span receiver
> + */
> +public class TestSpanReceiver implements SpanReceiver {
> + private static Collection<Span> spans = new HashSet<Span>();
> +
> + public TestSpanReceiver(final HTraceConfiguration conf) {
> + }
> +
> + public Collection<Span> getSpans() {
> + return spans;
> + }
> +
> + @Override
> + public void close() throws IOException {
> + }
> +
> + @Override
> + public void receiveSpan(Span span) {
> + spans.add(span);
> + }
> +
> + public static void clear() {
> + spans.clear();
> + }
> +
> + public static List<Span> getAllSpans() {
> + return new ArrayList< Span >(spans);
> + }
> +
> +}
> \ No newline at end of file
>
Re: cxf git commit: CXF-6360: Integration with Apache HTrace
Posted by Sergey Beryozkin <sb...@gmail.com>.
A bit more thought is also needed on how to make it work for JAX-WS.
I'd probably consider having TracerContext in rt/management (you are
right that not only HTrace integration can offer such a context), and
then integration/tracing/htrace possibly JAX-RS neutral (CXF
interceptors only). Not sure yet but we can discuss it...
Thanks, Sergey
On 18/05/15 21:03, Sergey Beryozkin wrote:
> Hi Andriy
>
> Great stuff, thanks for starting this work.
> I'm actually not sure we need a tracing-core module at all.
> Can we have a TracerContext in rt/management and save on introducing one
> more module ?
>
> Thanks, Sergey
>
> On 18/05/15 19:25, reta@apache.org wrote:
>> Repository: cxf
>> Updated Branches:
>> refs/heads/master ab1f363e1 -> 7e82d2f10
>>
>>
>> CXF-6360: Integration with Apache HTrace
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
>> Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/7e82d2f1
>> Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/7e82d2f1
>> Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/7e82d2f1
>>
>> Branch: refs/heads/master
>> Commit: 7e82d2f10a1ca14a939d2c63ca4e620f8870e256
>> Parents: ab1f363
>> Author: reta <dr...@gmail.com>
>> Authored: Mon May 18 14:25:03 2015 -0400
>> Committer: reta <dr...@gmail.com>
>> Committed: Mon May 18 14:25:03 2015 -0400
>>
>> ----------------------------------------------------------------------
>> integration/pom.xml | 2 +
>> integration/tracing/tracing-core/pom.xml | 62 +++++++++
>> .../org/apache/cxf/tracing/TracerContext.java | 23 ++++
>> integration/tracing/tracing-htrace/pom.xml | 71 ++++++++++
>> .../tracing/htrace/HTraceContextProvider.java | 41 ++++++
>> .../cxf/jaxrs/tracing/htrace/HTraceFeature.java | 71 ++++++++++
>> .../jaxrs/tracing/htrace/HTraceProvider.java | 106 +++++++++++++++
>> .../tracing/htrace/HTraceTracerContext.java | 38 ++++++
>> parent/pom.xml | 6 +
>> systests/pom.xml | 1 +
>> systests/tracing/pom.xml | 136
>> +++++++++++++++++++
>> .../apache/cxf/systest/jaxrs/tracing/Book.java | 52 +++++++
>> .../cxf/systest/jaxrs/tracing/BookStore.java | 49 +++++++
>> .../jaxrs/tracing/htrace/HTraceTracingTest.java | 95 +++++++++++++
>> .../jaxrs/tracing/htrace/TestSpanReceiver.java | 61 +++++++++
>> 15 files changed, 814 insertions(+)
>> ----------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/pom.xml
>>
>> ----------------------------------------------------------------------
>> diff --git a/integration/pom.xml b/integration/pom.xml
>> index a3ba814..f46fdbb 100644
>> --- a/integration/pom.xml
>> +++ b/integration/pom.xml
>> @@ -32,5 +32,7 @@
>> <modules>
>> <module>jca</module>
>> <module>cdi</module>
>> + <module>tracing/tracing-core</module>
>> + <module>tracing/tracing-htrace</module>
>> </modules>
>> </project>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-core/pom.xml
>>
>> ----------------------------------------------------------------------
>> diff --git a/integration/tracing/tracing-core/pom.xml
>> b/integration/tracing/tracing-core/pom.xml
>> new file mode 100644
>> index 0000000..e405ebb
>> --- /dev/null
>> +++ b/integration/tracing/tracing-core/pom.xml
>> @@ -0,0 +1,62 @@
>> +<?xml version="1.0" encoding="UTF-8"?>
>> +<!--
>> + Licensed to the Apache Software Foundation (ASF) under one
>> + or more contributor license agreements. See the NOTICE file
>> + distributed with this work for additional information
>> + regarding copyright ownership. The ASF licenses this file
>> + to you under the Apache License, Version 2.0 (the
>> + "License"); you may not use this file except in compliance
>> + with the License. You may obtain a copy of the License at
>> +
>> + http://www.apache.org/licenses/LICENSE-2.0
>> +
>> + Unless required by applicable law or agreed to in writing,
>> + software distributed under the License is distributed on an
>> + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> + KIND, either express or implied. See the License for the
>> + specific language governing permissions and limitations
>> + under the License.
>> +-->
>> +<project xmlns="http://maven.apache.org/POM/4.0.0"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>> + <modelVersion>4.0.0</modelVersion>
>> + <artifactId>cxf-integration-tracing-core</artifactId>
>> + <packaging>jar</packaging>
>> + <name>Apache CXF Distributed Tracing Integration</name>
>> + <description>Apache CXF Distributed Tracing
>> Integration</description>
>> + <url>http://cxf.apache.org</url>
>> + <parent>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-parent</artifactId>
>> + <version>3.1.1-SNAPSHOT</version>
>> + <relativePath>../../../parent/pom.xml</relativePath>
>> + </parent>
>> +
>> + <properties>
>> + <cxf.osgi.export>
>> + org.apache.cxf.tracing
>> + </cxf.osgi.export>
>> + </properties>
>> +
>> + <dependencies>
>> + <dependency>
>> + <groupId>junit</groupId>
>> + <artifactId>junit</artifactId>
>> + <scope>test</scope>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-core</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-rt-frontend-jaxrs</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.slf4j</groupId>
>> + <artifactId>slf4j-jdk14</artifactId>
>> + <scope>test</scope>
>> + </dependency>
>> + </dependencies>
>> +</project>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-core/src/main/java/org/apache/cxf/tracing/TracerContext.java
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/integration/tracing/tracing-core/src/main/java/org/apache/cxf/tracing/TracerContext.java
>> b/integration/tracing/tracing-core/src/main/java/org/apache/cxf/tracing/TracerContext.java
>>
>> new file mode 100644
>> index 0000000..2e1f37e
>> --- /dev/null
>> +++
>> b/integration/tracing/tracing-core/src/main/java/org/apache/cxf/tracing/TracerContext.java
>>
>> @@ -0,0 +1,23 @@
>> +/**
>> + * 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;
>> +
>> +public interface TracerContext {
>> + <T> T startSpan(final String desription);
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-htrace/pom.xml
>>
>> ----------------------------------------------------------------------
>> diff --git a/integration/tracing/tracing-htrace/pom.xml
>> b/integration/tracing/tracing-htrace/pom.xml
>> new file mode 100644
>> index 0000000..b418fb5
>> --- /dev/null
>> +++ b/integration/tracing/tracing-htrace/pom.xml
>> @@ -0,0 +1,71 @@
>> +<?xml version="1.0" encoding="UTF-8"?>
>> +<!--
>> + Licensed to the Apache Software Foundation (ASF) under one
>> + or more contributor license agreements. See the NOTICE file
>> + distributed with this work for additional information
>> + regarding copyright ownership. The ASF licenses this file
>> + to you under the Apache License, Version 2.0 (the
>> + "License"); you may not use this file except in compliance
>> + with the License. You may obtain a copy of the License at
>> +
>> + http://www.apache.org/licenses/LICENSE-2.0
>> +
>> + Unless required by applicable law or agreed to in writing,
>> + software distributed under the License is distributed on an
>> + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> + KIND, either express or implied. See the License for the
>> + specific language governing permissions and limitations
>> + under the License.
>> +-->
>> +<project xmlns="http://maven.apache.org/POM/4.0.0"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>> + <modelVersion>4.0.0</modelVersion>
>> + <artifactId>cxf-integration-tracing-htrace</artifactId>
>> + <packaging>jar</packaging>
>> + <name>Apache CXF Distributed Tracing using Apache HTrace</name>
>> + <description>Apache CXF Distributed using Apache
>> HTrace</description>
>> + <url>http://cxf.apache.org</url>
>> + <parent>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-parent</artifactId>
>> + <version>3.1.1-SNAPSHOT</version>
>> + <relativePath>../../../parent/pom.xml</relativePath>
>> + </parent>
>> +
>> + <properties>
>> + <cxf.osgi.export>
>> + org.apache.cxf.tracing
>> + </cxf.osgi.export>
>> + </properties>
>> +
>> + <dependencies>
>> + <dependency>
>> + <groupId>junit</groupId>
>> + <artifactId>junit</artifactId>
>> + <scope>test</scope>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-core</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-rt-frontend-jaxrs</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-integration-tracing-core</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.htrace</groupId>
>> + <artifactId>htrace-core</artifactId>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.slf4j</groupId>
>> + <artifactId>slf4j-jdk14</artifactId>
>> + <scope>test</scope>
>> + </dependency>
>> + </dependencies>
>> +</project>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
>> b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
>>
>> new file mode 100644
>> index 0000000..c983f1d
>> --- /dev/null
>> +++
>> b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceContextProvider.java
>>
>> @@ -0,0 +1,41 @@
>> +/**
>> + * 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.jaxrs.tracing.htrace;
>> +
>> +import javax.ws.rs.ext.Provider;
>> +
>> +import org.apache.cxf.jaxrs.ext.ContextProvider;
>> +import org.apache.cxf.message.Message;
>> +import org.apache.cxf.tracing.TracerContext;
>> +import org.apache.htrace.Sampler;
>> +import org.apache.htrace.impl.NeverSampler;
>> +
>> +@Provider
>> +public class HTraceContextProvider implements ContextProvider<
>> TracerContext > {
>> + private Sampler< ? > sampler = NeverSampler.INSTANCE;
>> +
>> + public HTraceContextProvider(final Sampler< ? > sampler) {
>> + this.sampler = sampler;
>> + }
>> +
>> + @Override
>> + public TracerContext createContext(final Message message) {
>> + return new HTraceTracerContext(sampler);
>> + }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
>> b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
>>
>> new file mode 100644
>> index 0000000..2b14f99
>> --- /dev/null
>> +++
>> b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceFeature.java
>>
>> @@ -0,0 +1,71 @@
>> +/**
>> + * Licensed to the Apache Software Foundation (ASF) under one
>> + * or more contributor license agreements. See the NOTICE file
>> + * distributed with this work for additional information
>> + * regarding copyright ownership. The ASF licenses this file
>> + * to you under the Apache License, Version 2.0 (the
>> + * "License"); you may not use this file except in compliance
>> + * with the License. You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> + * software distributed under the License is distributed on an
>> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> + * KIND, either express or implied. See the License for the
>> + * specific language governing permissions and limitations
>> + * under the License.
>> + */
>> +package org.apache.cxf.jaxrs.tracing.htrace;
>> +
>> +import java.util.Arrays;
>> +
>> +import org.apache.cxf.Bus;
>> +import org.apache.cxf.endpoint.Server;
>> +import org.apache.cxf.feature.AbstractFeature;
>> +import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
>> +import org.apache.htrace.HTraceConfiguration;
>> +import org.apache.htrace.Sampler;
>> +import org.apache.htrace.SamplerBuilder;
>> +import org.apache.htrace.SpanReceiver;
>> +import org.apache.htrace.SpanReceiverBuilder;
>> +import org.apache.htrace.Trace;
>> +
>> +public class HTraceFeature extends AbstractFeature {
>> + private HTraceConfiguration configuration;
>> +
>> + public HTraceFeature() {
>> + this(HTraceConfiguration.EMPTY);
>> + }
>> +
>> + public HTraceFeature(final HTraceConfiguration configuration) {
>> + this.configuration = configuration;
>> + }
>> +
>> + @Override
>> + public void initialize(final Server server, final Bus bus) {
>> + final ServerProviderFactory providerFactory =
>> (ServerProviderFactory)server
>> + .getEndpoint()
>> + .get(ServerProviderFactory.class.getName());
>> +
>> + final Sampler< ? > sampler = new
>> SamplerBuilder(configuration).build();
>> + final SpanReceiver spanReceiver = new
>> SpanReceiverBuilder(configuration).build();
>> +
>> + if (spanReceiver != null) {
>> + Trace.addReceiver(spanReceiver);
>> + }
>> +
>> + if (providerFactory != null) {
>> + providerFactory.setUserProviders(Arrays.asList(new
>> HTraceProvider(sampler),
>> + new HTraceContextProvider(sampler)));
>> + }
>> + }
>> +
>> + public void setConfiguration(final HTraceConfiguration
>> configuration) {
>> + this.configuration = configuration;
>> + }
>> +
>> + public HTraceConfiguration getConfiguration() {
>> + return configuration;
>> + }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
>> b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
>>
>> new file mode 100644
>> index 0000000..a66d93b
>> --- /dev/null
>> +++
>> b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceProvider.java
>>
>> @@ -0,0 +1,106 @@
>> +/**
>> + * 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.jaxrs.tracing.htrace;
>> +
>> +import java.io.IOException;
>> +import java.util.List;
>> +import java.util.logging.Level;
>> +import java.util.logging.Logger;
>> +
>> +import javax.ws.rs.container.ContainerRequestContext;
>> +import javax.ws.rs.container.ContainerRequestFilter;
>> +import javax.ws.rs.container.ContainerResponseContext;
>> +import javax.ws.rs.container.ContainerResponseFilter;
>> +import javax.ws.rs.core.MultivaluedMap;
>> +import javax.ws.rs.ext.Provider;
>> +
>> +import org.apache.cxf.common.logging.LogUtils;
>> +import org.apache.htrace.Sampler;
>> +import org.apache.htrace.Trace;
>> +import org.apache.htrace.TraceInfo;
>> +import org.apache.htrace.Tracer;
>> +import org.apache.htrace.impl.NeverSampler;
>> +
>> +@Provider
>> +public class HTraceProvider implements ContainerRequestFilter,
>> ContainerResponseFilter {
>> + private static final Logger LOG =
>> LogUtils.getL7dLogger(HTraceProvider.class);
>> +
>> + private static final String HEADER_TRACE_ID = "X-Trace-Id";
>> + private static final String HEADER_SPAN_ID = "X-Span-Id";
>> +
>> + private final Sampler< ? > sampler;
>> +
>> + public HTraceProvider() {
>> + this(NeverSampler.INSTANCE);
>> + }
>> +
>> + public HTraceProvider(final Sampler< ? > sampler) {
>> + this.sampler = sampler;
>> + }
>> +
>> + @SuppressWarnings("unchecked")
>> + @Override
>> + public void filter(final ContainerRequestContext requestContext)
>> throws IOException {
>> + final MultivaluedMap<String, String> headers =
>> requestContext.getHeaders();
>> +
>> + // Try to extract the Trace Id value from the request header
>> + final long traceId = getFirstValueOrDefault(headers,
>> HEADER_TRACE_ID,
>> + Tracer.DONT_TRACE.traceId);
>> +
>> + // Try to extract the Span Id value from the request header
>> + final long spanId = getFirstValueOrDefault(headers,
>> HEADER_SPAN_ID,
>> + Tracer.DONT_TRACE.spanId);
>> +
>> + if (traceId != Tracer.DONT_TRACE.traceId && spanId !=
>> Tracer.DONT_TRACE.spanId) {
>> + Trace.startSpan(requestContext.getUriInfo().getPath(),
>> (Sampler< TraceInfo >)sampler,
>> + new TraceInfo(traceId, spanId));
>> + }
>> + }
>> +
>> + @Override
>> + public void filter(final ContainerRequestContext requestContext,
>> + final ContainerResponseContext responseContext) throws
>> IOException {
>> + final MultivaluedMap<String, String> headers =
>> requestContext.getHeaders();
>> +
>> + // Transfer tracing headers into the response headers
>> + if (headers.containsKey(HEADER_TRACE_ID) &&
>> headers.containsKey(HEADER_SPAN_ID)) {
>> + responseContext.getHeaders().add(HEADER_TRACE_ID,
>> headers.getFirst(HEADER_TRACE_ID));
>> + responseContext.getHeaders().add(HEADER_SPAN_ID,
>> headers.getFirst(HEADER_SPAN_ID));
>> + }
>> + }
>> +
>> + private static Long getFirstValueOrDefault(final
>> MultivaluedMap<String, String> headers,
>> + final String header, final long defaultValue) {
>> +
>> + if (!headers.containsKey(header)) {
>> + return defaultValue;
>> + }
>> +
>> + try {
>> + final List< String > values = headers.get(header);
>> + if (values != null && !values.isEmpty()) {
>> + return Long.parseLong(values.get(0));
>> + }
>> + } catch (NumberFormatException ex) {
>> + LOG.log(Level.FINE, String.format("Unable to parse '%s'
>> header value to long number", header), ex);
>> + }
>> +
>> + return defaultValue;
>> + }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceTracerContext.java
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceTracerContext.java
>> b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceTracerContext.java
>>
>> new file mode 100644
>> index 0000000..4bb6c73
>> --- /dev/null
>> +++
>> b/integration/tracing/tracing-htrace/src/main/java/org/apache/cxf/jaxrs/tracing/htrace/HTraceTracerContext.java
>>
>> @@ -0,0 +1,38 @@
>> +/**
>> + * 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.jaxrs.tracing.htrace;
>> +
>> +import org.apache.cxf.tracing.TracerContext;
>> +import org.apache.htrace.Sampler;
>> +import org.apache.htrace.Trace;
>> +import org.apache.htrace.TraceScope;
>> +
>> +public class HTraceTracerContext implements TracerContext {
>> + private final Sampler< ? > sampler;
>> +
>> + public HTraceTracerContext(final Sampler< ? > sampler) {
>> + this.sampler = sampler;
>> + }
>> +
>> + @Override
>> + @SuppressWarnings("unchecked")
>> + public TraceScope startSpan(final String description) {
>> + return Trace.startSpan(description, sampler);
>> + }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/parent/pom.xml
>> ----------------------------------------------------------------------
>> diff --git a/parent/pom.xml b/parent/pom.xml
>> index da5efd6..63d5b51 100644
>> --- a/parent/pom.xml
>> +++ b/parent/pom.xml
>> @@ -189,6 +189,7 @@
>> <cxf.olingo.version>1.2.0</cxf.olingo.version>
>> <cxf.tika.version>1.6</cxf.tika.version>
>> <cxf.jexl.version>2.1.1</cxf.jexl.version>
>> + <cxf.htrace.version>3.1.0-incubating</cxf.htrace.version>
>> <cxf.checkstyle.extension />
>> <cxf.jaxb.context.class />
>>
>> <cxf.spring.validation.mode>VALIDATION_AUTO</cxf.spring.validation.mode>
>> @@ -1778,6 +1779,11 @@
>> <artifactId>metrics-core</artifactId>
>> <version>${cxf.dropwizard.version}</version>
>> </dependency>
>> + <dependency>
>> + <groupId>org.apache.htrace</groupId>
>> + <artifactId>htrace-core</artifactId>
>> + <version>${cxf.htrace.version}</version>
>> + </dependency>
>> </dependencies>
>> </dependencyManagement>
>> <profiles>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/pom.xml
>> ----------------------------------------------------------------------
>> diff --git a/systests/pom.xml b/systests/pom.xml
>> index e2beb50..da59c9a 100644
>> --- a/systests/pom.xml
>> +++ b/systests/pom.xml
>> @@ -48,6 +48,7 @@
>> <module>wsdl_maven</module>
>> <module>cdi</module>
>> <module>rs-http-sci</module>
>> + <module>tracing</module>
>> </modules>
>>
>> <profiles>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/tracing/pom.xml
>>
>> ----------------------------------------------------------------------
>> diff --git a/systests/tracing/pom.xml b/systests/tracing/pom.xml
>> new file mode 100644
>> index 0000000..c0fa699
>> --- /dev/null
>> +++ b/systests/tracing/pom.xml
>> @@ -0,0 +1,136 @@
>> +<?xml version="1.0"?>
>> +<!--
>> + Licensed to the Apache Software Foundation (ASF) under one
>> + or more contributor license agreements. See the NOTICE file
>> + distributed with this work for additional information
>> + regarding copyright ownership. The ASF licenses this file
>> + to you under the Apache License, Version 2.0 (the
>> + "License"); you may not use this file except in compliance
>> + with the License. You may obtain a copy of the License at
>> +
>> + http://www.apache.org/licenses/LICENSE-2.0
>> +
>> + Unless required by applicable law or agreed to in writing,
>> + software distributed under the License is distributed on an
>> + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> + KIND, either express or implied. See the License for the
>> + specific language governing permissions and limitations
>> + under the License.
>> +-->
>> +<project xmlns="http://maven.apache.org/POM/4.0.0"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
>> http://maven.apache.org/maven-v4_0_0.xsd">
>> + <parent>
>> + <artifactId>cxf-parent</artifactId>
>> + <groupId>org.apache.cxf</groupId>
>> + <version>3.1.1-SNAPSHOT</version>
>> + <relativePath>../../parent/pom.xml</relativePath>
>> + </parent>
>> + <modelVersion>4.0.0</modelVersion>
>> + <groupId>org.apache.cxf.systests</groupId>
>> + <artifactId>cxf-systests-tracing</artifactId>
>> + <name>Apache CXF Distributed Tracing Integration System Tests</name>
>> + <description>Apache CXF Distributed Tracing Integration System
>> Tests</description>
>> + <url>http://cxf.apache.org</url>
>> + <properties>
>> +
>> <cxf.surefire.fork.vmargs>-XX:MaxPermSize=192m</cxf.surefire.fork.vmargs>
>> +
>> <cxf.server.launcher.vmargs>-XX:MaxPermSize=192m</cxf.server.launcher.vmargs>
>>
>> + </properties>
>> + <dependencies>
>> + <dependency>
>> + <groupId>org.eclipse.jetty</groupId>
>> + <artifactId>jetty-server</artifactId>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.eclipse.jetty</groupId>
>> + <artifactId>jetty-plus</artifactId>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.eclipse.jetty</groupId>
>> + <artifactId>jetty-jsp</artifactId>
>> + <version>${cxf.jetty.version}</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.slf4j</groupId>
>> + <artifactId>slf4j-jdk14</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-transports-http-jetty</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-rt-frontend-jaxrs</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-rt-rs-client</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-integration-tracing-htrace</artifactId>
>> + <version>${project.version}</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.cxf</groupId>
>> + <artifactId>cxf-testutils</artifactId>
>> + <version>${project.version}</version>
>> + <scope>test</scope>
>> + </dependency>
>> + <dependency>
>> + <groupId>javax.annotation</groupId>
>> + <artifactId>jsr250-api</artifactId>
>> + <version>1.0</version>
>> + <scope>test</scope>
>> + </dependency>
>> + <dependency>
>> + <groupId>junit</groupId>
>> + <artifactId>junit</artifactId>
>> + <scope>test</scope>
>> + </dependency>
>> + <dependency>
>> + <groupId>com.fasterxml.jackson.jaxrs</groupId>
>> + <artifactId>jackson-jaxrs-json-provider</artifactId>
>> + <version>2.2.1</version>
>> + </dependency>
>> + <dependency>
>> + <groupId>org.apache.httpcomponents</groupId>
>> + <artifactId>httpclient</artifactId>
>> + <scope>test</scope>
>> + </dependency>
>> + <dependency>
>> + <groupId>com.ning</groupId>
>> + <artifactId>async-http-client</artifactId>
>> + <version>${cxf.ahc.version}</version>
>> + <scope>test</scope>
>> + <exclusions>
>> + <exclusion>
>> + <groupId>io.netty</groupId>
>> + <artifactId>netty</artifactId>
>> + </exclusion>
>> + </exclusions>
>> + </dependency>
>> + </dependencies>
>> + <build>
>> + <plugins>
>> + <plugin>
>> + <artifactId>maven-jar-plugin</artifactId>
>> + <executions>
>> + <execution>
>> + <id>attach-sources</id>
>> + <goals>
>> + <goal>test-jar</goal>
>> + </goals>
>> + </execution>
>> + </executions>
>> + </plugin>
>> + </plugins>
>> + </build>
>> +</project>
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/Book.java
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/Book.java
>> b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/Book.java
>>
>> new file mode 100644
>> index 0000000..baa499c
>> --- /dev/null
>> +++
>> b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/Book.java
>>
>> @@ -0,0 +1,52 @@
>> +/**
>> + * Licensed to the Apache Software Foundation (ASF) under one
>> + * or more contributor license agreements. See the NOTICE file
>> + * distributed with this work for additional information
>> + * regarding copyright ownership. The ASF licenses this file
>> + * to you under the Apache License, Version 2.0 (the
>> + * "License"); you may not use this file except in compliance
>> + * with the License. You may obtain a copy of the License at
>> + *
>> + * http://www.apache.org/licenses/LICENSE-2.0
>> + *
>> + * Unless required by applicable law or agreed to in writing,
>> + * software distributed under the License is distributed on an
>> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>> + * KIND, either express or implied. See the License for the
>> + * specific language governing permissions and limitations
>> + * under the License.
>> + */
>> +package org.apache.cxf.systest.jaxrs.tracing;
>> +
>> +public class Book {
>> + private String title;
>> + private String id;
>> +
>> + public Book() {
>> + }
>> +
>> + public Book(String id) {
>> + this.id = id;
>> + }
>> +
>> + public Book(String title, String id) {
>> + this.title = title;
>> + this.id = id;
>> + }
>> +
>> + public String getTitle() {
>> + return title;
>> + }
>> +
>> + public void setTitle(String title) {
>> + this.title = title;
>> + }
>> +
>> + public void setId(String i) {
>> + id = i;
>> + }
>> +
>> + public String getId() {
>> + return id;
>> + }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java
>> b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.java
>>
>> new file mode 100644
>> index 0000000..d7949dc
>> --- /dev/null
>> +++
>> b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/BookStore.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.systest.jaxrs.tracing;
>> +
>> +import java.util.Arrays;
>> +import java.util.Collection;
>> +import java.util.UUID;
>> +
>> +import javax.ws.rs.GET;
>> +import javax.ws.rs.Path;
>> +import javax.ws.rs.Produces;
>> +import javax.ws.rs.core.Context;
>> +import javax.ws.rs.core.MediaType;
>> +
>> +import org.apache.cxf.tracing.TracerContext;
>> +import org.apache.htrace.TraceScope;
>> +
>> +@Path("/bookstore/")
>> +public class BookStore {
>> + @Context private TracerContext tracer;
>> +
>> + @GET
>> + @Path("/books")
>> + @Produces(MediaType.APPLICATION_JSON)
>> + public Collection< Book > getBooks() {
>> + try (final TraceScope span = tracer.startSpan("Get Books")) {
>> + return Arrays.asList(
>> + new Book("Apache CXF in Action",
>> UUID.randomUUID().toString()),
>> + new Book("Mastering Apache CXF",
>> UUID.randomUUID().toString())
>> + );
>> + }
>> + }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
>> b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
>>
>> new file mode 100644
>> index 0000000..7591345
>> --- /dev/null
>> +++
>> b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/HTraceTracingTest.java
>>
>> @@ -0,0 +1,95 @@
>> +/**
>> + * 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.systest.jaxrs.tracing.htrace;
>> +
>> +import java.util.Arrays;
>> +import java.util.HashMap;
>> +import java.util.Map;
>> +
>> +import javax.ws.rs.core.MediaType;
>> +import javax.ws.rs.core.Response;
>> +import javax.ws.rs.core.Response.Status;
>> +
>> +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
>> +
>> +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
>> +import org.apache.cxf.jaxrs.client.WebClient;
>> +import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
>> +import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
>> +import org.apache.cxf.jaxrs.tracing.htrace.HTraceFeature;
>> +import org.apache.cxf.systest.jaxrs.tracing.BookStore;
>> +import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
>> +import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
>> +import org.apache.htrace.HTraceConfiguration;
>> +import org.apache.htrace.impl.AlwaysSampler;
>> +import org.junit.Before;
>> +import org.junit.BeforeClass;
>> +import org.junit.Ignore;
>> +import org.junit.Test;
>> +
>> +import static org.hamcrest.CoreMatchers.equalTo;
>> +
>> +public class HTraceTracingTest extends AbstractBusClientServerTestBase {
>> + public static final String PORT =
>> allocatePort(HTraceTracingTest.class);
>> +
>> + @Ignore
>> + public static class Server extends AbstractBusTestServerBase {
>> + protected void run() {
>> + final Map<String, String> properties = new
>> HashMap<String, String>();
>> + properties.put("span.receiver",
>> TestSpanReceiver.class.getName());
>> + properties.put("sampler", AlwaysSampler.class.getName());
>> +
>> + JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
>> + sf.setResourceClasses(BookStore.class);
>> + sf.setResourceProvider(BookStore.class, new
>> SingletonResourceProvider(new BookStore()));
>> + sf.setAddress("http://localhost:" + PORT);
>> + sf.setProvider(new JacksonJsonProvider());
>> + sf.setFeatures(Arrays.asList(new
>> HTraceFeature(HTraceConfiguration.fromMap(properties))));
>> + sf.create();
>> + }
>> + }
>> +
>> + @BeforeClass
>> + public static void startServers() throws Exception {
>> + AbstractResourceInfo.clearAllMaps();
>> + //keep out of process due to stack traces testing failures
>> + assertTrue("server did not launch correctly",
>> launchServer(Server.class, true));
>> + createStaticBus();
>> + }
>> +
>> + @Before
>> + public void setUp() {
>> + TestSpanReceiver.clear();
>> + }
>> +
>> + @Test
>> + public void testThatPatternValidationFails() {
>> + final Response r = createWebClient("/bookstore/books").get();
>> + assertEquals(Status.OK.getStatusCode(), r.getStatus());
>> +
>> + assertThat(TestSpanReceiver.getAllSpans().size(), equalTo(1));
>> +
>> assertThat(TestSpanReceiver.getAllSpans().get(0).getDescription(),
>> equalTo("Get Books"));
>> + }
>> +
>> + protected WebClient createWebClient(final String url) {
>> + return WebClient
>> + .create("http://localhost:" + PORT + url)
>> + .accept(MediaType.APPLICATION_JSON);
>> + }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/blob/7e82d2f1/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/TestSpanReceiver.java
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/TestSpanReceiver.java
>> b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/TestSpanReceiver.java
>>
>> new file mode 100644
>> index 0000000..1f533a7
>> --- /dev/null
>> +++
>> b/systests/tracing/src/test/java/org/apache/cxf/systest/jaxrs/tracing/htrace/TestSpanReceiver.java
>>
>> @@ -0,0 +1,61 @@
>> +/**
>> + * 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.systest.jaxrs.tracing.htrace;
>> +
>> +import java.io.IOException;
>> +import java.util.ArrayList;
>> +import java.util.Collection;
>> +import java.util.HashSet;
>> +import java.util.List;
>> +
>> +import org.apache.htrace.HTraceConfiguration;
>> +import org.apache.htrace.Span;
>> +import org.apache.htrace.SpanReceiver;
>> +
>> +/**
>> + * Test HTrace Span receiver
>> + */
>> +public class TestSpanReceiver implements SpanReceiver {
>> + private static Collection<Span> spans = new HashSet<Span>();
>> +
>> + public TestSpanReceiver(final HTraceConfiguration conf) {
>> + }
>> +
>> + public Collection<Span> getSpans() {
>> + return spans;
>> + }
>> +
>> + @Override
>> + public void close() throws IOException {
>> + }
>> +
>> + @Override
>> + public void receiveSpan(Span span) {
>> + spans.add(span);
>> + }
>> +
>> + public static void clear() {
>> + spans.clear();
>> + }
>> +
>> + public static List<Span> getAllSpans() {
>> + return new ArrayList< Span >(spans);
>> + }
>> +
>> +}
>> \ No newline at end of file
>>
>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com