You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/02/17 12:15:28 UTC

[4/8] camel git commit: Camel OpenTracing support

Camel OpenTracing support

Added decorators for http and jetty - for some reason the service2 http.status field is not captured because Exchange.hasOut() returns false - and if getOut() is accessed, it results in no result being returned from the service


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

Branch: refs/heads/master
Commit: d58fea9b1bbeef0ae6f5220253b8bf2a10b9f5f8
Parents: 39102b27
Author: Gary Brown <ga...@brownuk.com>
Authored: Thu Feb 9 16:30:56 2017 +0000
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Feb 17 12:07:03 2017 +0100

----------------------------------------------------------------------
 components/camel-opentracing/pom.xml            |  96 +++++++++
 .../src/main/docs/opentracing.adoc              |  57 +++++
 .../opentracing/CamelHeadersExtractAdapter.java |  43 ++++
 .../opentracing/CamelHeadersInjectAdapter.java  |  40 ++++
 .../camel/opentracing/OpenTracingTracer.java    | 213 +++++++++++++++++++
 .../apache/camel/opentracing/SpanDecorator.java |  81 +++++++
 .../decorators/AbstractHttpSpanDecorator.java   |  45 ++++
 .../decorators/AbstractSpanDecorator.java       |  60 ++++++
 .../decorators/HttpSpanDecorator.java           |  36 ++++
 .../decorators/JettySpanDecorator.java          |  36 ++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 ++++++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../org.apache.camel.opentracing.SpanDecorator  |   2 +
 .../apache/camel/opentracing/ABCRouteTest.java  |  81 +++++++
 .../CamelOpenTracingTestSupport.java            | 122 +++++++++++
 .../ClientRecipientListRouteTest.java           |  77 +++++++
 .../camel/opentracing/MulticastRouteTest.java   |  82 +++++++
 .../opentracing/OpenTracingSimpleRouteTest.java |  51 +++++
 .../camel/opentracing/RouteConcurrentTest.java  |  85 ++++++++
 .../apache/camel/opentracing/SpanTestData.java  |  62 ++++++
 .../opentracing/TestSEDASpanDecorator.java      |  49 +++++
 .../camel/opentracing/TwoServiceTest.java       |  65 ++++++
 .../org.apache.camel.opentracing.SpanDecorator  |   1 +
 .../src/test/resources/log4j2.properties        |  30 +++
 .../opentracing/OpenTracingSimpleRouteTest.xml  |  50 +++++
 components/pom.xml                              |   1 +
 docs/user-manual/en/SUMMARY.md                  |   1 +
 examples/camel-example-opentracing/README.md    |  61 ++++++
 .../camel-example-opentracing/client/pom.xml    | 125 +++++++++++
 .../java/sample/camel/ClientApplication.java    |  33 +++
 .../src/main/java/sample/camel/ClientRoute.java |  33 +++
 .../src/main/java/sample/camel/CounterBean.java |  32 +++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 ++++++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../src/main/resources/META-INF/beans.xml       |  18 ++
 .../client/src/main/resources/log4j2.properties |  25 +++
 .../loggingtracer/pom.xml                       |  62 ++++++
 .../opentracing/logging/LoggingTracer.java      |  46 ++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 ++++++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../src/main/resources/META-INF/beans.xml       |  18 ++
 .../META-INF/services/io.opentracing.Tracer     |   1 +
 .../src/main/resources/log4j2.properties        |  25 +++
 examples/camel-example-opentracing/pom.xml      |  41 ++++
 .../camel-example-opentracing/service1/pom.xml  | 101 +++++++++
 .../java/sample/camel/Service1Application.java  |  41 ++++
 .../main/java/sample/camel/Service1Route.java   |  36 ++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 ++++++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../src/main/resources/application.properties   |  25 +++
 .../camel-example-opentracing/service2/pom.xml  | 109 ++++++++++
 .../java/sample/camel/Service2Application.java  |  33 +++
 .../main/java/sample/camel/Service2Route.java   |  36 ++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 ++++++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../src/main/resources/log4j2.properties        |  25 +++
 examples/pom.xml                                |   1 +
 parent/pom.xml                                  |  13 ++
 .../camel-opentracing-starter/pom.xml           |  51 +++++
 .../opentracing/starter/CamelOpenTracing.java   |  34 +++
 .../starter/OpenTracingAutoConfiguration.java   |  43 ++++
 ...OpenTracingConditionalAutoConfiguration.java |  31 +++
 .../OpenTracingConfigurationProperties.java     |  26 +++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 ++++++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../main/resources/META-INF/spring.factories    |  19 ++
 .../src/main/resources/META-INF/spring.provides |  18 ++
 .../spring-boot/components-starter/pom.xml      |   1 +
 68 files changed, 3913 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/pom.xml b/components/camel-opentracing/pom.xml
new file mode 100644
index 0000000..6f0f550
--- /dev/null
+++ b/components/camel-opentracing/pom.xml
@@ -0,0 +1,96 @@
+<?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>
+
+  <parent>
+    <artifactId>components</artifactId>
+    <groupId>org.apache.camel</groupId>
+    <version>2.19.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-opentracing</artifactId>
+  <packaging>jar</packaging>
+  <name>Camel :: OpenTracing</name>
+  <description>Distributed tracing using OpenTracing</description>
+
+  <properties>
+    <!-- use by camel-catalog -->
+    <firstVersion>2.19.0</firstVersion>
+    <label>monitoring,microservice,opentracing</label>
+
+    <camel.osgi.export.pkg>org.apache.camel.opentracing.*</camel.osgi.export.pkg>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+
+    <!-- OpenTracing -->
+    <dependency>
+      <groupId>io.opentracing</groupId>
+      <artifactId>opentracing-api</artifactId>
+      <version>${opentracing-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>io.opentracing.contrib</groupId>
+      <artifactId>opentracing-globaltracer</artifactId>
+      <version>${opentracing-java-globaltracer-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>io.opentracing.contrib</groupId>
+      <artifactId>opentracing-spanmanager</artifactId>
+      <version>${opentracing-java-spanmanager-version}</version>
+    </dependency>
+
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>io.opentracing</groupId>
+      <artifactId>opentracing-mock</artifactId>
+      <version>${opentracing-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test-spring</artifactId>
+      <scope>test</scope>
+    </dependency>  
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/docs/opentracing.adoc
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/docs/opentracing.adoc b/components/camel-opentracing/src/main/docs/opentracing.adoc
new file mode 100644
index 0000000..7778660
--- /dev/null
+++ b/components/camel-opentracing/src/main/docs/opentracing.adoc
@@ -0,0 +1,57 @@
+[[OpenTracing-OpenTracingComponent]]
+OpenTracing Component
+~~~~~~~~~~~~~~~~~~~~~
+
+*Available as of Camel 2.19*
+
+The camel-opentracing component is used for tracing and timing incoming and
+outgoing Camel messages using http://opentracing.io/[OpenTracing].
+
+Events (spans) are captured for incoming and outgoing messages being sent
+to/from Camel.
+
+The component uses the https://github.com/opentracing-contrib/java-globaltracer[Global Tracer]
+project to obtain an OpenTracing provider. See the http://opentracing.io/[OpenTracing]
+website for a list of supported tracers.
+
+
+[[camel-opentracing-Example]]
+Example
+^^^^^^^
+
+To enable camel-opentracing you need to configure first
+
+[source,java]
+--------------------------------------------------------------------------------------------------
+OpenTracingTracer ottracer = new OpenTracingTracer();
+// by default uses the Global Tracer, but can override with specific OpenTracing implementation
+ottracer.setTracer(...);
+// and then set the CamelContext
+ottracer.setCamelContext(camelContext);
+--------------------------------------------------------------------------------------------------
+
+The configuration above will trace all incoming and outgoing
+messages in Camel routes.�
+
+To use OpenTracingTracer in XML, all you need to do is to define the
+OpenTracing tracer beans. Camel will automatically discover and use them.
+
+[source,xml]
+---------------------------------------------------------------------------------------------------------
+  <!-- setup opentracing tracer -->
+  <bean id="ottracer" class="org.apache.camel.opentracing.OpenTracingTracer">
+    <!-- Optional - use if want to specific tracer explicitly, rather than use the java-globaltracer -->
+    <property name="tracer" ref="tracer"/>
+  </bean>
+---------------------------------------------------------------------------------------------------------
+
+[[camel-opentracing-camel-opentracing-starter]]
+camel-opentracing-starter
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If you are using�link:spring-boot.html[Spring Boot] then you can add
+the�`camel-opentracing-starter` dependency, and turn on OpenTracing by annotating
+the main class with `@CamelOpenTracing`.
+
+You can find an example of this in
+the�https://github.com/apache/camel/tree/master/examples/camel-example-opentracing[camel-example-opentracing]

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/CamelHeadersExtractAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/CamelHeadersExtractAdapter.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/CamelHeadersExtractAdapter.java
new file mode 100644
index 0000000..cb8a9cb
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/CamelHeadersExtractAdapter.java
@@ -0,0 +1,43 @@
+/**
+ * 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.camel.opentracing;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import io.opentracing.propagation.TextMap;
+
+public final class CamelHeadersExtractAdapter implements TextMap {
+    private final Map<String, String> map = new HashMap<String, String>();
+
+    public CamelHeadersExtractAdapter(final Map<String,Object> map) {
+        // Extract string valued map entries
+        map.entrySet().stream().filter(e -> e.getValue() instanceof String).forEach(e ->
+                this.map.put(e.getKey(),(String)e.getValue()));
+     }
+
+    @Override
+    public Iterator<Map.Entry<String, String>> iterator() {
+        return map.entrySet().iterator();
+    }
+
+    @Override
+    public void put(String key, String value) {
+        throw new UnsupportedOperationException("CamelHeadersExtractAdapter should only be used with Tracer.extract()");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/CamelHeadersInjectAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/CamelHeadersInjectAdapter.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/CamelHeadersInjectAdapter.java
new file mode 100644
index 0000000..1370168
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/CamelHeadersInjectAdapter.java
@@ -0,0 +1,40 @@
+/**
+ * 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.camel.opentracing;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import io.opentracing.propagation.TextMap;
+
+public final class CamelHeadersInjectAdapter implements TextMap {
+    private final Map<String, Object> map;
+
+    public CamelHeadersInjectAdapter(final Map<String, Object> map) {
+        this.map = map;
+    }
+
+    @Override
+    public Iterator<Map.Entry<String, String>> iterator() {
+        throw new UnsupportedOperationException("CamelHeadersInjectAdapter should only be used with Tracer.inject()");
+    }
+
+    @Override
+    public void put(String key, String value) {
+        this.map.put(key, value);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/OpenTracingTracer.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/OpenTracingTracer.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/OpenTracingTracer.java
new file mode 100644
index 0000000..2ee6d4b
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/OpenTracingTracer.java
@@ -0,0 +1,213 @@
+/**
+ * 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.camel.opentracing;
+
+import java.net.URI;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ServiceLoader;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Route;
+import org.apache.camel.management.event.ExchangeSendingEvent;
+import org.apache.camel.management.event.ExchangeSentEvent;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.spi.RoutePolicy;
+import org.apache.camel.spi.RoutePolicyFactory;
+import org.apache.camel.support.EventNotifierSupport;
+import org.apache.camel.support.RoutePolicySupport;
+import org.apache.camel.util.ServiceHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.opentracing.Span;
+import io.opentracing.Tracer;
+import io.opentracing.Tracer.SpanBuilder;
+import io.opentracing.contrib.global.GlobalTracer;
+import io.opentracing.contrib.spanmanager.DefaultSpanManager;
+import io.opentracing.contrib.spanmanager.SpanManager;
+import io.opentracing.propagation.Format;
+import io.opentracing.tag.Tags;
+
+/**
+ * To use OpenTracing with Camel then setup this {@link OpenTracingTracer} in your Camel application.
+ * <p/>
+ * This class is implemented as both an {@link org.apache.camel.spi.EventNotifier} and {@link RoutePolicy} that allows
+ * to trap when Camel starts/ends an {@link Exchange} being routed using the {@link RoutePolicy} and during the routing
+ * if the {@link Exchange} sends messages, then we track them using the {@link org.apache.camel.spi.EventNotifier}.
+ */
+public class OpenTracingTracer implements RoutePolicyFactory, CamelContextAware {
+
+    private static final Logger LOG = LoggerFactory.getLogger(OpenTracingTracer.class);
+
+    private final OpenTracingEventNotifier eventNotifier = new OpenTracingEventNotifier();
+
+    private CamelContext camelContext;
+
+    private Tracer tracer = GlobalTracer.get();
+    private SpanManager spanManager = DefaultSpanManager.getInstance();
+
+    private static Map<String, SpanDecorator> decorators = new HashMap<>();
+
+    static {
+        ServiceLoader.load(SpanDecorator.class).forEach(d -> decorators.put(d.getComponent(), d));
+    }
+
+    public OpenTracingTracer() {
+    }
+
+    @Override
+    public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, RouteDefinition route) {
+        return new OpenTracingRoutePolicy(routeId);
+    }
+
+    @Override
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    @Override
+    public void setCamelContext(CamelContext camelContext) {
+        if (this.camelContext != null) {
+            // stop event notifier
+            camelContext.getManagementStrategy().removeEventNotifier(eventNotifier);
+
+             // remove route policy
+            camelContext.getRoutePolicyFactories().remove(this);
+        }
+
+        this.camelContext = camelContext;
+
+        if (this.camelContext != null) {
+            camelContext.getManagementStrategy().addEventNotifier(eventNotifier);
+            if (!camelContext.getRoutePolicyFactories().contains(this)) {
+                camelContext.addRoutePolicyFactory(this);
+            }
+            
+            // TODO: In example client, this was required otherwise outbound invocations
+            // were not instrumented - may be better to reinstate StaticService approach, but
+            // then need to resolve issue with xml dsl correctly starting service to init
+            // event notifier.
+            try {
+                ServiceHelper.startServices(eventNotifier);
+            } catch (Exception e) {
+                LOG.error("Failed to start event notifier", e);
+            }
+        }
+    }
+
+    public Tracer getTracer() {
+    	return tracer;
+    }
+
+    public void setTracer(Tracer tracer) {
+    	this.tracer = tracer;
+    }
+
+    protected SpanDecorator getSpanDecorator(Endpoint endpoint) {
+        SpanDecorator sd = decorators.get(URI.create(endpoint.getEndpointUri()).getScheme());
+        if (sd == null) {
+            return SpanDecorator.DEFAULT;
+        }
+        return sd;
+    }
+
+    private final class OpenTracingEventNotifier extends EventNotifierSupport {
+
+        @Override
+        public void notify(EventObject event) throws Exception {
+            if (event instanceof ExchangeSendingEvent) {
+                ExchangeSendingEvent ese = (ExchangeSendingEvent) event;
+                SpanManager.ManagedSpan parent = spanManager.current();
+                SpanDecorator sd = getSpanDecorator(ese.getEndpoint());
+                SpanBuilder spanBuilder = tracer.buildSpan(sd.getOperationName(ese.getExchange(), ese.getEndpoint()))
+                		.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
+                // Temporary workaround to avoid adding 'null' span as a parent
+                if (parent != null && parent.getSpan() != null) {
+                    spanBuilder.asChildOf(parent.getSpan());
+                }
+                Span span = spanBuilder.start();
+                sd.pre(span, ese.getExchange(), ese.getEndpoint());
+                tracer.inject(span.context(), Format.Builtin.TEXT_MAP,
+                        new CamelHeadersInjectAdapter(ese.getExchange().getIn().getHeaders()));
+                spanManager.manage(span);
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("OpenTracing: start client span=" + span);
+                }
+            } else if (event instanceof ExchangeSentEvent) {
+                SpanManager.ManagedSpan managedSpan = spanManager.current();
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("OpenTracing: start client span=" + managedSpan.getSpan());
+                }
+                SpanDecorator sd = getSpanDecorator(((ExchangeSentEvent)event).getEndpoint());
+                sd.post(managedSpan.getSpan(), ((ExchangeSentEvent)event).getExchange(),
+                        ((ExchangeSentEvent)event).getEndpoint());
+                managedSpan.getSpan().finish();
+                managedSpan.release();
+            }
+        }
+
+        @Override
+        public boolean isEnabled(EventObject event) {
+            return event instanceof ExchangeSendingEvent
+                    || event instanceof ExchangeSentEvent;
+        }
+
+        @Override
+        public String toString() {
+            return "OpenTracingEventNotifier";
+        }
+    }
+
+    private final class OpenTracingRoutePolicy extends RoutePolicySupport {
+
+        OpenTracingRoutePolicy(String routeId) {
+        }
+
+        @Override
+        public void onExchangeBegin(Route route, Exchange exchange) {
+            SpanDecorator sd = getSpanDecorator(route.getEndpoint());
+            Span span = tracer.buildSpan(sd.getOperationName(exchange, route.getEndpoint()))
+                    .asChildOf(tracer.extract(Format.Builtin.TEXT_MAP,
+                            new CamelHeadersExtractAdapter(exchange.getIn().getHeaders())))
+            		.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
+            		.start();
+            sd.pre(span, exchange, route.getEndpoint());
+            spanManager.manage(span);
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("OpenTracing: start server span=" + span);
+            }
+        }
+
+        @Override
+        public void onExchangeDone(Route route, Exchange exchange) {
+            SpanManager.ManagedSpan managedSpan = spanManager.current();
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("OpenTracing: finish server span=" + managedSpan.getSpan());
+            }
+            SpanDecorator sd = getSpanDecorator(route.getEndpoint());
+            sd.post(managedSpan.getSpan(), exchange, route.getEndpoint());
+            managedSpan.getSpan().finish();
+            managedSpan.release();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/SpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/SpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/SpanDecorator.java
new file mode 100644
index 0000000..5c4bdf4
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/SpanDecorator.java
@@ -0,0 +1,81 @@
+/**
+ * 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.camel.opentracing;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.opentracing.decorators.AbstractSpanDecorator;
+
+import io.opentracing.Span;
+
+/**
+ * This interface represents a decorator specific to the component/endpoint
+ * being instrumented.
+ *
+ */
+public interface SpanDecorator {
+
+    /* Prefix for camel component tag */
+    public static final String CAMEL_COMPONENT = "camel-";
+
+    /**
+     * The camel component associated with the decorator.
+     *
+     * @return The camel component name
+     */
+    String getComponent();
+
+    /**
+     * This method returns the operation name to use with the Span representing
+     * this exchange and endpoint.
+     *
+     * @param exchange The exchange
+     * @param endpoint The endpoint
+     * @return The operation name
+     */
+    String getOperationName(Exchange exchange, Endpoint endpoint);
+
+    /**
+     * This method adds appropriate details (tags/logs) to the supplied span
+     * based on the pre processing of the exchange.
+     *
+     * @param span The span
+     * @param exchange The exchange
+     * @param endpoint The endpoint
+     */
+    void pre(Span span, Exchange exchange, Endpoint endpoint);
+
+    /**
+     * This method adds appropriate details (tags/logs) to the supplied span
+     * based on the post processing of the exchange.
+     *
+     * @param span The span
+     * @param exchange The exchange
+     * @param endpoint The endpoint
+     */
+    void post(Span span, Exchange exchange, Endpoint endpoint);
+
+    SpanDecorator DEFAULT = new AbstractSpanDecorator() {
+
+        @Override
+        public String getComponent() {
+            return null;
+        }
+        
+    };
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractHttpSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractHttpSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractHttpSpanDecorator.java
new file mode 100644
index 0000000..dcd40ff
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractHttpSpanDecorator.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing.decorators;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+import io.opentracing.Span;
+import io.opentracing.tag.Tags;
+
+public abstract class AbstractHttpSpanDecorator extends AbstractSpanDecorator {
+
+    @Override
+    public void pre(Span span, Exchange exchange, Endpoint endpoint) {
+        super.pre(span, exchange, endpoint);
+        span.setTag(Tags.HTTP_URL.getKey(), endpoint.getEndpointUri());
+    }
+
+    @Override
+    public void post(Span span, Exchange exchange, Endpoint endpoint) {
+        super.post(span, exchange, endpoint);
+
+        if (exchange.hasOut()) {
+            Object responseCode=exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE);
+            if (responseCode instanceof Integer) {
+                span.setTag(Tags.HTTP_STATUS.getKey(), (Integer)responseCode);
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractSpanDecorator.java
new file mode 100644
index 0000000..f32a287
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AbstractSpanDecorator.java
@@ -0,0 +1,60 @@
+/**
+ * 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.camel.opentracing.decorators;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.opentracing.SpanDecorator;
+
+import io.opentracing.Span;
+import io.opentracing.tag.Tags;
+
+/**
+ * An abstract base implementation of the {@link SpanDecorator} interface.
+ *
+ */
+public abstract class AbstractSpanDecorator implements SpanDecorator {
+
+    @Override
+    public String getOperationName(Exchange exchange, Endpoint endpoint) {
+        return endpoint.getEndpointUri();
+    }
+
+    @Override
+    public void pre(Span span, Exchange exchange, Endpoint endpoint) {     
+        span.setTag(Tags.COMPONENT.getKey(), CAMEL_COMPONENT + URI.create(endpoint.getEndpointUri()).getScheme());
+    }
+
+    @Override
+    public void post(Span span, Exchange exchange, Endpoint endpoint) {
+        if (exchange.isFailed()) {
+            span.setTag(Tags.ERROR.getKey(), true);
+            if (exchange.getException() != null) {
+                Map<String,String> logEvent = new HashMap<>();
+                logEvent.put("event", "error");
+                logEvent.put("error.kind", "Exception");
+                logEvent.put("message", exchange.getException().getMessage());
+                span.log(logEvent);
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/HttpSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/HttpSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/HttpSpanDecorator.java
new file mode 100644
index 0000000..43eec8a
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/HttpSpanDecorator.java
@@ -0,0 +1,36 @@
+/**
+ * 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.camel.opentracing.decorators;
+
+import java.net.URI;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+public class HttpSpanDecorator extends AbstractHttpSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "http";
+    }
+
+    @Override
+    public String getOperationName(Exchange exchange, Endpoint endpoint) {
+        return URI.create(endpoint.getEndpointUri()).getPath();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/JettySpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/JettySpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/JettySpanDecorator.java
new file mode 100644
index 0000000..8137100
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/JettySpanDecorator.java
@@ -0,0 +1,36 @@
+/**
+ * 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.camel.opentracing.decorators;
+
+import java.net.URI;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+public class JettySpanDecorator extends AbstractHttpSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "jetty";
+    }
+
+    @Override
+    public String getOperationName(Exchange exchange, Endpoint endpoint) {
+        return URI.create(endpoint.getEndpointUri().substring(getComponent().length()+1)).getPath();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/resources/META-INF/LICENSE.txt b/components/camel-opentracing/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-opentracing/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/resources/META-INF/NOTICE.txt b/components/camel-opentracing/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-opentracing/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator b/components/camel-opentracing/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
new file mode 100644
index 0000000..9806d26
--- /dev/null
+++ b/components/camel-opentracing/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
@@ -0,0 +1,2 @@
+org.apache.camel.opentracing.decorators.HttpSpanDecorator
+org.apache.camel.opentracing.decorators.JettySpanDecorator

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/ABCRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/ABCRouteTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/ABCRouteTest.java
new file mode 100644
index 0000000..dc172c6
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/ABCRouteTest.java
@@ -0,0 +1,81 @@
+/**
+ * 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.camel.opentracing;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+import io.opentracing.tag.Tags;
+
+public class ABCRouteTest extends CamelOpenTracingTestSupport {
+
+    private static SpanTestData[] testdata = {
+            new SpanTestData().setLabel("seda:b server").setUri("seda://b")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(1),
+            new SpanTestData().setLabel("seda:b client").setUri("seda://b")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(4),
+            new SpanTestData().setLabel("seda:c server").setUri("seda://c")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(3),
+            new SpanTestData().setLabel("seda:c client").setUri("seda://c")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(4),
+            new SpanTestData().setLabel("seda:a server").setUri("seda://a")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(5),
+            new SpanTestData().setLabel("seda:a client").setUri("seda://a")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(6),
+            new SpanTestData().setLabel("direct:start server").setUri("direct://start")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(7),
+            new SpanTestData().setLabel("direct:start client").setUri("direct://start")
+                    .setKind(Tags.SPAN_KIND_CLIENT)
+    };
+
+    public ABCRouteTest() {
+        super(testdata);
+    }
+
+    @Test
+    public void testRoute() throws Exception {
+        template.requestBody("direct:start", "Hello");
+
+        verify();
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("seda:a").routeId("start");
+
+                from("seda:a").routeId("a")
+                    .log("routing at ${routeId}")
+                    .to("seda:b")
+                    .delay(2000)
+                    .to("seda:c")
+                    .log("End of routing");
+
+                from("seda:b").routeId("b")
+                        .log("routing at ${routeId}")
+                        .delay(simple("${random(1000,2000)}"));
+
+                from("seda:c").routeId("c")
+                        .log("routing at ${routeId}")
+                        .delay(simple("${random(0,100)}"));
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/CamelOpenTracingTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/CamelOpenTracingTestSupport.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/CamelOpenTracingTestSupport.java
new file mode 100644
index 0000000..b3aa1b4
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/CamelOpenTracingTestSupport.java
@@ -0,0 +1,122 @@
+/**
+ * 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.camel.opentracing;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+import io.opentracing.Span;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.mock.MockTracer.Propagator;
+import io.opentracing.tag.Tags;
+
+public class CamelOpenTracingTestSupport extends CamelTestSupport {
+
+    private MockTracer tracer;
+
+    private SpanTestData[] testdata;
+
+    public CamelOpenTracingTestSupport(SpanTestData[] testdata) {
+        this.testdata = testdata;
+    }
+
+    @Override
+    protected void doPostSetup() throws Exception {
+        tracer.reset();
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+
+        tracer = new MockTracer(Propagator.TEXT_MAP);
+        
+        OpenTracingTracer ottracer = new OpenTracingTracer();
+        ottracer.setTracer(tracer);
+        
+        ottracer.setCamelContext(context);
+
+        return context;
+    }
+
+    protected MockTracer getTracer() {
+        return tracer;
+    }
+
+    protected void verify() {
+        assertEquals("Incorrect number of spans", testdata.length, tracer.finishedSpans().size());
+        
+        for (int i=0; i < testdata.length; i++) {
+            if (i > 0) {
+                assertEquals(testdata[i].getLabel(), tracer.finishedSpans().get(0).context().traceId(),
+                    tracer.finishedSpans().get(i).context().traceId());   
+            }
+
+            String component = (String)tracer.finishedSpans().get(i).tags().get(Tags.COMPONENT.getKey());
+            assertNotNull(component);
+            assertEquals(testdata[i].getLabel(),
+                    SpanDecorator.CAMEL_COMPONENT + URI.create((String)testdata[i].getUri()).getScheme(),
+                    component);
+
+            // If span associated with TestSEDASpanDecorator, check that 'testop' and pre/post tags have been defined
+            if ("camel-seda".equals(component)) {
+                assertEquals("testop", tracer.finishedSpans().get(i).operationName());
+                assertTrue(tracer.finishedSpans().get(i).tags().containsKey("pre"));
+                assertTrue(tracer.finishedSpans().get(i).tags().containsKey("post"));
+            } else {
+                assertEquals(testdata[i].getLabel(), testdata[i].getUri(), tracer.finishedSpans().get(i).operationName());
+            }
+
+            assertEquals(testdata[i].getLabel(), testdata[i].getKind(),
+                    tracer.finishedSpans().get(i).tags().get(Tags.SPAN_KIND.getKey()));
+
+            if (testdata[i].getParentId() != -1) {
+                assertEquals(testdata[i].getLabel(),
+                        tracer.finishedSpans().get(testdata[i].getParentId()).context().spanId(),
+                        tracer.finishedSpans().get(i).parentId());
+            }
+
+        }
+    }
+
+    protected void verifyTraceSpanNumbers(int numOfTraces, int numSpansPerTrace) {
+        Map<Long,List<Span>> traces = new HashMap<Long,List<Span>>();
+
+        // Sort spans into separate traces
+        for (int i=0; i < getTracer().finishedSpans().size(); i++) {
+            List<Span> spans = traces.get(getTracer().finishedSpans().get(i).context().traceId());
+            if (spans == null) {
+                spans = new ArrayList<Span>();
+                traces.put(getTracer().finishedSpans().get(i).context().traceId(), spans);
+            }
+            spans.add(getTracer().finishedSpans().get(i));
+        }
+
+        assertEquals(numOfTraces, traces.size());
+
+        for (Map.Entry<Long,List<Span>> spans : traces.entrySet()) {
+            assertEquals(numSpansPerTrace, spans.getValue().size());
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/ClientRecipientListRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/ClientRecipientListRouteTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/ClientRecipientListRouteTest.java
new file mode 100644
index 0000000..f9849b2
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/ClientRecipientListRouteTest.java
@@ -0,0 +1,77 @@
+/**
+ * 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.camel.opentracing;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+import io.opentracing.tag.Tags;
+
+public class ClientRecipientListRouteTest extends CamelOpenTracingTestSupport {
+
+    private static SpanTestData[] testdata = {
+            new SpanTestData().setLabel("seda:a server").setUri("seda://a")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(1),
+            new SpanTestData().setLabel("seda:a client").setUri("seda://a")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(6),
+            new SpanTestData().setLabel("seda:b server").setUri("seda://b")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(3),
+            new SpanTestData().setLabel("seda:b client").setUri("seda://b")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(6),
+            new SpanTestData().setLabel("seda:c server").setUri("seda://c")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(5),
+            new SpanTestData().setLabel("seda:c client").setUri("seda://c")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(6),
+            new SpanTestData().setLabel("direct:start server").setUri("direct://start")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(7),
+            new SpanTestData().setLabel("direct:start client").setUri("direct://start")
+                    .setKind(Tags.SPAN_KIND_CLIENT)
+    };
+
+    public ClientRecipientListRouteTest() {
+        super(testdata);
+    }
+
+    @Test
+    public void testRoute() throws Exception {
+        template.requestBody("direct:start", "Hello");
+
+        verify();
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").recipientList(constant("seda:a,seda:b,seda:c")).routeId("start");
+
+                from("seda:a").routeId("a")
+                    .log("routing at ${routeId}");
+
+                from("seda:b").routeId("b")
+                        .log("routing at ${routeId}")
+                        .delay(simple("${random(1000,2000)}"));
+
+                from("seda:c").routeId("c")
+                        .log("routing at ${routeId}")
+                        .delay(simple("${random(0,100)}"));
+           }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/MulticastRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/MulticastRouteTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/MulticastRouteTest.java
new file mode 100644
index 0000000..c24fab6
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/MulticastRouteTest.java
@@ -0,0 +1,82 @@
+/**
+ * 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.camel.opentracing;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+import io.opentracing.tag.Tags;
+
+public class MulticastRouteTest extends CamelOpenTracingTestSupport {
+
+    private static SpanTestData[] testdata = {
+            new SpanTestData().setLabel("seda:b server").setUri("seda://b")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(1),
+            new SpanTestData().setLabel("seda:b client").setUri("seda://b")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(4),
+            new SpanTestData().setLabel("seda:c server").setUri("seda://c")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(3),
+            new SpanTestData().setLabel("seda:c client").setUri("seda://c")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(4),
+            new SpanTestData().setLabel("seda:a server").setUri("seda://a")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(5),
+            new SpanTestData().setLabel("seda:a client").setUri("seda://a")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(6),
+            new SpanTestData().setLabel("direct:start server").setUri("direct://start")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(7),
+            new SpanTestData().setLabel("direct:start client").setUri("direct://start")
+                    .setKind(Tags.SPAN_KIND_CLIENT)
+    };
+
+    public MulticastRouteTest() {
+        super(testdata);
+    }
+
+    @Test
+    public void testRoute() throws Exception {
+        template.requestBody("direct:start", "Hello");
+
+        verify();
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("seda:a").routeId("start");
+
+                from("seda:a").routeId("a")
+                    .log("routing at ${routeId}")
+                    .multicast()
+                        .to("seda:b")
+                        .to("seda:c")
+                    .end()
+                    .log("End of routing");
+
+                from("seda:b").routeId("b")
+                        .log("routing at ${routeId}")
+                        .delay(simple("${random(1000,2000)}"));
+
+                from("seda:c").routeId("c")
+                        .log("routing at ${routeId}")
+                        .delay(simple("${random(0,100)}"));
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.java
new file mode 100644
index 0000000..c33359c
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.NotifyBuilder;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import io.opentracing.mock.MockTracer;
+
+public class OpenTracingSimpleRouteTest extends CamelSpringTestSupport {
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/opentracing/OpenTracingSimpleRouteTest.xml");
+    }
+
+    @Test
+    public void testRoute() throws Exception {
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();
+
+        for (int i = 0; i < 5; i++) {
+            template.sendBody("seda:dude", "Hello World");
+        }
+
+        assertTrue(notify.matches(30, TimeUnit.SECONDS));
+
+        MockTracer tracer = (MockTracer)context().getRegistry().lookupByName("mockTracer");
+
+        // Four spans per invocation, one for client, two for dude route (server and client to), one for car route
+        assertEquals(20, tracer.finishedSpans().size());
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/RouteConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/RouteConcurrentTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/RouteConcurrentTest.java
new file mode 100644
index 0000000..6d13a8d
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/RouteConcurrentTest.java
@@ -0,0 +1,85 @@
+/**
+ * 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.camel.opentracing;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.NotifyBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+import io.opentracing.tag.Tags;
+
+public class RouteConcurrentTest extends CamelOpenTracingTestSupport {
+
+    private static SpanTestData[] testdata = {
+            new SpanTestData().setLabel("seda:foo client").setUri("seda://foo")
+                    .setKind(Tags.SPAN_KIND_CLIENT),
+            new SpanTestData().setLabel("seda:bar client").setUri("seda://bar")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(2),
+            new SpanTestData().setLabel("seda:foo server").setUri("seda://foo?concurrentConsumers=5")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(0),
+            new SpanTestData().setLabel("seda:bar server").setUri("seda://bar?concurrentConsumers=5")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(1)
+    };
+
+    public RouteConcurrentTest() {
+        super(testdata);
+    }
+
+    @Test
+    public void testSingleInvocationsOfRoute() throws Exception {
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();
+
+        template.sendBody("seda:foo", "Hello World");
+
+        assertTrue(notify.matches(30, TimeUnit.SECONDS));
+
+        verify();
+    }
+
+    @Test
+    public void testConcurrentInvocationsOfRoute() throws Exception {
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(10).create();
+
+        for (int i = 0; i < 5; i++) {
+            template.sendBody("seda:foo", "Hello World");
+        }
+
+        assertTrue(notify.matches(30, TimeUnit.SECONDS));
+
+        verifyTraceSpanNumbers(5,  testdata.length);
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("seda:foo?concurrentConsumers=5").routeId("foo")
+                    .log("routing at ${routeId}")
+                    .delay(simple("${random(1000,2000)}"))
+                    .to("seda:bar");
+
+                from("seda:bar?concurrentConsumers=5").routeId("bar")
+                    .log("routing at ${routeId}")
+                    .delay(simple("${random(0,500)}"));
+           }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/SpanTestData.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/SpanTestData.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/SpanTestData.java
new file mode 100644
index 0000000..4bf542a
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/SpanTestData.java
@@ -0,0 +1,62 @@
+/**
+ * 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.camel.opentracing;
+
+public class SpanTestData {
+
+    private String label;
+    private String uri;
+    private String kind;
+    private int parentId = -1;
+
+    public String getLabel() {
+        return label;
+    }
+
+    public SpanTestData setLabel(String label) {
+        this.label = label;
+        return this;
+    }
+
+    public String getUri() {
+        return uri;
+    }
+
+    public SpanTestData setUri(String uri) {
+        this.uri = uri;
+        return this;
+    }
+
+    public String getKind() {
+        return kind;
+    }
+
+    public SpanTestData setKind(String kind) {
+        this.kind = kind;
+        return this;
+    }
+
+    public int getParentId() {
+        return parentId;
+    }
+
+    public SpanTestData setParentId(int parentId) {
+        this.parentId = parentId;
+        return this;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/TestSEDASpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/TestSEDASpanDecorator.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/TestSEDASpanDecorator.java
new file mode 100644
index 0000000..f7e3bd4
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/TestSEDASpanDecorator.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.camel.opentracing;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.opentracing.decorators.AbstractSpanDecorator;
+
+import io.opentracing.Span;
+
+public class TestSEDASpanDecorator extends AbstractSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "seda";
+    }
+
+    @Override
+    public String getOperationName(Exchange exchange, Endpoint endpoint) {
+        return "testop";
+    }
+
+    @Override
+    public void pre(Span span, Exchange exchange, Endpoint endpoint) {
+        super.pre(span, exchange, endpoint);
+        span.setTag("pre", "test");
+    }
+
+    @Override
+    public void post(Span span, Exchange exchange, Endpoint endpoint) {
+        super.post(span, exchange, endpoint);
+        span.setTag("post", "test");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/TwoServiceTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/TwoServiceTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/TwoServiceTest.java
new file mode 100644
index 0000000..45a8a33
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/TwoServiceTest.java
@@ -0,0 +1,65 @@
+/**
+ * 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.camel.opentracing;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+import io.opentracing.tag.Tags;
+
+public class TwoServiceTest extends CamelOpenTracingTestSupport {
+
+    private static SpanTestData[] testdata = {
+            new SpanTestData().setLabel("ServiceB server").setUri("direct://ServiceB")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(1),
+            new SpanTestData().setLabel("ServiceB client").setUri("direct://ServiceB")
+                    .setKind(Tags.SPAN_KIND_CLIENT).setParentId(2),
+            new SpanTestData().setLabel("ServiceA server").setUri("direct://ServiceA")
+                    .setKind(Tags.SPAN_KIND_SERVER).setParentId(3),
+            new SpanTestData().setLabel("ServiceA client").setUri("direct://ServiceA")
+                    .setKind(Tags.SPAN_KIND_CLIENT)
+    };
+
+    public TwoServiceTest() {
+        super(testdata);
+    }
+
+    @Test
+    public void testRoute() throws Exception {
+        template.requestBody("direct:ServiceA", "Hello");
+
+        verify();
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:ServiceA")
+		            .log("ServiceA has been called")
+                    .delay(simple("${random(1000,2000)}"))
+		            .to("direct:ServiceB");
+
+                from("direct:ServiceB")
+		            .log("ServiceB has been called")
+		            .delay(simple("${random(0,500)}"));
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator b/components/camel-opentracing/src/test/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
new file mode 100644
index 0000000..75e4398
--- /dev/null
+++ b/components/camel-opentracing/src/test/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
@@ -0,0 +1 @@
+org.apache.camel.opentracing.TestSEDASpanDecorator

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/resources/log4j2.properties b/components/camel-opentracing/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..1ceb5bb
--- /dev/null
+++ b/components/camel-opentracing/src/test/resources/log4j2.properties
@@ -0,0 +1,30 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-opentracing-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+logger.opentracing.name = org.apache.camel.opentracing
+logger.opentracing.level = INFO
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/camel-opentracing/src/test/resources/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/resources/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.xml b/components/camel-opentracing/src/test/resources/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.xml
new file mode 100644
index 0000000..6f99c81
--- /dev/null
+++ b/components/camel-opentracing/src/test/resources/org/apache/camel/opentracing/OpenTracingSimpleRouteTest.xml
@@ -0,0 +1,50 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <bean id="mockTracer" class="io.opentracing.mock.MockTracer"/>
+
+  <!-- setup opentracing tracer -->
+  <bean id="ottracer" class="org.apache.camel.opentracing.OpenTracingTracer">
+    <property name="tracer" ref="mockTracer"/>
+  </bean>
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring">
+    <route id="dude">
+      <from uri="seda:dude"/>
+      <log message="Routing at ${routeId}"/>
+      <delay>
+        <simple>${random(1000,2000)}</simple>
+      </delay>
+      <to uri="direct:car"/>
+    </route>
+    <route id="car">
+      <from uri="direct:car"/>
+      <log message="Routing at ${routeId}"/>
+      <delay>
+        <simple>${random(1000,2000)}</simple>
+      </delay>
+    </route>
+  </camelContext>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/d58fea9b/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index b265d79..b3f3864 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -207,6 +207,7 @@
     <module>camel-olingo2</module>
     <module>camel-openshift</module>
     <module>camel-openstack</module>
+    <module>camel-opentracing</module>
     <module>camel-optaplanner</module>
     <module>camel-paho</module>
     <module>camel-paxlogging</module>