camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: Instrument OpenTracing example service2 using the JavaAgent. Fix issue with baggage propagating Camel prefixed headers, causing outbound component to throw exception. Added agent rule test.
Date Mon, 20 Mar 2017 13:10:25 GMT
Instrument OpenTracing example service2 using the JavaAgent.
Fix issue with baggage propagating Camel prefixed headers, causing outbound component to throw
exception.
Added agent rule test.


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

Branch: refs/heads/master
Commit: 1ead8dfc47464031f3de7e6e794e1798080fa13d
Parents: 61e5086
Author: Gary Brown <gary@brownuk.com>
Authored: Tue Mar 7 08:09:39 2017 +0000
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Mar 20 14:10:14 2017 +0100

----------------------------------------------------------------------
 components/camel-opentracing/pom.xml            |  75 ++++++++++++++
 .../opentracing/CamelHeadersExtractAdapter.java |  43 --------
 .../opentracing/CamelHeadersInjectAdapter.java  |  40 --------
 .../camel/opentracing/OpenTracingTracer.java    |   2 +
 .../propagation/CamelHeadersExtractAdapter.java |  43 ++++++++
 .../propagation/CamelHeadersInjectAdapter.java  |  43 ++++++++
 .../src/main/resources/otagent/apache-camel.btm |  16 +++
 .../agent/InstallOpenTracingTracerRuleTest.java |  98 ++++++++++++++++++
 examples/camel-example-opentracing/README.md    |   8 +-
 .../camel-example-opentracing/service2/pom.xml  | 101 +++++++++++++------
 .../main/java/sample/camel/Service2Route.java   |   3 -
 parent/pom.xml                                  |   1 +
 12 files changed, 355 insertions(+), 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1ead8dfc/components/camel-opentracing/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/pom.xml b/components/camel-opentracing/pom.xml
index 384a01f..77c26f9 100644
--- a/components/camel-opentracing/pom.xml
+++ b/components/camel-opentracing/pom.xml
@@ -38,6 +38,8 @@
     <title>OpenTracing</title>
 
     <camel.osgi.export.pkg>org.apache.camel.opentracing.*</camel.osgi.export.pkg>
+
+    <opentracing-agent.lib>${project.build.directory}/lib</opentracing-agent.lib>
   </properties>
 
   <dependencies>
@@ -66,6 +68,12 @@
 
     <!-- test dependencies -->
     <dependency>
+      <groupId>io.opentracing.contrib</groupId>
+      <artifactId>opentracing-agent</artifactId>
+      <scope>test</scope>
+      <version>${opentracing-java-agent-version}</version>
+    </dependency>
+    <dependency>
       <groupId>io.opentracing</groupId>
       <artifactId>opentracing-mock</artifactId>
       <version>${opentracing-version}</version>
@@ -99,4 +107,71 @@
 
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>**/agent/*Test.java</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>get-agent</id>
+            <phase>pre-integration-test</phase>
+            <goals>
+              <goal>copy</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>io.opentracing.contrib</groupId>
+                  <artifactId>opentracing-agent</artifactId>
+                  <overWrite>true</overWrite>
+                  <outputDirectory>${opentracing-agent.lib}</outputDirectory>
+                  <destFileName>opentracing-agent.jar</destFileName>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-failsafe-plugin</artifactId>
+        <configuration>
+          <argLine>
+            -javaagent:${opentracing-agent.lib}/opentracing-agent.jar
+            -Dorg.jboss.byteman.verbose
+          </argLine>
+        </configuration>
+        <executions>
+          <execution>
+            <id>run-integration-tests</id>
+            <goals>
+              <goal>integration-test</goal>
+            </goals>
+            <configuration>
+              <includes>
+                <include>**/agent/*Test.java</include>
+              </includes>
+            </configuration>
+          </execution>
+          <execution>
+            <id>final-verify</id>
+            <goals>
+              <goal>verify</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/1ead8dfc/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
deleted file mode 100644
index c0a8ff0..0000000
--- a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/CamelHeadersExtractAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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/1ead8dfc/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
deleted file mode 100644
index 1370168..0000000
--- a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/CamelHeadersInjectAdapter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-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/1ead8dfc/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 9f45aa2..e662d24 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
@@ -41,6 +41,8 @@ import org.apache.camel.api.management.ManagedResource;
 import org.apache.camel.management.event.ExchangeSendingEvent;
 import org.apache.camel.management.event.ExchangeSentEvent;
 import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.opentracing.propagation.CamelHeadersExtractAdapter;
+import org.apache.camel.opentracing.propagation.CamelHeadersInjectAdapter;
 import org.apache.camel.spi.RoutePolicy;
 import org.apache.camel.spi.RoutePolicyFactory;
 import org.apache.camel.support.EventNotifierSupport;

http://git-wip-us.apache.org/repos/asf/camel/blob/1ead8dfc/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/propagation/CamelHeadersExtractAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/propagation/CamelHeadersExtractAdapter.java
b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/propagation/CamelHeadersExtractAdapter.java
new file mode 100644
index 0000000..a316a97
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/propagation/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.propagation;
+
+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/1ead8dfc/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/propagation/CamelHeadersInjectAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/propagation/CamelHeadersInjectAdapter.java
b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/propagation/CamelHeadersInjectAdapter.java
new file mode 100644
index 0000000..1741c6b
--- /dev/null
+++ b/components/camel-opentracing/src/main/java/org/apache/camel/opentracing/propagation/CamelHeadersInjectAdapter.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.propagation;
+
+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) {
+        // Assume any header property that begins with 'Camel' is for internal use
+        if (!key.startsWith("Camel")) {
+            this.map.put(key, value);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/1ead8dfc/components/camel-opentracing/src/main/resources/otagent/apache-camel.btm
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/main/resources/otagent/apache-camel.btm b/components/camel-opentracing/src/main/resources/otagent/apache-camel.btm
new file mode 100644
index 0000000..1ae76fe
--- /dev/null
+++ b/components/camel-opentracing/src/main/resources/otagent/apache-camel.btm
@@ -0,0 +1,16 @@
+
+# State 0 - camel context not initialized
+# State 1 - camel context initialized
+
+RULE apache-camel: Install OpenTracing tracer
+CLASS org.apache.camel.impl.DefaultCamelContext
+METHOD startRouteDefinitions
+HELPER io.opentracing.contrib.agent.OpenTracingHelper
+BIND
+  ottracer:org.apache.camel.opentracing.OpenTracingTracer = new org.apache.camel.opentracing.OpenTracingTracer();
+AT ENTRY
+IF getState($0) == 0
+DO
+  ottracer.init($0);
+  setState($0, 1);
+ENDRULE

http://git-wip-us.apache.org/repos/asf/camel/blob/1ead8dfc/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/agent/InstallOpenTracingTracerRuleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/agent/InstallOpenTracingTracerRuleTest.java
b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/agent/InstallOpenTracingTracerRuleTest.java
new file mode 100644
index 0000000..cce12a7
--- /dev/null
+++ b/components/camel-opentracing/src/test/java/org/apache/camel/opentracing/agent/InstallOpenTracingTracerRuleTest.java
@@ -0,0 +1,98 @@
+/**
+ * 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.agent;
+
+import java.util.List;
+
+import io.opentracing.contrib.global.GlobalTracer;
+import io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockTracer;
+import io.opentracing.mock.MockTracer.Propagator;
+import io.opentracing.tag.Tags;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author gbrown
+ */
+public class InstallOpenTracingTracerRuleTest extends CamelTestSupport {
+
+    private static MockTracer tracer = new MockTracer(Propagator.TEXT_MAP);
+
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint resultEndpoint;
+
+    @Produce(uri = "direct:start")
+    protected ProducerTemplate template;
+
+    @BeforeClass
+    public static void initClass() throws Exception {
+        GlobalTracer.register(tracer);
+    }
+
+    @Before
+    public void init() {
+        tracer.reset();
+    }
+
+    public static MockTracer getTracer() {
+        return tracer;
+    }
+
+    @Override
+    public boolean isDumpRouteCoverage() {
+        return true;
+    }
+
+    @Test
+    public void testSendMatchingMessage() throws Exception {
+        String expectedBody = "<matched/>";
+
+        resultEndpoint.expectedBodiesReceived(expectedBody);
+
+        template.sendBodyAndHeader(expectedBody,  "foo",  "bar");
+
+        resultEndpoint.assertIsSatisfied();
+
+        List<MockSpan> spans = getTracer().finishedSpans();
+        assertEquals(3, spans.size());
+        assertEquals("mock", spans.get(0).operationName());
+        assertEquals("start", spans.get(1).operationName());
+        assertEquals("start", spans.get(2).operationName());
+        assertEquals(Tags.SPAN_KIND_CLIENT, spans.get(0).tags().get(Tags.SPAN_KIND.getKey()));
+        assertEquals(Tags.SPAN_KIND_SERVER, spans.get(1).tags().get(Tags.SPAN_KIND.getKey()));
+        assertEquals(Tags.SPAN_KIND_CLIENT, spans.get(2).tags().get(Tags.SPAN_KIND.getKey()));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ead8dfc/examples/camel-example-opentracing/README.md
----------------------------------------------------------------------
diff --git a/examples/camel-example-opentracing/README.md b/examples/camel-example-opentracing/README.md
index ec7f18a..78a23a2 100644
--- a/examples/camel-example-opentracing/README.md
+++ b/examples/camel-example-opentracing/README.md
@@ -32,13 +32,17 @@ $ cd service1
 $ mvn compile spring-boot:run
 ```
 
+This service uses an annotation _CamelOpenTracing_ to indicate that the service should be
traced.
+
 When service1 is ready then start service2
 
 ```sh
 $ cd service2
-$ mvn compile camel:run
+$ mvn compile exec:exec
 ```
 
+This service is instrumented using an OpenTracing Java Agent, so the code does not need to
be modified. The only requirement is that the OpenTracing Tracer and Camel OpenTracing component
dependencies are added, and that the _opentracing-agent.jar_ Java Agent is specified when
executing the service.
+
 And then start the client that calls service1 every 30 seconds.
 
 ```sh
@@ -46,6 +50,8 @@ $ cd client
 $ mvn compile camel:run
 ```
 
+The client application explicitly instantiates and initializes the OpenTracing Tracer with
the _CamelContext_.
+
 The shells will show *SPAN FINISHED* messages indicating what spans have been reported from
the client
 and two services.
 

http://git-wip-us.apache.org/repos/asf/camel/blob/1ead8dfc/examples/camel-example-opentracing/service2/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-opentracing/service2/pom.xml b/examples/camel-example-opentracing/service2/pom.xml
index 3be3276..ed90010 100644
--- a/examples/camel-example-opentracing/service2/pom.xml
+++ b/examples/camel-example-opentracing/service2/pom.xml
@@ -30,6 +30,10 @@
   <name>Camel :: Example :: OpenTracing :: Service 2</name>
   <description>An example showing how to trace incoming and outgoing messages from
Camel with OpenTracing</description>
 
+  <properties>
+    <opentracing-agent.lib>${project.build.directory}/lib</opentracing-agent.lib>
+  </properties>
+
   <!-- import Camel BOM -->
   <dependencyManagement>
     <dependencies>
@@ -52,55 +56,90 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-opentracing</artifactId>
+      <artifactId>camel-undertow</artifactId>
     </dependency>
+
     <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-undertow</artifactId>
+      <groupId>org.jboss.xnio</groupId>
+      <artifactId>xnio-nio</artifactId>
+      <version>${jboss-xnio-version}</version>
     </dependency>
 
     <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
+    </dependency>
+
+    <!-- OpenTracing dependencies -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-opentracing</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-example-opentracing-loggingtracer</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>io.opentracing.contrib</groupId>
+      <artifactId>opentracing-agent</artifactId>
+      <version>${opentracing-java-agent-version}</version>
+      <scope>provided</scope>
+    </dependency>
 
   </dependencies>
 
   <build>
 
     <plugins>
-      <!-- allows the routes to be run via 'mvn camel:run' -->
       <plugin>
-        <groupId>org.apache.camel</groupId>
-        <artifactId>camel-maven-plugin</artifactId>
-        <version>${project.version}</version>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>get-agent</id>
+            <phase>compile</phase>
+            <goals>
+              <goal>copy</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>io.opentracing.contrib</groupId>
+                  <artifactId>opentracing-agent</artifactId>
+                  <overWrite>true</overWrite>
+                  <outputDirectory>${opentracing-agent.lib}</outputDirectory>
+                  <destFileName>opentracing-agent.jar</destFileName>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
         <configuration>
-          <mainClass>sample.camel.Service2Application</mainClass>
+          <executable>java</executable>
+          <arguments>
+            <argument>-javaagent:${opentracing-agent.lib}/opentracing-agent.jar</argument>
+            <argument>-classpath</argument>
+            <classpath/>
+            <argument>sample.camel.Service2Application</argument>
+          </arguments>
         </configuration>
-        <dependencies>  
-          <!-- logging -->
-          <dependency>
-            <groupId>org.apache.logging.log4j</groupId>
-            <artifactId>log4j-api</artifactId>
-            <version>${log4j2-version}</version>
-          </dependency>
-          <dependency>
-            <groupId>org.apache.logging.log4j</groupId>
-            <artifactId>log4j-core</artifactId>
-            <version>${log4j2-version}</version>
-          </dependency>
-          <dependency>
-            <groupId>org.apache.logging.log4j</groupId>
-            <artifactId>log4j-slf4j-impl</artifactId>
-            <version>${log4j2-version}</version>
-          </dependency>
-          <dependency>
-            <groupId>org.apache.logging.log4j</groupId>
-            <artifactId>log4j-1.2-api</artifactId>
-            <version>${log4j2-version}</version>
-          </dependency>
-        </dependencies>
       </plugin>
     </plugins>
 

http://git-wip-us.apache.org/repos/asf/camel/blob/1ead8dfc/examples/camel-example-opentracing/service2/src/main/java/sample/camel/Service2Route.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-opentracing/service2/src/main/java/sample/camel/Service2Route.java
b/examples/camel-example-opentracing/service2/src/main/java/sample/camel/Service2Route.java
index e914ba8..24014b1 100644
--- a/examples/camel-example-opentracing/service2/src/main/java/sample/camel/Service2Route.java
+++ b/examples/camel-example-opentracing/service2/src/main/java/sample/camel/Service2Route.java
@@ -17,14 +17,11 @@
 package sample.camel;
 
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.opentracing.OpenTracingTracer;
 
 public class Service2Route extends RouteBuilder {
 
     @Override
     public void configure() throws Exception {
-        OpenTracingTracer ottracer = new OpenTracingTracer();
-        ottracer.init(getContext());
 
         from("undertow:http://0.0.0.0:7070/service2").routeId("service2").streamCaching()
                 .log(" Service2 request: ${body}")

http://git-wip-us.apache.org/repos/asf/camel/blob/1ead8dfc/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 6702128..f4cda15 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -492,6 +492,7 @@
     <openshift-java-client-version>2.7.0.Final</openshift-java-client-version>
     <openstack4j-version>3.0.2</openstack4j-version>
     <openstack4j-guava-version>17.0</openstack4j-guava-version>
+    <opentracing-java-agent-version>0.0.10</opentracing-java-agent-version>
     <opentracing-java-globaltracer-version>0.1.0</opentracing-java-globaltracer-version>
     <opentracing-java-spanmanager-version>0.0.3</opentracing-java-spanmanager-version>
     <opentracing-version>0.20.10</opentracing-version>


Mime
View raw message