You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/10/17 09:05:59 UTC
[camel-quarkus] branch master updated: fix: Add OpenTracing
extension
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new d356025 fix: Add OpenTracing extension
new 5047518 Merge pull request #279 from jamesnetherton/276-opentracing
d356025 is described below
commit d356025247b2cceb52d2d72b731bfb11b2fa7552
Author: James Netherton <ja...@gmail.com>
AuthorDate: Thu Oct 17 08:03:14 2019 +0100
fix: Add OpenTracing extension
fixes #276
---
.../pages/list-of-camel-quarkus-extensions.adoc | 4 +-
extensions/opentracing/deployment/pom.xml | 77 ++++++++++++
.../deployment/OpenTracingProcessor.java | 52 ++++++++
extensions/opentracing/pom.xml | 37 ++++++
extensions/opentracing/runtime/pom.xml | 87 +++++++++++++
.../opentracing/CamelOpenTracingConfig.java | 39 ++++++
.../opentracing/CamelOpenTracingRecorder.java | 43 +++++++
.../opentracing/PlatformHttpSpanDecorator.java | 30 +++++
.../org.apache.camel.opentracing.SpanDecorator | 18 +++
extensions/pom.xml | 1 +
extensions/readme.adoc | 4 +-
integration-tests/opentracing/pom.xml | 138 +++++++++++++++++++++
.../opentracing/it/MockTracerProducer.java | 44 +++++++
.../opentracing/it/OpenTracingResource.java | 62 +++++++++
.../opentracing/it/OpenTracingRouteBuilder.java | 33 +++++
.../src/main/resources/application.properties | 20 +++
.../component/opentracing/it/OpenTracingIT.java | 24 ++++
.../component/opentracing/it/OpenTracingTest.java | 69 +++++++++++
integration-tests/pom.xml | 1 +
poms/bom-deployment/pom.xml | 25 ++--
poms/bom/pom.xml | 40 +++---
21 files changed, 821 insertions(+), 27 deletions(-)
diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
index 9339e85..09fa64b 100644
--- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
+++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
@@ -130,7 +130,7 @@ Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated)
== Miscellaneous Extensions
// others: START
-Number of miscellaneous extensions: 4 in 4 JAR artifacts (0 deprecated)
+Number of miscellaneous extensions: 5 in 5 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -143,5 +143,7 @@ Number of miscellaneous extensions: 4 in 4 JAR artifacts (0 deprecated)
| (camel-quarkus-reactive-executor) | 0.2.1 | To use Quarkus reactive executor with Camel
| (camel-quarkus-microprofile-health) | 0.2.1 | Integration with the Quarkus MicroProfile Health extension
+
+| (camel-quarkus-opentracing) | 0.2.1 | Distributed tracing using OpenTracing
|===
// others: END
diff --git a/extensions/opentracing/deployment/pom.xml b/extensions/opentracing/deployment/pom.xml
new file mode 100644
index 0000000..282f448
--- /dev/null
+++ b/extensions/opentracing/deployment/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-opentracing-parent</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-opentracing-deployment</artifactId>
+ <name>Camel Quarkus :: OpenTracing :: Deployment</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-smallrye-opentracing-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-opentracing</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/extensions/opentracing/deployment/src/main/java/org/apache/camel/quarkus/component/opentracing/deployment/OpenTracingProcessor.java b/extensions/opentracing/deployment/src/main/java/org/apache/camel/quarkus/component/opentracing/deployment/OpenTracingProcessor.java
new file mode 100644
index 0000000..ff68bd8
--- /dev/null
+++ b/extensions/opentracing/deployment/src/main/java/org/apache/camel/quarkus/component/opentracing/deployment/OpenTracingProcessor.java
@@ -0,0 +1,52 @@
+/*
+ * 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.quarkus.component.opentracing.deployment;
+
+import io.opentracing.Tracer;
+import io.quarkus.arc.deployment.BeanContainerBuildItem;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.substrate.SubstrateResourceBuildItem;
+
+import org.apache.camel.quarkus.component.opentracing.CamelOpenTracingConfig;
+import org.apache.camel.quarkus.component.opentracing.CamelOpenTracingRecorder;
+import org.apache.camel.quarkus.core.deployment.CamelBeanBuildItem;
+
+class OpenTracingProcessor {
+
+ private static final String FEATURE = "camel-opentracing";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ void process(BuildProducer<SubstrateResourceBuildItem> resource) {
+ resource.produce(new SubstrateResourceBuildItem("META-INF/services/org.apache.camel.opentracing.SpanDecorator"));
+ }
+
+ @BuildStep
+ @Record(ExecutionTime.STATIC_INIT)
+ CamelBeanBuildItem setupCamelOpenTracingTracer(CamelOpenTracingConfig config, CamelOpenTracingRecorder recorder, BeanContainerBuildItem beanContainer) {
+ // Configure & bind OpenTracingTracer to the registry so that Camel can use it
+ return new CamelBeanBuildItem("tracer", Tracer.class, recorder.createCamelOpenTracingTracer(config, beanContainer.getValue()));
+ }
+}
diff --git a/extensions/opentracing/pom.xml b/extensions/opentracing/pom.xml
new file mode 100644
index 0000000..2296918
--- /dev/null
+++ b/extensions/opentracing/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-opentracing-parent</artifactId>
+ <name>Camel Quarkus :: OpenTracing</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/opentracing/runtime/pom.xml b/extensions/opentracing/runtime/pom.xml
new file mode 100644
index 0000000..2a72d64
--- /dev/null
+++ b/extensions/opentracing/runtime/pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-opentracing-parent</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-opentracing</artifactId>
+ <name>Camel Quarkus :: OpenTracing :: Runtime</name>
+ <description>Distributed tracing using OpenTracing</description>
+
+ <properties>
+ <firstVersion>0.2.1</firstVersion>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-smallrye-opentracing</artifactId>
+ </dependency>
+
+ <!-- Camel -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-opentracing</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/extensions/opentracing/runtime/src/main/java/org/apache/camel/quarkus/component/opentracing/CamelOpenTracingConfig.java b/extensions/opentracing/runtime/src/main/java/org/apache/camel/quarkus/component/opentracing/CamelOpenTracingConfig.java
new file mode 100644
index 0000000..8c1d87a
--- /dev/null
+++ b/extensions/opentracing/runtime/src/main/java/org/apache/camel/quarkus/component/opentracing/CamelOpenTracingConfig.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.quarkus.component.opentracing;
+
+import java.util.List;
+
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+
+@ConfigRoot(name = "camel.opentracing", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
+public final class CamelOpenTracingConfig {
+
+ /**
+ * Sets whether header keys need to be encoded
+ */
+ @ConfigItem(defaultValue = "false")
+ public boolean encoding;
+
+ /**
+ * Sets whether to disable tracing for endpoint URIs that match the given patterns
+ */
+ @ConfigItem
+ public List<String> excludePatterns;
+}
diff --git a/extensions/opentracing/runtime/src/main/java/org/apache/camel/quarkus/component/opentracing/CamelOpenTracingRecorder.java b/extensions/opentracing/runtime/src/main/java/org/apache/camel/quarkus/component/opentracing/CamelOpenTracingRecorder.java
new file mode 100644
index 0000000..ec399f4
--- /dev/null
+++ b/extensions/opentracing/runtime/src/main/java/org/apache/camel/quarkus/component/opentracing/CamelOpenTracingRecorder.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.quarkus.component.opentracing;
+
+import java.util.LinkedHashSet;
+
+import io.opentracing.Tracer;
+import io.quarkus.arc.runtime.BeanContainer;
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+
+import org.apache.camel.opentracing.OpenTracingTracer;
+
+@Recorder
+public class CamelOpenTracingRecorder {
+
+ public RuntimeValue<OpenTracingTracer> createCamelOpenTracingTracer(CamelOpenTracingConfig camelOpenTracingConfig, BeanContainer beanContainer) {
+ Tracer tracer = beanContainer.instance(Tracer.class);
+ OpenTracingTracer openTracingTracer = new OpenTracingTracer();
+ if (tracer != null) {
+ openTracingTracer.setTracer(tracer);
+ openTracingTracer.setEncoding(camelOpenTracingConfig.encoding);
+ if (camelOpenTracingConfig.excludePatterns != null) {
+ openTracingTracer.setExcludePatterns(new LinkedHashSet<>(camelOpenTracingConfig.excludePatterns));
+ }
+ }
+ return new RuntimeValue<>(openTracingTracer);
+ }
+}
diff --git a/extensions/opentracing/runtime/src/main/java/org/apache/camel/quarkus/component/opentracing/PlatformHttpSpanDecorator.java b/extensions/opentracing/runtime/src/main/java/org/apache/camel/quarkus/component/opentracing/PlatformHttpSpanDecorator.java
new file mode 100644
index 0000000..8adbdb1
--- /dev/null
+++ b/extensions/opentracing/runtime/src/main/java/org/apache/camel/quarkus/component/opentracing/PlatformHttpSpanDecorator.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.opentracing;
+
+import org.apache.camel.opentracing.decorators.AbstractHttpSpanDecorator;
+
+/**
+ * Camel OpenTracing SpanDecorator for the platform-http component
+ */
+public class PlatformHttpSpanDecorator extends AbstractHttpSpanDecorator {
+
+ @Override
+ public String getComponent() {
+ return "platform-http";
+ }
+}
diff --git a/extensions/opentracing/runtime/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator b/extensions/opentracing/runtime/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
new file mode 100644
index 0000000..468c7a4
--- /dev/null
+++ b/extensions/opentracing/runtime/src/main/resources/META-INF/services/org.apache.camel.opentracing.SpanDecorator
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.camel.quarkus.component.opentracing.PlatformHttpSpanDecorator
diff --git a/extensions/pom.xml b/extensions/pom.xml
index c327fec..3339fba 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -57,6 +57,7 @@
<module>microprofile-health</module>
<module>microprofile-metrics</module>
<module>netty-http</module>
+ <module>opentracing</module>
<module>paho</module>
<module>platform-http</module>
<module>rest</module>
diff --git a/extensions/readme.adoc b/extensions/readme.adoc
index 8cb4f0c..d864076 100644
--- a/extensions/readme.adoc
+++ b/extensions/readme.adoc
@@ -132,7 +132,7 @@ Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated)
== Miscellaneous Extensions
// others: START
-Number of miscellaneous extensions: 4 in 4 JAR artifacts (0 deprecated)
+Number of miscellaneous extensions: 5 in 5 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,5",options="header"]
|===
@@ -145,6 +145,8 @@ Number of miscellaneous extensions: 4 in 4 JAR artifacts (0 deprecated)
| (camel-quarkus-reactive-executor) | 0.2.1 | To use Quarkus reactive executor with Camel
| (camel-quarkus-microprofile-health) | 0.2.1 | Integration with the Quarkus MicroProfile Health extension
+
+| (camel-quarkus-opentracing) | 0.2.1 | Distributed tracing using OpenTracing
|===
// others: END
diff --git a/integration-tests/opentracing/pom.xml b/integration-tests/opentracing/pom.xml
new file mode 100644
index 0000000..47fc4c9
--- /dev/null
+++ b/integration-tests/opentracing/pom.xml
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-opentracing</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: OpenTracing</name>
+ <description>Integration tests for Camel Quarkus OpenTracing extension</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-opentracing</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jsonb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.opentracing</groupId>
+ <artifactId>opentracing-mock</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native-image</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>native-image</id>
+ <goals>
+ <goal>native-image</goal>
+ </goals>
+ <configuration>
+ <reportErrorsAtRuntime>false</reportErrorsAtRuntime>
+ <cleanupServer>true</cleanupServer>
+ <enableHttpUrlHandler>true</enableHttpUrlHandler>
+ <enableServer>false</enableServer>
+ <dumpProxies>false</dumpProxies>
+ <graalvmHome>${graalvmHome}</graalvmHome>
+ <enableJni>true</enableJni>
+ <enableAllSecurityServices>true</enableAllSecurityServices>
+ <disableReports>true</disableReports>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/integration-tests/opentracing/src/main/java/org/apache/camel/quarkus/component/opentracing/it/MockTracerProducer.java b/integration-tests/opentracing/src/main/java/org/apache/camel/quarkus/component/opentracing/it/MockTracerProducer.java
new file mode 100644
index 0000000..e0da47f
--- /dev/null
+++ b/integration-tests/opentracing/src/main/java/org/apache/camel/quarkus/component/opentracing/it/MockTracerProducer.java
@@ -0,0 +1,44 @@
+/*
+ * 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.quarkus.component.opentracing.it;
+
+import javax.annotation.Priority;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Produces;
+import javax.inject.Singleton;
+import javax.interceptor.Interceptor;
+
+import io.opentracing.Tracer;
+import io.opentracing.mock.MockTracer;
+
+/**
+ * Overrides the default Tracer created by the Jaeger tracing extension
+ */
+@ApplicationScoped
+@Alternative
+@Priority(Interceptor.Priority.APPLICATION + 10)
+public class MockTracerProducer {
+
+ @Default
+ @Produces
+ @Singleton
+ public Tracer tracer() {
+ return new MockTracer();
+ }
+}
\ No newline at end of file
diff --git a/integration-tests/opentracing/src/main/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingResource.java b/integration-tests/opentracing/src/main/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingResource.java
new file mode 100644
index 0000000..c8fc871
--- /dev/null
+++ b/integration-tests/opentracing/src/main/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingResource.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.quarkus.component.opentracing.it;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObjectBuilder;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import io.opentracing.Tracer;
+import io.opentracing.mock.MockSpan;
+import io.opentracing.mock.MockTracer;
+
+@Path("/opentracing")
+@ApplicationScoped
+public class OpenTracingResource {
+
+ @Inject
+ Tracer tracer;
+
+ @Path("/spans")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public JsonArray getSpans() {
+ JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
+
+ MockTracer mockTracer = (MockTracer) tracer;
+ for (MockSpan span : mockTracer.finishedSpans()) {
+ MockSpan.MockContext context = span.context();
+
+ JsonObjectBuilder objectBuilder = Json.createObjectBuilder();
+ objectBuilder.add("spanId", context.spanId());
+ objectBuilder.add("traceId", context.traceId());
+
+ span.tags().forEach((k, v) -> objectBuilder.add(k, v.toString()));
+
+ arrayBuilder.add(objectBuilder.build());
+ }
+
+ return arrayBuilder.build();
+ }
+}
diff --git a/integration-tests/opentracing/src/main/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingRouteBuilder.java b/integration-tests/opentracing/src/main/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingRouteBuilder.java
new file mode 100644
index 0000000..e7f3596
--- /dev/null
+++ b/integration-tests/opentracing/src/main/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingRouteBuilder.java
@@ -0,0 +1,33 @@
+/*
+ * 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.quarkus.component.opentracing.it;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+public class OpenTracingRouteBuilder extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("platform-http:/opentracing/test/trace?httpMethodRestrict=GET")
+ .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(200))
+ .setBody(constant("GET: /opentracing/test/trace"));
+
+ from("platform-http:/opentracing/test/trace/filtered")
+ .setBody(constant("GET: /opentracing/test/trace/filtered"));
+ }
+}
diff --git a/integration-tests/opentracing/src/main/resources/application.properties b/integration-tests/opentracing/src/main/resources/application.properties
new file mode 100644
index 0000000..cb6da54
--- /dev/null
+++ b/integration-tests/opentracing/src/main/resources/application.properties
@@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+camel.context.name = quarkus-camel-example
+
+quarkus.camel.opentracing.exclude-patterns = platform-http:/opentracing/test/trace/filtered
diff --git a/integration-tests/opentracing/src/test/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingIT.java b/integration-tests/opentracing/src/test/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingIT.java
new file mode 100644
index 0000000..5e677d9
--- /dev/null
+++ b/integration-tests/opentracing/src/test/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingIT.java
@@ -0,0 +1,24 @@
+/*
+ * 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.quarkus.component.opentracing.it;
+
+import io.quarkus.test.junit.SubstrateTest;
+
+@SubstrateTest
+class OpenTracingIT extends OpenTracingTest {
+
+}
diff --git a/integration-tests/opentracing/src/test/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingTest.java b/integration-tests/opentracing/src/test/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingTest.java
new file mode 100644
index 0000000..d64efb0
--- /dev/null
+++ b/integration-tests/opentracing/src/test/java/org/apache/camel/quarkus/component/opentracing/it/OpenTracingTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.quarkus.component.opentracing.it;
+
+import java.util.List;
+import java.util.Map;
+
+import io.opentracing.tag.Tags;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.path.json.JsonPath;
+
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+class OpenTracingTest {
+
+ @Test
+ public void testTraceRoute() {
+ // Generate messages
+ for (int i = 0; i < 5; i++) {
+ RestAssured.get("/opentracing/test/trace")
+ .then()
+ .statusCode(200);
+
+ // No spans should be recorded for this route as they are excluded by camel.opentracing.exclude-patterns in application.properties
+ RestAssured.get("/opentracing/test/trace/filtered")
+ .then()
+ .statusCode(200);
+ }
+
+ // Retrieve recorded spans
+ JsonPath jsonPath = RestAssured.given()
+ .get("/opentracing/spans")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .jsonPath();
+
+ List<Map<String, String>> spans = jsonPath.get();
+ assertEquals(5, spans.size());
+
+ for (Map<String, String> span : spans) {
+ assertEquals("server", span.get(Tags.SPAN_KIND.getKey()));
+ assertEquals("camel-platform-http", span.get(Tags.COMPONENT.getKey()));
+ assertEquals("200", span.get(Tags.HTTP_STATUS.getKey()));
+ assertEquals("GET", span.get(Tags.HTTP_METHOD.getKey()));
+ assertEquals("platform-http:///opentracing/test/trace?httpMethodRestrict=GET", span.get("camel.uri"));
+ assertTrue(span.get(Tags.HTTP_URL.getKey()).endsWith("/opentracing/test/trace"));
+ }
+ }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index fa5361e..84552f8 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -92,6 +92,7 @@
<module>microprofile-health</module>
<module>microprofile-metrics</module>
<module>netty-http</module>
+ <module>opentracing</module>
<module>paho</module>
<module>platform-http</module>
<module>salesforce</module>
diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml
index 7a4ad59..89b0f58 100644
--- a/poms/bom-deployment/pom.xml
+++ b/poms/bom-deployment/pom.xml
@@ -167,6 +167,21 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-opentracing-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-paho-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-reactive-executor-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
@@ -215,16 +230,6 @@
<artifactId>camel-quarkus-tarfile-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-paho-deployment</artifactId>
- <version>${camel-quarkus.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-platform-http-deployment</artifactId>
- <version>${camel-quarkus.version}</version>
- </dependency>
</dependencies>
</dependencyManagement>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index c77c9ee..c5c9906 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -193,6 +193,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-opentracing</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-paho</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -359,6 +364,26 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-opentracing</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-paho</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-platform-http-component</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-reactive-executor</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
@@ -409,21 +434,6 @@
<artifactId>xstream</artifactId>
<version>${xstream.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-paho</artifactId>
- <version>${camel-quarkus.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-platform-http</artifactId>
- <version>${camel-quarkus.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-platform-http-component</artifactId>
- <version>${camel-quarkus.version}</version>
- </dependency>
</dependencies>
</dependencyManagement>