You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/12/02 11:05:05 UTC
[camel-quarkus] branch master updated: Micrometer component support
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton 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 1b60e43 Micrometer component support
1b60e43 is described below
commit 1b60e436def71a3f193e5abedc60c910b87666c8
Author: James Netherton <ja...@gmail.com>
AuthorDate: Wed Dec 2 07:14:11 2020 +0000
Micrometer component support
Fixes #2034
---
catalog/pom.xml | 13 ++
.../pages/reference/extensions/micrometer.adoc | 110 +++++++++++++
.../ROOT/pages/user-guide/observability.adoc | 9 +-
.../partials/reference/components/micrometer.adoc | 14 +-
extensions/micrometer/deployment/pom.xml | 71 ++++++++
.../micrometer/deployment/MicrometerProcessor.java | 65 ++++++++
extensions/micrometer/pom.xml | 39 +++++
extensions/micrometer/runtime/pom.xml | 121 ++++++++++++++
.../micrometer/runtime/src/main/doc/usage.adoc | 37 +++++
.../micrometer/CamelMicrometerConfig.java | 56 +++++++
.../micrometer/CamelMicrometerRecorder.java | 84 ++++++++++
.../main/resources/META-INF/quarkus-extension.yaml | 31 ++++
extensions/pom.xml | 1 +
integration-tests/micrometer/pom.xml | 178 +++++++++++++++++++++
.../micrometer/it/MicrometerResource.java | 109 +++++++++++++
.../component/micrometer/it/MicrometerRoutes.java | 43 +++++
.../src/main/resources/application.properties | 20 +++
.../component/micrometer/it/MicrometerIT.java | 24 +++
.../component/micrometer/it/MicrometerTest.java | 113 +++++++++++++
integration-tests/pom.xml | 1 +
poms/bom/pom.xml | 15 ++
tooling/scripts/test-categories.yaml | 1 +
22 files changed, 1150 insertions(+), 5 deletions(-)
diff --git a/catalog/pom.xml b/catalog/pom.xml
index 3a95d63..09745bb 100644
--- a/catalog/pom.xml
+++ b/catalog/pom.xml
@@ -2467,6 +2467,19 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-micrometer</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-microprofile-fault-tolerance</artifactId>
<version>${project.version}</version>
<type>pom</type>
diff --git a/docs/modules/ROOT/pages/reference/extensions/micrometer.adoc b/docs/modules/ROOT/pages/reference/extensions/micrometer.adoc
new file mode 100644
index 0000000..f63d7a9
--- /dev/null
+++ b/docs/modules/ROOT/pages/reference/extensions/micrometer.adoc
@@ -0,0 +1,110 @@
+// Do not edit directly!
+// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
+= Micrometer
+:cq-artifact-id: camel-quarkus-micrometer
+:cq-native-supported: true
+:cq-status: Stable
+:cq-description: Collect various metrics directly from Camel routes using the Micrometer library.
+:cq-deprecated: false
+:cq-jvm-since: 1.5.0
+:cq-native-since: 1.5.0
+
+[.badges]
+[.badge-key]##JVM since##[.badge-supported]##1.5.0## [.badge-key]##Native since##[.badge-supported]##1.5.0##
+
+Collect various metrics directly from Camel routes using the Micrometer library.
+
+== What's inside
+
+* xref:latest@components::micrometer-component.adoc[Micrometer component], URI syntax: `micrometer:metricsType:metricsName`
+
+Please refer to the above link for usage and configuration details.
+
+== Maven coordinates
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-micrometer</artifactId>
+</dependency>
+----
+
+Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== Usage
+
+This extension leverages https://quarkus.io/guides/micrometer[Quarkus Micrometer]. Quarkus supports a variety of Micrometer metric registry implementations.
+
+Your application should declare one of the following dependencies, depending on the monitoring solution you want to work with.
+
+[cols="50,.^50]
+|===
+|Monitoring System | Dependency
+
+| Azure
+
+| `io.micrometer:micrometer-registry-azure-monitor`
+
+| Datadog
+
+| `io.micrometer:micrometer-registry-datadog`
+
+| JMX (JVM mode only)
+
+| `io.micrometer:micrometer-registry-jmx`
+
+| Prometheus
+
+| `io.micrometer:micrometer-registry-prometheus`
+
+| SignalFx
+
+| `io.micrometer:micrometer-registry-signalfx`
+
+| Stackdriver
+
+| `io.micrometer:micrometer-registry-stackdriver`
+
+| StatsD
+
+| `io.micrometer:micrometer-registry-statsd`
+
+|===
+
+
+== Additional Camel Quarkus configuration
+
+[width="100%",cols="80,5,15",options="header"]
+|===
+| Configuration property | Type | Default
+
+
+|icon:lock[title=Fixed at build time] [[quarkus.camel.metrics.enable-route-policy]]`link:#quarkus.camel.metrics.enable-route-policy[quarkus.camel.metrics.enable-route-policy]`
+
+Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.
+| `boolean`
+| `true`
+
+|icon:lock[title=Fixed at build time] [[quarkus.camel.metrics.enable-message-history]]`link:#quarkus.camel.metrics.enable-message-history[quarkus.camel.metrics.enable-message-history]`
+
+Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics on individual route node processing times. Depending on the number of configured route nodes, there is the potential to create a large volume of metrics. Therefore, this option is disabled by default.
+| `boolean`
+| `false`
+
+|icon:lock[title=Fixed at build time] [[quarkus.camel.metrics.enable-exchange-event-notifier]]`link:#quarkus.camel.metrics.enable-exchange-event-notifier[quarkus.camel.metrics.enable-exchange-event-notifier]`
+
+Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics on exchange processing times.
+| `boolean`
+| `true`
+
+|icon:lock[title=Fixed at build time] [[quarkus.camel.metrics.enable-route-event-notifier]]`link:#quarkus.camel.metrics.enable-route-event-notifier[quarkus.camel.metrics.enable-route-event-notifier]`
+
+Set whether to enable the MicrometerRouteEventNotifier for capturing metrics on the total number of routes and total number of routes running.
+| `boolean`
+| `true`
+|===
+
+[.configuration-legend]
+icon:lock[title=Fixed at build time] Configuration property fixed at build time. All other configuration properties are overridable at runtime.
+
diff --git a/docs/modules/ROOT/pages/user-guide/observability.adoc b/docs/modules/ROOT/pages/user-guide/observability.adoc
index 884f6ea..1293ade 100644
--- a/docs/modules/ROOT/pages/user-guide/observability.adoc
+++ b/docs/modules/ROOT/pages/user-guide/observability.adoc
@@ -17,11 +17,12 @@ There's an example project which demonstrates health checks: https://github.com/
== Metrics
-We provide the xref:reference/extensions/microprofile-metrics.adoc[MicroProfile Metrics] extension which integrates with
-https://quarkus.io/guides/microprofile-metrics[Quarkus MicroProfile Metrics] under the hood. Some basic Camel metrics
-are provided for you out of the box, and these can be supplemented by configuring additional metrics in your routes.
+We provide two choices for exposing metrics. The xref:reference/extensions/micrometer.adoc[Micrometer] extension (preferred) which integrates with https://quarkus.io/guides/micrometer[Quarkus Micrometer] and the xref:reference/extensions/microprofile-metrics.adoc[MicroProfile Metrics] extension which integrates with
+https://quarkus.io/guides/microprofile-metrics[Quarkus MicroProfile Metrics].
-Metrics are available on the standard MicroProfile metrics endpoint:
+Some basic Camel metrics are provided for you out of the box, and these can be supplemented by configuring additional metrics in your routes.
+
+Metrics are available on the standard Quarkus metrics endpoint:
* http://localhost:8080/metrics
diff --git a/docs/modules/ROOT/partials/reference/components/micrometer.adoc b/docs/modules/ROOT/partials/reference/components/micrometer.adoc
index a509c1d..38d8892 100644
--- a/docs/modules/ROOT/partials/reference/components/micrometer.adoc
+++ b/docs/modules/ROOT/partials/reference/components/micrometer.adoc
@@ -1 +1,13 @@
-// Empty partial for a Camel bit unsupported by Camel Quarkus to avoid warnings when this file is included from a Camel page
+// Do not edit directly!
+// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
+:cq-artifact-id: camel-quarkus-micrometer
+:cq-artifact-id-base: micrometer
+:cq-native-supported: true
+:cq-status: Stable
+:cq-deprecated: false
+:cq-jvm-since: 1.5.0
+:cq-native-since: 1.5.0
+:cq-camel-part-name: micrometer
+:cq-camel-part-title: Micrometer
+:cq-camel-part-description: Collect various metrics directly from Camel routes using the Micrometer library.
+:cq-extension-page-title: Micrometer
diff --git a/extensions/micrometer/deployment/pom.xml b/extensions/micrometer/deployment/pom.xml
new file mode 100644
index 0000000..6f2beee
--- /dev/null
+++ b/extensions/micrometer/deployment/pom.xml
@@ -0,0 +1,71 @@
+<?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-micrometer-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-micrometer-deployment</artifactId>
+ <name>Camel Quarkus :: Micrometer :: Deployment</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-micrometer-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jackson-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-micrometer</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/micrometer/deployment/src/main/java/org/apache/camel/quarkus/component/micrometer/deployment/MicrometerProcessor.java b/extensions/micrometer/deployment/src/main/java/org/apache/camel/quarkus/component/micrometer/deployment/MicrometerProcessor.java
new file mode 100644
index 0000000..b4a71d1
--- /dev/null
+++ b/extensions/micrometer/deployment/src/main/java/org/apache/camel/quarkus/component/micrometer/deployment/MicrometerProcessor.java
@@ -0,0 +1,65 @@
+/*
+ * 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.micrometer.deployment;
+
+import io.micrometer.core.instrument.MeterRegistry;
+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.micrometer.deployment.RootMeterRegistryBuildItem;
+import org.apache.camel.component.micrometer.MicrometerConstants;
+import org.apache.camel.quarkus.component.micrometer.CamelMicrometerConfig;
+import org.apache.camel.quarkus.component.micrometer.CamelMicrometerRecorder;
+import org.apache.camel.quarkus.core.deployment.spi.CamelBeanBuildItem;
+import org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;
+import org.apache.camel.quarkus.core.deployment.spi.RuntimeCamelContextCustomizerBuildItem;
+
+class MicrometerProcessor {
+
+ private static final String FEATURE = "camel-micrometer";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ CamelBeanBuildItem meterRegistry(RootMeterRegistryBuildItem registry) {
+ return new CamelBeanBuildItem(
+ MicrometerConstants.METRICS_REGISTRY_NAME,
+ MeterRegistry.class.getName(),
+ registry.getValue());
+ }
+
+ @Record(ExecutionTime.STATIC_INIT)
+ @BuildStep
+ CamelContextCustomizerBuildItem contextCustomizer(
+ CamelMicrometerRecorder recorder,
+ CamelMicrometerConfig config) {
+
+ return new CamelContextCustomizerBuildItem(recorder.createContextCustomizer(config));
+ }
+
+ @Record(ExecutionTime.RUNTIME_INIT)
+ @BuildStep
+ RuntimeCamelContextCustomizerBuildItem runtimeContextCustomizer(
+ CamelMicrometerRecorder recorder,
+ CamelMicrometerConfig config) {
+ return new RuntimeCamelContextCustomizerBuildItem(recorder.createRuntimeContextCustomizer(config));
+ }
+}
diff --git a/extensions/micrometer/pom.xml b/extensions/micrometer/pom.xml
new file mode 100644
index 0000000..df9c662
--- /dev/null
+++ b/extensions/micrometer/pom.xml
@@ -0,0 +1,39 @@
+<?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>1.5.0-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-micrometer-parent</artifactId>
+ <name>Camel Quarkus :: Micrometer</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/micrometer/runtime/pom.xml b/extensions/micrometer/runtime/pom.xml
new file mode 100644
index 0000000..335c599
--- /dev/null
+++ b/extensions/micrometer/runtime/pom.xml
@@ -0,0 +1,121 @@
+<?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-micrometer-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-micrometer</artifactId>
+ <name>Camel Quarkus :: Micrometer :: Runtime</name>
+ <description>Collect various metrics directly from Camel routes using the Micrometer library.</description>
+
+ <properties>
+ <camel.quarkus.jvmSince>1.5.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>1.5.0</camel.quarkus.nativeSince>
+ </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>io.quarkus</groupId>
+ <artifactId>quarkus-micrometer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jackson</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-micrometer</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>
+
+
+ <profiles>
+ <profile>
+ <id>full</id>
+ <activation>
+ <property>
+ <name>!quickly</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>update-extension-doc-page</id>
+ <goals>
+ <goal>update-extension-doc-page</goal>
+ </goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/extensions/micrometer/runtime/src/main/doc/usage.adoc b/extensions/micrometer/runtime/src/main/doc/usage.adoc
new file mode 100644
index 0000000..9b35670
--- /dev/null
+++ b/extensions/micrometer/runtime/src/main/doc/usage.adoc
@@ -0,0 +1,37 @@
+This extension leverages https://quarkus.io/guides/micrometer[Quarkus Micrometer]. Quarkus supports a variety of Micrometer metric registry implementations.
+
+Your application should declare one of the following dependencies, depending on the monitoring solution you want to work with.
+
+[cols="50,.^50]
+|===
+|Monitoring System | Dependency
+
+| Azure
+
+| `io.micrometer:micrometer-registry-azure-monitor`
+
+| Datadog
+
+| `io.micrometer:micrometer-registry-datadog`
+
+| JMX (JVM mode only)
+
+| `io.micrometer:micrometer-registry-jmx`
+
+| Prometheus
+
+| `io.micrometer:micrometer-registry-prometheus`
+
+| SignalFx
+
+| `io.micrometer:micrometer-registry-signalfx`
+
+| Stackdriver
+
+| `io.micrometer:micrometer-registry-stackdriver`
+
+| StatsD
+
+| `io.micrometer:micrometer-registry-statsd`
+
+|===
diff --git a/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerConfig.java b/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerConfig.java
new file mode 100644
index 0000000..656491e
--- /dev/null
+++ b/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerConfig.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.micrometer;
+
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+
+@ConfigRoot(name = "camel.metrics", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
+public class CamelMicrometerConfig {
+
+ /**
+ * Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics
+ * on route processing times.
+ */
+ @ConfigItem(defaultValue = "true")
+ public boolean enableRoutePolicy;
+
+ /**
+ * Set whether to enable the MicrometerMessageHistoryFactory for capturing metrics
+ * on individual route node processing times.
+ *
+ * Depending on the number of configured route nodes, there is the potential to create a large
+ * volume of metrics. Therefore, this option is disabled by default.
+ */
+ @ConfigItem(defaultValue = "false")
+ public boolean enableMessageHistory;
+
+ /**
+ * Set whether to enable the MicrometerExchangeEventNotifier for capturing metrics
+ * on exchange processing times.
+ */
+ @ConfigItem(defaultValue = "true")
+ public boolean enableExchangeEventNotifier;
+
+ /**
+ * Set whether to enable the MicrometerRouteEventNotifier for capturing metrics
+ * on the total number of routes and total number of routes running.
+ */
+ @ConfigItem(defaultValue = "true")
+ public boolean enableRouteEventNotifier;
+}
diff --git a/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerRecorder.java b/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerRecorder.java
new file mode 100644
index 0000000..1d10a75
--- /dev/null
+++ b/extensions/micrometer/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/CamelMicrometerRecorder.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.quarkus.component.micrometer;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEventNotifier;
+import org.apache.camel.component.micrometer.eventnotifier.MicrometerRouteEventNotifier;
+import org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryFactory;
+import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;
+import org.apache.camel.quarkus.core.CamelContextCustomizer;
+import org.apache.camel.spi.ManagementStrategy;
+
+@Recorder
+public class CamelMicrometerRecorder {
+
+ public RuntimeValue<CamelContextCustomizer> createContextCustomizer(CamelMicrometerConfig config) {
+ return new RuntimeValue<>(new MicrometerContextCustomizer(config));
+ }
+
+ public RuntimeValue<CamelContextCustomizer> createRuntimeContextCustomizer(CamelMicrometerConfig config) {
+ return new RuntimeValue<>(new MicrometerRuntimeContextCustomizer(config));
+ }
+
+ private static class MicrometerContextCustomizer implements CamelContextCustomizer {
+ private final CamelMicrometerConfig config;
+
+ public MicrometerContextCustomizer(CamelMicrometerConfig config) {
+ this.config = config;
+ }
+
+ @Override
+ public void customize(CamelContext camelContext) {
+ if (config.enableRoutePolicy) {
+ camelContext.addRoutePolicyFactory(new MicrometerRoutePolicyFactory());
+ }
+
+ ManagementStrategy managementStrategy = camelContext.getManagementStrategy();
+ if (config.enableExchangeEventNotifier) {
+ managementStrategy.addEventNotifier(new MicrometerExchangeEventNotifier());
+ }
+
+ if (config.enableRouteEventNotifier) {
+ managementStrategy.addEventNotifier(new MicrometerRouteEventNotifier());
+ }
+ }
+ }
+
+ private static class MicrometerRuntimeContextCustomizer implements CamelContextCustomizer {
+ private final CamelMicrometerConfig config;
+
+ public MicrometerRuntimeContextCustomizer(CamelMicrometerConfig config) {
+ this.config = config;
+ }
+
+ @Override
+ public void customize(CamelContext camelContext) {
+ if (!config.enableMessageHistory) {
+ return;
+ }
+
+ if (!camelContext.isMessageHistory()) {
+ camelContext.setMessageHistory(true);
+ }
+
+ camelContext.setMessageHistoryFactory(new MicrometerMessageHistoryFactory());
+ }
+ }
+}
diff --git a/extensions/micrometer/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/micrometer/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000..916fd3f
--- /dev/null
+++ b/extensions/micrometer/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+
+# This is a generated file. Do not edit directly!
+# To re-generate, run the following command from the top level directory:
+#
+# mvn -N cq:update-quarkus-metadata
+#
+---
+name: "Camel Micrometer"
+description: "Collect various metrics directly from Camel routes using the Micrometer library"
+metadata:
+ guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/micrometer.html"
+ categories:
+ - "integration"
+ status:
+ - "stable"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 7d7172f..9728c0f 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -148,6 +148,7 @@
<module>lzf</module>
<module>mail</module>
<module>master</module>
+ <module>micrometer</module>
<module>microprofile-fault-tolerance</module>
<module>microprofile-health</module>
<module>microprofile-metrics</module>
diff --git a/integration-tests/micrometer/pom.xml b/integration-tests/micrometer/pom.xml
new file mode 100644
index 0000000..db2c133
--- /dev/null
+++ b/integration-tests/micrometer/pom.xml
@@ -0,0 +1,178 @@
+<?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>1.5.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-integration-test-micrometer</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Micrometer</name>
+ <description>Integration tests for Camel Quarkus Micrometer extension</description>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-test</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-main</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-log</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-micrometer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.micrometer</groupId>
+ <artifactId>micrometer-registry-prometheus</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jsonb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jsonb</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>
+
+ <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-log-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-main-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-micrometer-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </properties>
+ <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>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/integration-tests/micrometer/src/main/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerResource.java b/integration-tests/micrometer/src/main/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerResource.java
new file mode 100644
index 0000000..c3244ea
--- /dev/null
+++ b/integration-tests/micrometer/src/main/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerResource.java
@@ -0,0 +1,109 @@
+/*
+ * 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.micrometer.it;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tag;
+import io.micrometer.core.instrument.search.Search;
+import org.apache.camel.ProducerTemplate;
+
+@Path("/micrometer")
+public class MicrometerResource {
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Inject
+ MeterRegistry meterRegistry;
+
+ @Path("/metric/{type}/{name}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @GET
+ public Response getMetricValue(@PathParam("type") String type, @PathParam("name") String name,
+ @QueryParam("tags") String tagValues) {
+ List<Tag> tags = new ArrayList<>();
+
+ if (tagValues.length() > 0) {
+ String[] tagElements = tagValues.split(",");
+ for (String element : tagElements) {
+ String[] tagParts = element.split("=");
+ tags.add(Tag.of(tagParts[0], tagParts[1]));
+ }
+ }
+
+ Search search = meterRegistry.find(name).tags(tags);
+ if (search == null) {
+ return Response.status(404).build();
+ }
+
+ Response.ResponseBuilder response = Response.ok();
+ if (type.equals("counter")) {
+ response.entity(search.counter().count());
+ } else if (type.equals("gauge")) {
+ response.entity(search.gauge().value());
+ } else if (type.equals("summary")) {
+ response.entity(search.summary().max());
+ } else if (type.equals("timer")) {
+ response.entity(search.timer().totalTime(TimeUnit.MILLISECONDS));
+ } else {
+ throw new IllegalArgumentException("Unknown metric type: " + type);
+ }
+
+ return response.build();
+ }
+
+ @Path("/counter")
+ @GET
+ public Response counter() {
+ producerTemplate.sendBody("direct:counter", null);
+ return Response.ok().build();
+ }
+
+ @Path("/summary")
+ @GET
+ public Response summarySetValue(@QueryParam("value") int value) {
+ producerTemplate.sendBody("direct:summary", value);
+ return Response.ok().build();
+ }
+
+ @Path("/timer")
+ @GET
+ public Response timerStartStop() {
+ producerTemplate.sendBody("direct:timer", null);
+ return Response.ok().build();
+ }
+
+ @Path("/log")
+ @GET
+ public Response logMessage() {
+ producerTemplate.requestBody("direct:log", (Object) null);
+ return Response.ok().build();
+ }
+}
diff --git a/integration-tests/micrometer/src/main/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerRoutes.java b/integration-tests/micrometer/src/main/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerRoutes.java
new file mode 100644
index 0000000..068d2fd
--- /dev/null
+++ b/integration-tests/micrometer/src/main/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerRoutes.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.micrometer.it;
+
+import org.apache.camel.builder.RouteBuilder;
+
+import static org.apache.camel.component.micrometer.MicrometerConstants.HEADER_HISTOGRAM_VALUE;
+
+public class MicrometerRoutes extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:counter")
+ .to("micrometer:counter:camel-quarkus-counter");
+
+ from("direct:summary")
+ .setHeader(HEADER_HISTOGRAM_VALUE, simple("${body}"))
+ .to("micrometer:summary:camel-quarkus-summary");
+
+ from("direct:timer")
+ .id("micrometer-metrics-timer")
+ .to("micrometer:timer:camel-quarkus-timer?action=start")
+ .delay(100)
+ .to("micrometer:timer:camel-quarkus-timer?action=stop");
+
+ from("direct:log").routeId("log")
+ .log("Camel Quarkus Micrometer");
+ }
+}
diff --git a/integration-tests/micrometer/src/main/resources/application.properties b/integration-tests/micrometer/src/main/resources/application.properties
new file mode 100644
index 0000000..88616a5
--- /dev/null
+++ b/integration-tests/micrometer/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-micrometer
+
+quarkus.camel.metrics.enable-message-history = true
diff --git a/integration-tests/micrometer/src/test/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerIT.java b/integration-tests/micrometer/src/test/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerIT.java
new file mode 100644
index 0000000..2def38d
--- /dev/null
+++ b/integration-tests/micrometer/src/test/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerIT.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.micrometer.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+class MicrometerIT extends MicrometerTest {
+
+}
diff --git a/integration-tests/micrometer/src/test/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerTest.java b/integration-tests/micrometer/src/test/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerTest.java
new file mode 100644
index 0000000..40bc9cf
--- /dev/null
+++ b/integration-tests/micrometer/src/test/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.micrometer.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+class MicrometerTest {
+
+ @Test
+ public void testMicrometerMetricsCounter() {
+ RestAssured.get("/micrometer/counter")
+ .then()
+ .statusCode(200);
+ assertEquals(1, getMetricValue(Integer.class, "counter", "camel-quarkus-counter"));
+ }
+
+ @Test
+ public void testMicrometerSummary() {
+ RestAssured.get("/micrometer/summary?value=10")
+ .then()
+ .statusCode(200);
+ assertEquals(10, getMetricValue(Integer.class, "summary", "camel-quarkus-summary"));
+ }
+
+ @Test
+ public void testMicrometerTimer() {
+ RestAssured.get("/micrometer/timer")
+ .then()
+ .statusCode(200);
+ assertTrue(getMetricValue(Integer.class, "timer", "camel-quarkus-timer") >= 100);
+ }
+
+ @Test
+ public void testMicrometerRoutePolicyFactory() {
+ RestAssured.get("/micrometer/timer")
+ .then()
+ .statusCode(200);
+ assertTrue(getMetricValue(Integer.class, "counter", "CamelExchangesSucceeded", "routeId=micrometer-metrics-timer") > 0);
+ assertEquals(0, getMetricValue(Integer.class, "counter", "CamelExchangesFailed", "routeId=micrometer-metrics-timer"));
+ }
+
+ @Test
+ public void testMicrometerMessageHistoryFactory() {
+ RestAssured.get("/micrometer/log")
+ .then()
+ .statusCode(200);
+ String tags = "nodeId=log1,routeId=log";
+ assertTrue(getMetricValue(Double.class, "timer", "CamelMessageHistory", tags) > 0.0);
+ }
+
+ @Test
+ public void testMicrometerRouteEventNotifier() {
+ assertTrue(getMetricValue(Integer.class, "gauge", "CamelRoutesAdded") >= 4);
+ assertTrue(getMetricValue(Integer.class, "gauge", "CamelRoutesRunning") >= 4);
+ }
+
+ @Test
+ public void testMicrometerExchangeEventNotifier() {
+ RestAssured.get("/micrometer/log")
+ .then()
+ .statusCode(200);
+ String tags = "endpointName=direct://log,eventType=ExchangeSentEvent";
+ assertTrue(getMetricValue(Double.class, "timer", "CamelExchangeEventNotifier", tags) >= 0.0);
+ }
+
+ private <T> T getMetricValue(Class<T> as, String type, String name) {
+ return getMetricValue(as, type, name, null);
+ }
+
+ private <T> T getMetricValue(Class<T> as, String type, String name, String tags) {
+ return RestAssured.given()
+ .queryParam("tags", tags)
+ .when()
+ .get("/micrometer/metric/" + type + "/" + name)
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .as(as);
+ }
+
+ /**
+ * Debug available metrics
+ */
+ private String dumpMetrics() {
+ return RestAssured.get("/metrics")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .asString();
+ }
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index b0303c7..a508405 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -127,6 +127,7 @@
<module>mail</module>
<module>master</module>
<module>messaging</module>
+ <module>micrometer</module>
<module>microprofile</module>
<module>mongodb</module>
<module>msv</module>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index f2cfeaa..766477a 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -1361,6 +1361,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-micrometer</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-microprofile-config</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -3922,6 +3927,16 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-micrometer</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-micrometer-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-microprofile-fault-tolerance</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index b0e8ee7..3977600 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -78,6 +78,7 @@ foundation:
- hystrix
- jta
- jsonpath
+ - micrometer
- quartz
- saga
xml-json-olingo4: