This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 77f32b75607 camel-micrometer: Avoid registering app.info gauge
multiple times
77f32b75607 is described below
commit 77f32b756072d2ee9fba80c9e010cd8f575446bd
Author: James Netherton <[email protected]>
AuthorDate: Thu Mar 20 11:46:20 2025 +0000
camel-micrometer: Avoid registering app.info gauge multiple times
---
.../micrometer/json/AbstractMicrometerService.java | 32 ++++++++++++----------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/json/AbstractMicrometerService.java
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/json/AbstractMicrometerService.java
index 6cd8fc88fd5..64093f4914b 100644
---
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/json/AbstractMicrometerService.java
+++
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/json/AbstractMicrometerService.java
@@ -160,22 +160,24 @@ public class AbstractMicrometerService extends
ServiceSupport {
// This method does a best effort attempt to recover information about
versioning of the runtime.
// It is also in charge to include the information in the meterRegistry
passed in.
private void registerAppInfo(MeterRegistry meterRegistry) {
- Optional<RuntimeInfo> rt = RuntimeInfo.quarkus();
- if (!rt.isPresent()) {
- rt = RuntimeInfo.springboot();
- }
- if (!rt.isPresent()) {
- // If not other runtime is available, we assume we're on Camel main
- rt = Optional.of(new RuntimeInfo(RuntimeInfo.MAIN,
getCamelContext().getVersion()));
+ if (meterRegistry.find(APP_INFO_METER_NAME).gauge() == null) {
+ Optional<RuntimeInfo> rt = RuntimeInfo.quarkus();
+ if (!rt.isPresent()) {
+ rt = RuntimeInfo.springboot();
+ }
+ if (!rt.isPresent()) {
+ // If not other runtime is available, we assume we're on Camel
main
+ rt = Optional.of(new RuntimeInfo(RuntimeInfo.MAIN,
getCamelContext().getVersion()));
+ }
+ meterRegistry.gaugeCollectionSize(
+ APP_INFO_METER_NAME,
+ Tags.of(
+ "camel.version", getCamelContext().getVersion(),
+ "camel.context", getCamelContext().getName(),
+ "camel.runtime.provider", rt.get().runtimeProvider,
+ "camel.runtime.version", rt.get().runtimeVersion),
+ new ArrayList<String>());
}
- meterRegistry.gaugeCollectionSize(
- APP_INFO_METER_NAME,
- Tags.of(
- "camel.version", getCamelContext().getVersion(),
- "camel.context", getCamelContext().getName(),
- "camel.runtime.provider", rt.get().runtimeProvider,
- "camel.runtime.version", rt.get().runtimeVersion),
- new ArrayList<String>());
}
private static class RuntimeInfo {