camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: Update spanmanager version, add decorators and tests for other camel components
Date Sat, 04 Mar 2017 15:05:58 GMT
Repository: camel
Updated Branches:
  refs/heads/master bf1b57ca2 -> f97c6af6a


Update spanmanager version, add decorators and tests for other camel components


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

Branch: refs/heads/master
Commit: 84b21a8a9f20c3e87b688ca5f7f2796a60e6e123
Parents: bf1b57c
Author: Gary Brown <gary@brownuk.com>
Authored: Wed Mar 1 16:18:35 2017 +0000
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Mar 4 15:59:45 2017 +0100

----------------------------------------------------------------------
 components/camel-opentracing/pom.xml            |   5 +
 .../camel/opentracing/OpenTracingTracer.java    |   8 +-
 .../decorators/AbstractHttpSpanDecorator.java   |  58 +++-
 .../decorators/AhcSpanDecorator.java            |  26 ++
 .../decorators/Http4SpanDecorator.java          |  26 ++
 .../decorators/HttpSpanDecorator.java           |  10 -
 .../decorators/JdbcSpanDecorator.java           |  43 +++
 .../decorators/JettySpanDecorator.java          |  10 -
 .../decorators/MongoDBSpanDecorator.java        |  74 +++++
 .../decorators/NettyHttp4SpanDecorator.java     |  26 ++
 .../decorators/NettyHttpSpanDecorator.java      |  26 ++
 .../decorators/RestletSpanDecorator.java        |  26 ++
 .../decorators/ServletSpanDecorator.java        |  26 ++
 .../decorators/SqlSpanDecorator.java            |  45 ++++
 .../decorators/TimerSpanDecorator.java          |  39 +++
 .../decorators/UndertowSpanDecorator.java       |  26 ++
 .../org.apache.camel.opentracing.SpanDecorator  |  11 +
 .../AbstractHttpSpanDecoratorTest.java          | 267 +++++++++++++++++++
 .../decorators/AbstractSpanDecoratorTest.java   | 100 +++++++
 .../decorators/JdbcSpanDecoratorTest.java       |  56 ++++
 .../decorators/MongoDBSpanDecoratorTest.java    |  76 ++++++
 .../decorators/SqlSpanDecoratorTest.java        |  56 ++++
 .../decorators/TimerSpanDecoratorTest.java      |  46 ++++
 parent/pom.xml                                  |   2 +-
 24 files changed, 1062 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/pom.xml b/components/camel-opentracing/pom.xml
index 92d3d9d..384a01f 100644
--- a/components/camel-opentracing/pom.xml
+++ b/components/camel-opentracing/pom.xml
@@ -91,6 +91,11 @@
       <artifactId>log4j-slf4j-impl</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
 
   </dependencies>
 

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/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
index a737499..759634f 100644
--- 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
@@ -167,7 +167,7 @@ public class OpenTracingTracer extends ServiceSupport implements RoutePolicyFact
                 sd.pre(span, ese.getExchange(), ese.getEndpoint());
                 tracer.inject(span.context(), Format.Builtin.TEXT_MAP,
                     new CamelHeadersInjectAdapter(ese.getExchange().getIn().getHeaders()));
-                spanManager.manage(span);
+                spanManager.activate(span);
                 if (LOG.isTraceEnabled()) {
                     LOG.trace("OpenTracing: start client span=" + span);
                 }
@@ -180,7 +180,7 @@ public class OpenTracingTracer extends ServiceSupport implements RoutePolicyFact
                 sd.post(managedSpan.getSpan(), ((ExchangeSentEvent) event).getExchange(),
                     ((ExchangeSentEvent) event).getEndpoint());
                 managedSpan.getSpan().finish();
-                managedSpan.release();
+                managedSpan.deactivate();
             }
         }
 
@@ -210,7 +210,7 @@ public class OpenTracingTracer extends ServiceSupport implements RoutePolicyFact
                 .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
                 .start();
             sd.pre(span, exchange, route.getEndpoint());
-            spanManager.manage(span);
+            spanManager.activate(span);
             if (LOG.isTraceEnabled()) {
                 LOG.trace("OpenTracing: start server span=" + span);
             }
@@ -225,7 +225,7 @@ public class OpenTracingTracer extends ServiceSupport implements RoutePolicyFact
             SpanDecorator sd = getSpanDecorator(route.getEndpoint());
             sd.post(managedSpan.getSpan(), exchange, route.getEndpoint());
             managedSpan.getSpan().finish();
-            managedSpan.release();
+            managedSpan.deactivate();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/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
index bccfade..bc16f42 100644
--- 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
@@ -18,15 +18,71 @@ package org.apache.camel.opentracing.decorators;
 
 import io.opentracing.Span;
 import io.opentracing.tag.Tags;
+
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 
 public abstract class AbstractHttpSpanDecorator extends AbstractSpanDecorator {
 
+    public static final String POST_METHOD = "POST";
+    public static final String GET_METHOD = "GET";
+
+    @Override
+    public String getOperationName(Exchange exchange, Endpoint endpoint) {
+        // Based on HTTP component documentation:
+
+        // 1. Use method provided in header.
+        Object method = exchange.getIn().getHeader(Exchange.HTTP_METHOD);
+        if (method instanceof String) {
+            return (String)method;
+        }
+
+        // 2. GET if query string is provided in header.
+        if (exchange.getIn().getHeader(Exchange.HTTP_QUERY) != null) {
+            return GET_METHOD;
+        }
+
+        // 3. GET if endpoint is configured with a query string.
+        if (endpoint.getEndpointUri().indexOf('?') != -1) {
+            return GET_METHOD;
+        }
+
+        // 4. POST if there is data to send (body is not null).
+        if (exchange.getIn().getBody() != null) {
+            return POST_METHOD;
+        }
+
+        // 5. GET otherwise.
+        return GET_METHOD;
+    }
+
     @Override
     public void pre(Span span, Exchange exchange, Endpoint endpoint) {
         super.pre(span, exchange, endpoint);
-        span.setTag(Tags.HTTP_URL.getKey(), endpoint.getEndpointUri());
+
+        String httpUrl = getHttpURL(exchange, endpoint);
+        if (httpUrl != null) {
+            span.setTag(Tags.HTTP_URL.getKey(), httpUrl);
+        }
+    }
+
+    protected String getHttpURL(Exchange exchange, Endpoint endpoint) {
+        Object url = exchange.getIn().getHeader(Exchange.HTTP_URL);
+        if (url instanceof String) {
+            return (String) url;
+        } else {
+            Object uri = exchange.getIn().getHeader(Exchange.HTTP_URI);
+            if (uri instanceof String) {
+                return (String) uri;
+            } else {
+                // Try to obtain from endpoint
+                int index = endpoint.getEndpointUri().lastIndexOf("http:");
+                if (index != -1) {
+                    return endpoint.getEndpointUri().substring(index);
+                }
+            }
+        }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AhcSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AhcSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AhcSpanDecorator.java
new file mode 100644
index 0000000..170a3df
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/AhcSpanDecorator.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing.decorators;
+
+public class AhcSpanDecorator extends AbstractHttpSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "ahc";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/Http4SpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/Http4SpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/Http4SpanDecorator.java
new file mode 100644
index 0000000..68e0932
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/Http4SpanDecorator.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing.decorators;
+
+public class Http4SpanDecorator extends AbstractHttpSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "http4";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/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
index 43eec8a..489d2c3 100644
--- 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
@@ -16,11 +16,6 @@
  */
 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
@@ -28,9 +23,4 @@ public class HttpSpanDecorator extends AbstractHttpSpanDecorator {
         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/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/JdbcSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/JdbcSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/JdbcSpanDecorator.java
new file mode 100644
index 0000000..44cded4
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/JdbcSpanDecorator.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.decorators;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+import io.opentracing.Span;
+
+public class JdbcSpanDecorator extends AbstractSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "jdbc";
+    }
+
+    @Override
+    public void pre(Span span, Exchange exchange, Endpoint endpoint) {
+        super.pre(span, exchange, endpoint);
+
+        span.setTag("db.type", "sql");
+
+        Object body = exchange.getIn().getBody();
+        if (body instanceof String) {
+            span.setTag("db.statement", (String)body);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/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
index f16669b..94e279d 100644
--- 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
@@ -16,11 +16,6 @@
  */
 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
@@ -28,9 +23,4 @@ public class JettySpanDecorator extends AbstractHttpSpanDecorator {
         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/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/MongoDBSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/MongoDBSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/MongoDBSpanDecorator.java
new file mode 100644
index 0000000..0237535
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/MongoDBSpanDecorator.java
@@ -0,0 +1,74 @@
+/**
+ * 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.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+import io.opentracing.Span;
+
+public class MongoDBSpanDecorator extends AbstractSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "mongodb";
+    }
+
+    @Override
+    public String getOperationName(Exchange exchange, Endpoint endpoint) {
+        Map<String,String> queryParameters = toQueryParameters(endpoint.getEndpointUri());
+        String opName = queryParameters.get("operation");
+        if (opName != null) {
+            return opName;
+        }
+        return super.getOperationName(exchange, endpoint);
+    }
+
+    @Override
+    public void pre(Span span, Exchange exchange, Endpoint endpoint) {
+        super.pre(span, exchange, endpoint);
+
+        span.setTag("db.type", getComponent());
+
+        Map<String,String> queryParameters = toQueryParameters(endpoint.getEndpointUri());
+        String database = queryParameters.get("database");
+        if (database != null) {
+            span.setTag("db.instance", database);
+        }
+        span.setTag("db.statement", queryParameters.toString());
+    }
+
+    public static Map<String,String> toQueryParameters(String uri) {
+        int index = uri.indexOf('?');
+        if (index != -1) {
+            String queryString = uri.substring(index + 1);
+            Map<String,String> map = new HashMap<>();
+            for (String param : queryString.split("&")) {
+                String[] parts = param.split("=");
+                if (parts.length == 2) {
+                    map.put(parts[0], parts[1]);
+                }
+            }
+            return map;
+        }
+        return Collections.emptyMap();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NettyHttp4SpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NettyHttp4SpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NettyHttp4SpanDecorator.java
new file mode 100644
index 0000000..3548d29
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NettyHttp4SpanDecorator.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing.decorators;
+
+public class NettyHttp4SpanDecorator extends AbstractHttpSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "netty-http4";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NettyHttpSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NettyHttpSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NettyHttpSpanDecorator.java
new file mode 100644
index 0000000..25c632a
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/NettyHttpSpanDecorator.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing.decorators;
+
+public class NettyHttpSpanDecorator extends AbstractHttpSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "netty-http";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/RestletSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/RestletSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/RestletSpanDecorator.java
new file mode 100644
index 0000000..ac83542
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/RestletSpanDecorator.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing.decorators;
+
+public class RestletSpanDecorator extends AbstractHttpSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "restlet";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/ServletSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/ServletSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/ServletSpanDecorator.java
new file mode 100644
index 0000000..5adb0ae
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/ServletSpanDecorator.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing.decorators;
+
+public class ServletSpanDecorator extends AbstractHttpSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "servlet";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/SqlSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/SqlSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/SqlSpanDecorator.java
new file mode 100644
index 0000000..c814994
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/SqlSpanDecorator.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;
+
+public class SqlSpanDecorator extends AbstractSpanDecorator {
+
+    public static final String CAMEL_SQL_QUERY = "CamelSqlQuery";
+
+    @Override
+    public String getComponent() {
+        return "sql";
+    }
+
+    @Override
+    public void pre(Span span, Exchange exchange, Endpoint endpoint) {
+        super.pre(span, exchange, endpoint);
+
+        span.setTag("db.type", "sql");
+
+        Object sqlquery = exchange.getIn().getHeader(CAMEL_SQL_QUERY);
+        if (sqlquery instanceof String) {
+            span.setTag("db.statement", (String) sqlquery);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/TimerSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/TimerSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/TimerSpanDecorator.java
new file mode 100644
index 0000000..b7a7fd4
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/TimerSpanDecorator.java
@@ -0,0 +1,39 @@
+/**
+ * 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;
+
+public class TimerSpanDecorator extends AbstractSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "timer";
+    }
+
+    @Override
+    public String getOperationName(Exchange exchange, Endpoint endpoint) {
+        Object name = exchange.getProperty(Exchange.TIMER_NAME);
+        if (name instanceof String) {
+            return (String)name;
+        }
+
+        return super.getOperationName(exchange, endpoint);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/UndertowSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/UndertowSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/UndertowSpanDecorator.java
new file mode 100644
index 0000000..9e8a1ae
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/UndertowSpanDecorator.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing.decorators;
+
+public class UndertowSpanDecorator extends AbstractHttpSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "undertow";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/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
index 2898102..452aaa2 100644
--- 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
@@ -15,5 +15,16 @@
 # limitations under the License.
 #
 
+org.apache.camel.opentracing.decorators.AhcSpanDecorator
+org.apache.camel.opentracing.decorators.Http4SpanDecorator
 org.apache.camel.opentracing.decorators.HttpSpanDecorator
+org.apache.camel.opentracing.decorators.JdbcSpanDecorator
 org.apache.camel.opentracing.decorators.JettySpanDecorator
+org.apache.camel.opentracing.decorators.MongoDBSpanDecorator
+org.apache.camel.opentracing.decorators.NettyHttp4SpanDecorator
+org.apache.camel.opentracing.decorators.NettyHttpSpanDecorator
+org.apache.camel.opentracing.decorators.RestletSpanDecorator
+org.apache.camel.opentracing.decorators.ServletSpanDecorator
+org.apache.camel.opentracing.decorators.SqlSpanDecorator
+org.apache.camel.opentracing.decorators.TimerSpanDecorator
+org.apache.camel.opentracing.decorators.UndertowSpanDecorator

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/AbstractHttpSpanDecoratorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/AbstractHttpSpanDecoratorTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/AbstractHttpSpanDecoratorTest.java
new file mode 100644
index 0000000..8c16e76
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/AbstractHttpSpanDecoratorTest.java
@@ -0,0 +1,267 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import java.net.URI;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.opentracing.SpanDecorator;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.tag.Tags;
+
+public class AbstractHttpSpanDecoratorTest {
+
+    private static final String TEST_URI = "http://localhost:8080/test";
+
+    @Test
+    public void testGetOperationNameFromMethodHeader() {
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(Exchange.HTTP_METHOD)).thenReturn("PUT");
+
+        SpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals("PUT", decorator.getOperationName(exchange, null));
+    }
+
+    @Test
+    public void testGetOperationNameQueryStringHeader() {
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(Exchange.HTTP_QUERY)).thenReturn("MyQuery");
+
+        SpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals(AbstractHttpSpanDecorator.GET_METHOD,
+                decorator.getOperationName(exchange, null));
+    }
+
+    @Test
+    public void testGetOperationNameQueryStringInEndpoint() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn("http://localhost:8080/endpoint?query=hello");
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(Exchange.HTTP_URI)).thenReturn("http://localhost:8080/endpoint?query=hello");
+
+        SpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals(AbstractHttpSpanDecorator.GET_METHOD,
+                decorator.getOperationName(exchange, endpoint));
+    }
+
+    @Test
+    public void testGetOperationNameBodyNotNull() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(Exchange.HTTP_URI)).thenReturn(TEST_URI);
+        Mockito.when(message.getBody()).thenReturn("Message Body");
+
+        SpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals(AbstractHttpSpanDecorator.POST_METHOD,
+                decorator.getOperationName(exchange, endpoint));
+    }
+
+    @Test
+    public void testGetOperationNameDefault() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(Exchange.HTTP_URI)).thenReturn(TEST_URI);
+
+        SpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals(AbstractHttpSpanDecorator.GET_METHOD,
+                decorator.getOperationName(exchange, endpoint));
+    }
+
+    @Test
+    public void testPreUri() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(Exchange.HTTP_URI)).thenReturn(TEST_URI);
+
+        SpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        MockTracer tracer = new MockTracer();
+        MockSpan span = (MockSpan)tracer.buildSpan("TestSpan").start();
+
+        decorator.pre(span, exchange, endpoint);
+
+        assertEquals(TEST_URI, span.tags().get(Tags.HTTP_URL.getKey()));
+    }
+
+    @Test
+    public void testGetHttpURLFromHeaderUrl() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(Exchange.HTTP_URI)).thenReturn("Another URL");
+        Mockito.when(message.getHeader(Exchange.HTTP_URL)).thenReturn(TEST_URI);
+
+        AbstractHttpSpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals(TEST_URI, decorator.getHttpURL(exchange, endpoint));
+    }
+
+    @Test
+    public void testGetHttpURLFromHeaderUri() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(Exchange.HTTP_URI)).thenReturn(TEST_URI);
+
+        AbstractHttpSpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals(TEST_URI, decorator.getHttpURL(exchange, endpoint));
+    }
+
+    @Test
+    public void testGetHttpURLFromEndpointUri() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
+        Mockito.when(exchange.getIn()).thenReturn(message);
+
+        AbstractHttpSpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals(TEST_URI, decorator.getHttpURL(exchange, endpoint));
+    }
+
+    @Test
+    public void testGetHttpURLFromEndpointUriWithAdditionalScheme() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn("netty-http:" + TEST_URI);
+        Mockito.when(exchange.getIn()).thenReturn(message);
+
+        AbstractHttpSpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals(TEST_URI, decorator.getHttpURL(exchange, endpoint));
+    }
+
+    @Test
+    public void testPostResponseCode() {
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(exchange.hasOut()).thenReturn(true);
+        Mockito.when(exchange.getOut()).thenReturn(message);
+        Mockito.when(message.getHeader(Exchange.HTTP_RESPONSE_CODE)).thenReturn(200);
+        
+        SpanDecorator decorator = new AbstractHttpSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        MockTracer tracer = new MockTracer();
+        MockSpan span = (MockSpan)tracer.buildSpan("TestSpan").start();
+
+        decorator.post(span, exchange, null);
+
+        assertEquals(200, span.tags().get(Tags.HTTP_STATUS.getKey()));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/AbstractSpanDecoratorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/AbstractSpanDecoratorTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/AbstractSpanDecoratorTest.java
new file mode 100644
index 0000000..b59aa30
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/AbstractSpanDecoratorTest.java
@@ -0,0 +1,100 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.opentracing.SpanDecorator;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.tag.Tags;
+
+public class AbstractSpanDecoratorTest {
+
+    private static final String TEST_URI = "test:/uri";
+
+    @Test
+    public void testGetOperationName() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
+
+        SpanDecorator decorator = new AbstractSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals(TEST_URI, decorator.getOperationName(null, endpoint));
+    }
+
+    @Test
+    public void testPre() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn(TEST_URI);
+
+        SpanDecorator decorator = new AbstractSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        MockTracer tracer = new MockTracer();
+        MockSpan span = (MockSpan)tracer.buildSpan("TestSpan").start();
+
+        decorator.pre(span, null, endpoint);
+
+        assertEquals("camel-test", span.tags().get(Tags.COMPONENT.getKey()));
+    }
+
+    @Test
+    public void testPostExchangeFailed() {
+        Exchange exchange = Mockito.mock(Exchange.class);
+
+        Mockito.when(exchange.isFailed()).thenReturn(true);
+        
+        Exception e=new Exception("Test Message");
+        Mockito.when(exchange.getException()).thenReturn(e);
+
+        SpanDecorator decorator = new AbstractSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        MockTracer tracer = new MockTracer();
+        MockSpan span = (MockSpan)tracer.buildSpan("TestSpan").start();
+
+        decorator.post(span, exchange, null);
+
+        assertEquals(true, span.tags().get(Tags.ERROR.getKey()));
+        assertEquals(1, span.logEntries().size());
+        assertEquals("error", span.logEntries().get(0).fields().get("event"));
+        assertEquals("Exception", span.logEntries().get(0).fields().get("error.kind"));
+        assertEquals(e.getMessage(), span.logEntries().get(0).fields().get("message"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/JdbcSpanDecoratorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/JdbcSpanDecoratorTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/JdbcSpanDecoratorTest.java
new file mode 100644
index 0000000..ce24aaf
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/JdbcSpanDecoratorTest.java
@@ -0,0 +1,56 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.opentracing.SpanDecorator;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockTracer;
+
+public class JdbcSpanDecoratorTest {
+
+    private static final String SQL_STATEMENT = "select * from customer";
+
+    @Test
+    public void testPre() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn("test");
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getBody()).thenReturn(SQL_STATEMENT);
+
+        SpanDecorator decorator = new JdbcSpanDecorator();
+
+        MockTracer tracer = new MockTracer();
+        MockSpan span = (MockSpan)tracer.buildSpan("TestSpan").start();
+
+        decorator.pre(span, exchange, endpoint);
+
+        assertEquals("sql", span.tags().get("db.type"));
+        assertEquals(SQL_STATEMENT, span.tags().get("db.statement"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/MongoDBSpanDecoratorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/MongoDBSpanDecoratorTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/MongoDBSpanDecoratorTest.java
new file mode 100644
index 0000000..908560f
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/MongoDBSpanDecoratorTest.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing.decorators;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.opentracing.SpanDecorator;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockTracer;
+
+public class MongoDBSpanDecoratorTest {
+
+    private static final String MONGODB_STATEMENT =
+            "mongodb:myDb?database=flights&collection=tickets&operation=findOneByQuery";
+
+    @Test
+    public void testGetOperationName() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn(
+                MONGODB_STATEMENT);
+
+        SpanDecorator decorator = new MongoDBSpanDecorator();
+
+        assertEquals("findOneByQuery", decorator.getOperationName(null, endpoint));
+    }
+
+    @Test
+    public void testToQueryParameters() {
+        Map<String,String> params = MongoDBSpanDecorator.toQueryParameters(MONGODB_STATEMENT);
+        assertEquals(3, params.size());
+        assertEquals("flights", params.get("database"));
+        assertEquals("tickets", params.get("collection"));
+        assertEquals("findOneByQuery", params.get("operation"));
+    }
+
+    @Test
+    public void testPre() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn(
+                MONGODB_STATEMENT);
+
+        SpanDecorator decorator = new MongoDBSpanDecorator();
+
+        MockTracer tracer = new MockTracer();
+        MockSpan span = (MockSpan)tracer.buildSpan("TestSpan").start();
+
+        decorator.pre(span, null, endpoint);
+
+        assertEquals("mongodb", span.tags().get("db.type"));
+        assertEquals("flights", span.tags().get("db.instance"));
+        assertTrue(span.tags().containsKey("db.statement"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/SqlSpanDecoratorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/SqlSpanDecoratorTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/SqlSpanDecoratorTest.java
new file mode 100644
index 0000000..f9d3987
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/SqlSpanDecoratorTest.java
@@ -0,0 +1,56 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.opentracing.SpanDecorator;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockTracer;
+
+public class SqlSpanDecoratorTest {
+
+    private static final String SQL_STATEMENT = "select * from customer";
+
+    @Test
+    public void testPre() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn("test");
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(SqlSpanDecorator.CAMEL_SQL_QUERY)).thenReturn(SQL_STATEMENT);
+
+        SpanDecorator decorator = new SqlSpanDecorator();
+
+        MockTracer tracer = new MockTracer();
+        MockSpan span = (MockSpan)tracer.buildSpan("TestSpan").start();
+
+        decorator.pre(span, exchange, endpoint);
+
+        assertEquals("sql", span.tags().get("db.type"));
+        assertEquals(SQL_STATEMENT, span.tags().get("db.statement"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/TimerSpanDecoratorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/TimerSpanDecoratorTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/TimerSpanDecoratorTest.java
new file mode 100644
index 0000000..c5abdd0
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/TimerSpanDecoratorTest.java
@@ -0,0 +1,46 @@
+/**
+ * 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 static org.junit.Assert.*;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.opentracing.SpanDecorator;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class TimerSpanDecoratorTest {
+
+    private static final String TEST_NAME = "TestName";
+
+    @Test
+    public void testGetOperationName() {
+        Exchange exchange = Mockito.mock(Exchange.class);
+
+        Mockito.when(exchange.getProperty(Exchange.TIMER_NAME)).thenReturn(TEST_NAME);
+
+        SpanDecorator decorator = new TimerSpanDecorator() {
+            @Override
+            public String getComponent() {
+                return null;
+            }
+        };
+
+        assertEquals(TEST_NAME, decorator.getOperationName(exchange, null));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/84b21a8a/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 82b5536..3001de0 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -485,7 +485,7 @@
     <openstack4j-version>3.0.2</openstack4j-version>
     <openstack4j-guava-version>17.0</openstack4j-guava-version>
     <opentracing-java-globaltracer-version>0.1.0</opentracing-java-globaltracer-version>
-    <opentracing-java-spanmanager-version>0.0.2</opentracing-java-spanmanager-version>
+    <opentracing-java-spanmanager-version>0.0.3</opentracing-java-spanmanager-version>
     <opentracing-version>0.20.9</opentracing-version>
     <ops4j-base-version>1.5.0</ops4j-base-version>
     <optaplanner-version>6.5.0.Final</optaplanner-version>


Mime
View raw message