camel git commit: Add OpenTracing span decorators for cassandra (cql), direct-vm, disruptor[-vm], elasticsearch and stomp

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

camel git commit: Add OpenTracing span decorators for cassandra (cql), direct-vm, disruptor[-vm], elasticsearch and stomp

davsclaus-2
Repository: camel
Updated Branches:
  refs/heads/master 8cd032925 -> d73644159


Add OpenTracing span decorators for cassandra (cql), direct-vm, disruptor[-vm], elasticsearch and stomp


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

Branch: refs/heads/master
Commit: d7364415942cd55b224048888246229902d7990e
Parents: 8cd0329
Author: Gary Brown <[hidden email]>
Authored: Tue Mar 14 15:33:59 2017 +0000
Committer: Claus Ibsen <[hidden email]>
Committed: Tue Mar 14 18:38:56 2017 +0100

----------------------------------------------------------------------
 .../decorators/CqlSpanDecorator.java            | 62 +++++++++++++++
 .../decorators/DirectvmSpanDecorator.java       | 26 ++++++
 .../decorators/DisruptorSpanDecorator.java      | 26 ++++++
 .../decorators/DisruptorvmSpanDecorator.java    | 26 ++++++
 .../decorators/ElasticsearchSpanDecorator.java  | 62 +++++++++++++++
 .../decorators/StompSpanDecorator.java          | 40 ++++++++++
 .../org.apache.camel.opentracing.SpanDecorator  |  6 ++
 .../decorators/CqlSpanDecoratorTest.java        | 84 ++++++++++++++++++++
 .../ElasticsearchSpanDecoratorTest.java         | 72 +++++++++++++++++
 .../decorators/StompSpanDecoratorTest.java      | 38 +++++++++
 10 files changed, 442 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d7364415/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/CqlSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/CqlSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/CqlSpanDecorator.java
new file mode 100644
index 0000000..28cc48d
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/CqlSpanDecorator.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.decorators;
+
+import java.net.URI;
+import java.util.Map;
+
+import io.opentracing.Span;
+import io.opentracing.tag.Tags;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+public class CqlSpanDecorator extends AbstractSpanDecorator {
+
+    public static final String CASSANDRA_DB_TYPE = "cassandra";
+
+    protected static final String CAMEL_CQL_QUERY = "CamelCqlQuery";
+
+    @Override
+    public String getComponent() {
+        return "cql";
+    }
+
+    @Override
+    public void pre(Span span, Exchange exchange, Endpoint endpoint) {
+        super.pre(span, exchange, endpoint);
+
+        span.setTag(Tags.DB_TYPE.getKey(), CASSANDRA_DB_TYPE);
+
+        URI uri = URI.create(endpoint.getEndpointUri());
+        if (uri.getPath() != null && uri.getPath().length() > 0) {
+            // Strip leading '/' from path
+            span.setTag(Tags.DB_INSTANCE.getKey(), uri.getPath().substring(1));
+        }
+
+        Object cql = exchange.getIn().getHeader(CAMEL_CQL_QUERY);
+        if (cql != null) {
+            span.setTag(Tags.DB_STATEMENT.getKey(), cql.toString());
+        } else {
+            Map<String, String> queryParameters = toQueryParameters(endpoint.getEndpointUri());
+            if (queryParameters.containsKey("cql")) {
+                span.setTag(Tags.DB_STATEMENT.getKey(), queryParameters.get("cql"));
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d7364415/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DirectvmSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DirectvmSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DirectvmSpanDecorator.java
new file mode 100644
index 0000000..bb3c8e6
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DirectvmSpanDecorator.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 DirectvmSpanDecorator extends AbstractInternalSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "direct-vm";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d7364415/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DisruptorSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DisruptorSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DisruptorSpanDecorator.java
new file mode 100644
index 0000000..2d431bd
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DisruptorSpanDecorator.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 DisruptorSpanDecorator extends AbstractInternalSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "disruptor";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d7364415/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DisruptorvmSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DisruptorvmSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DisruptorvmSpanDecorator.java
new file mode 100644
index 0000000..7d79786
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/DisruptorvmSpanDecorator.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 DisruptorvmSpanDecorator extends AbstractInternalSpanDecorator {
+
+    @Override
+    public String getComponent() {
+        return "disruptor-vm";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d7364415/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/ElasticsearchSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/ElasticsearchSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/ElasticsearchSpanDecorator.java
new file mode 100644
index 0000000..ee8f72d
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/ElasticsearchSpanDecorator.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.decorators;
+
+import java.util.Map;
+
+import io.opentracing.Span;
+import io.opentracing.tag.Tags;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+public class ElasticsearchSpanDecorator extends AbstractSpanDecorator {
+
+    public static final String ELASTICSEARCH_DB_TYPE = "elasticsearch";
+
+    public static final String ELASTICSEARCH_CLUSTER_TAG = "elasticsearch.cluster";
+
+    @Override
+    public String getComponent() {
+        return "elasticsearch";
+    }
+
+    @Override
+    public String getOperationName(Exchange exchange, Endpoint endpoint) {
+        Map<String, String> queryParameters = toQueryParameters(endpoint.getEndpointUri());
+        return queryParameters.containsKey("operation") ? queryParameters.get("operation")
+                : super.getOperationName(exchange, endpoint);
+    }
+
+    @Override
+    public void pre(Span span, Exchange exchange, Endpoint endpoint) {
+        super.pre(span, exchange, endpoint);
+
+        span.setTag(Tags.DB_TYPE.getKey(), ELASTICSEARCH_DB_TYPE);
+
+        Map<String, String> queryParameters = toQueryParameters(endpoint.getEndpointUri());
+        if (queryParameters.containsKey("indexName")) {
+            span.setTag(Tags.DB_INSTANCE.getKey(), queryParameters.get("indexName"));
+        }
+
+        String cluster = stripSchemeAndOptions(endpoint);
+        if (cluster != null) {
+            span.setTag(ELASTICSEARCH_CLUSTER_TAG, cluster);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d7364415/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/StompSpanDecorator.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/StompSpanDecorator.java b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/StompSpanDecorator.java
new file mode 100644
index 0000000..c152fac
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/decorators/StompSpanDecorator.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.decorators;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+public class StompSpanDecorator extends AbstractMessagingSpanDecorator {
+
+    protected static final String QUEUE_PREFIX = "queue:";
+
+    @Override
+    public String getComponent() {
+        return "stomp";
+    }
+
+    @Override
+    public String getDestination(Exchange exchange, Endpoint endpoint) {
+        String destination = super.getDestination(exchange, endpoint);
+        if (destination.startsWith(QUEUE_PREFIX)) {
+            destination = destination.substring(QUEUE_PREFIX.length());
+        }
+        return destination;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d7364415/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 68af6ca..36c2805 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
@@ -21,7 +21,12 @@ org.apache.camel.opentracing.decorators.AwsSqsSpanDecorator
 org.apache.camel.opentracing.decorators.AwsSnsSpanDecorator
 org.apache.camel.opentracing.decorators.CometdSpanDecorator
 org.apache.camel.opentracing.decorators.CometdsSpanDecorator
+org.apache.camel.opentracing.decorators.CqlSpanDecorator
 org.apache.camel.opentracing.decorators.DirectSpanDecorator
+org.apache.camel.opentracing.decorators.DirectvmSpanDecorator
+org.apache.camel.opentracing.decorators.DisruptorSpanDecorator
+org.apache.camel.opentracing.decorators.DisruptorvmSpanDecorator
+org.apache.camel.opentracing.decorators.ElasticsearchSpanDecorator
 org.apache.camel.opentracing.decorators.Http4SpanDecorator
 org.apache.camel.opentracing.decorators.HttpSpanDecorator
 org.apache.camel.opentracing.decorators.IronmqSpanDecorator
@@ -40,6 +45,7 @@ org.apache.camel.opentracing.decorators.SedaSpanDecorator
 org.apache.camel.opentracing.decorators.ServletSpanDecorator
 org.apache.camel.opentracing.decorators.SjmsSpanDecorator
 org.apache.camel.opentracing.decorators.SqlSpanDecorator
+org.apache.camel.opentracing.decorators.StompSpanDecorator
 org.apache.camel.opentracing.decorators.TimerSpanDecorator
 org.apache.camel.opentracing.decorators.UndertowSpanDecorator
 org.apache.camel.opentracing.decorators.VmSpanDecorator

http://git-wip-us.apache.org/repos/asf/camel/blob/d7364415/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/CqlSpanDecoratorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/CqlSpanDecoratorTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/CqlSpanDecoratorTest.java
new file mode 100644
index 0000000..bfe904f
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/CqlSpanDecoratorTest.java
@@ -0,0 +1,84 @@
+/**
+ * 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 io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.tag.Tags;
+
+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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class CqlSpanDecoratorTest {
+
+    @Test
+    public void testPreCqlFromUri() {
+        String cql = "select%20*%20from%20users";
+        String keyspace = "test";
+
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn("cql://host1,host2:8080/" + keyspace + "?cql="
+                + cql + "&consistencyLevel=quorum");
+        Mockito.when(exchange.getIn()).thenReturn(message);
+
+        SpanDecorator decorator = new CqlSpanDecorator();
+
+        MockTracer tracer = new MockTracer();
+        MockSpan span = (MockSpan)tracer.buildSpan("TestSpan").start();
+
+        decorator.pre(span, exchange, endpoint);
+
+        assertEquals(CqlSpanDecorator.CASSANDRA_DB_TYPE, span.tags().get(Tags.DB_TYPE.getKey()));
+        assertEquals(cql, span.tags().get(Tags.DB_STATEMENT.getKey()));
+        assertEquals(keyspace, span.tags().get(Tags.DB_INSTANCE.getKey()));
+    }
+
+    @Test
+    public void testPreCqlFromHeader() {
+        String cql = "select * from users";
+
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn("cql://host1,host2?consistencyLevel=quorum");
+        Mockito.when(exchange.getIn()).thenReturn(message);
+        Mockito.when(message.getHeader(CqlSpanDecorator.CAMEL_CQL_QUERY)).thenReturn(cql);
+
+        SpanDecorator decorator = new CqlSpanDecorator();
+
+        MockTracer tracer = new MockTracer();
+        MockSpan span = (MockSpan)tracer.buildSpan("TestSpan").start();
+
+        decorator.pre(span, exchange, endpoint);
+
+        assertEquals(CqlSpanDecorator.CASSANDRA_DB_TYPE, span.tags().get(Tags.DB_TYPE.getKey()));
+        assertEquals(cql, span.tags().get(Tags.DB_STATEMENT.getKey()));
+        assertNull(span.tags().get(Tags.DB_INSTANCE.getKey()));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d7364415/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/ElasticsearchSpanDecoratorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/ElasticsearchSpanDecoratorTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/ElasticsearchSpanDecoratorTest.java
new file mode 100644
index 0000000..9847b2d
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/ElasticsearchSpanDecoratorTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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 io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.tag.Tags;
+
+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 static org.junit.Assert.assertEquals;
+
+public class ElasticsearchSpanDecoratorTest {
+
+    @Test
+    public void testOperationName() {
+        String opName = "INDEX";
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn("elasticsearch://local?operation="
+                + opName + "&indexName=twitter&indexType=tweet");
+
+        SpanDecorator decorator = new ElasticsearchSpanDecorator();
+
+        assertEquals(opName, decorator.getOperationName(null, endpoint));
+    }
+
+    @Test
+    public void testPre() {
+        String indexName = "twitter";
+        String cluster = "local";
+
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+        Exchange exchange = Mockito.mock(Exchange.class);
+        Message message = Mockito.mock(Message.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn("elasticsearch://" + cluster
+                + "?operation=INDEX&indexName=" + indexName + "&indexType=tweet");
+        Mockito.when(exchange.getIn()).thenReturn(message);
+
+        SpanDecorator decorator = new ElasticsearchSpanDecorator();
+
+        MockTracer tracer = new MockTracer();
+        MockSpan span = tracer.buildSpan("TestSpan").start();
+
+        decorator.pre(span, exchange, endpoint);
+
+        assertEquals(ElasticsearchSpanDecorator.ELASTICSEARCH_DB_TYPE, span.tags().get(Tags.DB_TYPE.getKey()));
+        assertEquals(indexName, span.tags().get(Tags.DB_INSTANCE.getKey()));
+        assertEquals(cluster, span.tags().get(ElasticsearchSpanDecorator.ELASTICSEARCH_CLUSTER_TAG));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d7364415/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/StompSpanDecoratorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/StompSpanDecoratorTest.java b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/StompSpanDecoratorTest.java
new file mode 100644
index 0000000..5535ea7
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/decorators/StompSpanDecoratorTest.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.opentracing.decorators;
+
+import org.apache.camel.Endpoint;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import static org.junit.Assert.assertEquals;
+
+public class StompSpanDecoratorTest {
+
+    @Test
+    public void testGetDestination() {
+        Endpoint endpoint = Mockito.mock(Endpoint.class);
+
+        Mockito.when(endpoint.getEndpointUri()).thenReturn("stomp:queue:test");
+
+        StompSpanDecorator decorator = new StompSpanDecorator();
+
+        assertEquals("test", decorator.getDestination(null, endpoint));
+    }
+
+}