CAMEL-9759: camel-zipkin - Instrument Camel. Work in progress.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/afc18f97 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/afc18f97 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/afc18f97 Branch: refs/heads/master Commit: afc18f97781b475bdd4e15072ad8c51729aa9c6a Parents: c6a2585 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Mar 29 14:40:48 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Mar 29 14:42:24 2016 +0200 ---------------------------------------------------------------------- apache-camel/pom.xml | 4 ++ .../src/main/descriptors/common-bin.xml | 1 + components/camel-zipkin/pom.xml | 4 +- .../zipkin/ZipkinLoggingSpanCollector.java | 13 +------ parent/pom.xml | 6 +++ .../features/src/main/resources/features.xml | 9 ++++- .../camel/itest/karaf/CamelZipkinTest.java | 40 ++++++++++++++++++++ 7 files changed, 61 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/afc18f97/apache-camel/pom.xml ---------------------------------------------------------------------- diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index faf142e..264f2fe 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -948,6 +948,10 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-zipkin</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-zookeeper</artifactId> </dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/afc18f97/apache-camel/src/main/descriptors/common-bin.xml ---------------------------------------------------------------------- diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml index ae2c879..fcbc250 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -247,6 +247,7 @@ <include>org.apache.camel:camel-xstream</include> <include>org.apache.camel:camel-yammer</include> <include>org.apache.camel:camel-zipfile</include> + <include>org.apache.camel:camel-zipkin</include> <include>org.apache.camel:camel-zookeeper</include> <include>org.apache.camel:camel-catalog</include> <include>org.apache.camel:camel-catalog-lucene</include> http://git-wip-us.apache.org/repos/asf/camel/blob/afc18f97/components/camel-zipkin/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-zipkin/pom.xml b/components/camel-zipkin/pom.xml index e5e5b31..0027d3a 100644 --- a/components/camel-zipkin/pom.xml +++ b/components/camel-zipkin/pom.xml @@ -47,13 +47,11 @@ <artifactId>brave-core</artifactId> <version>${brave-zipkin-version}</version> </dependency> - - <!-- for testing using a real zipkin server --> + <!-- to send to zipkin server --> <dependency> <groupId>com.github.kristofa</groupId> <artifactId>brave-spancollector-scribe</artifactId> <version>${brave-zipkin-version}</version> - <scope>test</scope> </dependency> <!-- test dependencies --> http://git-wip-us.apache.org/repos/asf/camel/blob/afc18f97/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinLoggingSpanCollector.java ---------------------------------------------------------------------- diff --git a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinLoggingSpanCollector.java b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinLoggingSpanCollector.java index 84daddb..608ef3a 100644 --- a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinLoggingSpanCollector.java +++ b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinLoggingSpanCollector.java @@ -16,12 +16,8 @@ */ package org.apache.camel.zipkin; -import java.util.LinkedHashSet; -import java.util.Set; - import com.github.kristofa.brave.IdConversion; import com.github.kristofa.brave.SpanCollector; -import com.twitter.zipkin.gen.BinaryAnnotation; import com.twitter.zipkin.gen.Span; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,7 +27,6 @@ import org.slf4j.LoggerFactory; */ public class ZipkinLoggingSpanCollector implements SpanCollector { - private final Set<BinaryAnnotation> defaultAnnotations = new LinkedHashSet<BinaryAnnotation>(); private final String name; private final Logger logger; @@ -46,12 +41,6 @@ public class ZipkinLoggingSpanCollector implements SpanCollector { @Override public void collect(Span span) { - if (!defaultAnnotations.isEmpty()) { - for (BinaryAnnotation ba : defaultAnnotations) { - span.addToBinary_annotations(ba); - } - } - if (logger.isInfoEnabled()) { long ms = span.getDuration() != null ? span.getDuration() / 1000 : -1; String id = IdConversion.convertToString(span.getId()); @@ -62,7 +51,7 @@ public class ZipkinLoggingSpanCollector implements SpanCollector { @Override public void addDefaultAnnotation(String key, String value) { - defaultAnnotations.add(BinaryAnnotation.create(key, value, null)); + // noop } } http://git-wip-us.apache.org/repos/asf/camel/blob/afc18f97/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index 0ff8534..fb672f9 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -311,6 +311,7 @@ <jettison-version>1.3.7</jettison-version> <jgit-version>4.2.0.201601211800-r</jgit-version> <jgroups-version>3.6.8.Final</jgroups-version> + <libthrift-version>0.9.0</libthrift-version> <jibx-version>1.2.6</jibx-version> <jing-bundle-version>20030619_5</jing-bundle-version> <jing-version>20030619</jing-version> @@ -1804,6 +1805,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-zipkin</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-zookeeper</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/afc18f97/platforms/karaf/features/src/main/resources/features.xml ---------------------------------------------------------------------- diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml index 67986fe..1ef3c26 100644 --- a/platforms/karaf/features/src/main/resources/features.xml +++ b/platforms/karaf/features/src/main/resources/features.xml @@ -1489,7 +1489,6 @@ <bundle>mvn:org.apache.camel/camel-solr/${project.version}</bundle> </feature> <feature name='camel-spark-rest' version='${project.version}' resolver='(obr)' start-level='50'> - <details>camel-spark-rest requires Java 8 and Jetty9</details> <feature version='${project.version}'>camel-core</feature> <feature version='${project.version}'>camel-jetty9</feature> <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.sparkjava-core/${spark-rest-bundle-version}</bundle> @@ -1815,6 +1814,14 @@ <feature version='${project.version}'>camel-core</feature> <bundle>mvn:org.apache.camel/camel-zipfile/${project.version}</bundle> </feature> + <feature name='camel-zipkin' version='${project.version}' resolver='(obr)' start-level='50'> + <details>camel-zpikin using spancollector-scribe does not yet work in OSGi</details> + <feature version='${project.version}'>camel-core</feature> + <bundle dependency='true'>wrap:mvn:com.github.kristofa/brave-core/${brave-zipkin-version}</bundle> + <!--<bundle dependency='true'>wrap:mvn:com.github.kristofa/brave-spancollector-scribe/${brave-zipkin-version}</bundle>--> + <bundle dependency='true'>mvn:org.apache.thrift/libthrift/${libthrift-version}</bundle> + <bundle>mvn:org.apache.camel/camel-zipkin/${project.version}</bundle> + </feature> <feature name='camel-zookeeper' version='${project.version}' resolver='(obr)' start-level='50'> <feature version='${project.version}'>camel-core</feature> <bundle dependency='true'>mvn:org.apache.zookeeper/zookeeper/${zookeeper-version}</bundle> http://git-wip-us.apache.org/repos/asf/camel/blob/afc18f97/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelZipkinTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelZipkinTest.java b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelZipkinTest.java new file mode 100644 index 0000000..7a665d5 --- /dev/null +++ b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelZipkinTest.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.itest.karaf; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; + +@RunWith(PaxExam.class) +public class CamelZipkinTest extends AbstractFeatureTest { + + public static final String COMPONENT = extractName(CamelZipkinTest.class); + + @Test + public void test() throws Exception { + // TODO: test zipkin + } + + @Configuration + public static Option[] configure() { + return configure(COMPONENT); + } + +}