You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/03/18 11:07:35 UTC
[camel-spring-boot] branch camel-spring-boot-3.20.x updated: CAMEL-19136: camel-micrometer-starter - Turn of metrics with uri tag by default as it can lead to too many tags due to dynamic values.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-spring-boot-3.20.x
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/camel-spring-boot-3.20.x by this push:
new 304bf9f01c5 CAMEL-19136: camel-micrometer-starter - Turn of metrics with uri tag by default as it can lead to too many tags due to dynamic values.
304bf9f01c5 is described below
commit 304bf9f01c57ae1238d28ef3185e1279fe81a8ed
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Mar 18 11:52:15 2023 +0100
CAMEL-19136: camel-micrometer-starter - Turn of metrics with uri tag by default as it can lead to too many tags due to dynamic values.
---
.../src/main/docs/micrometer.json | 7 +++++++
.../springboot/MicrometerTagsAutoConfiguration.java | 2 ++
.../springboot/metrics/CamelMetricsConfiguration.java | 18 ++++++++++++++++++
3 files changed, 27 insertions(+)
diff --git a/components-starter/camel-micrometer-starter/src/main/docs/micrometer.json b/components-starter/camel-micrometer-starter/src/main/docs/micrometer.json
index e6c174b84c0..61705f360d1 100644
--- a/components-starter/camel-micrometer-starter/src/main/docs/micrometer.json
+++ b/components-starter/camel-micrometer-starter/src/main/docs/micrometer.json
@@ -76,6 +76,13 @@
"description": "Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics on route processing times.",
"sourceType": "org.apache.camel.component.micrometer.springboot.metrics.CamelMetricsConfiguration",
"defaultValue": true
+ },
+ {
+ "name": "camel.metrics.uri-tag-expand-values",
+ "type": "java.lang.Boolean",
+ "description": "Whether HTTP uri tags should be expanded or not. For example a REST service defined with base URL: \/users\/{id} will capture metrics with uri tag: \/users\/{id}. There can be some use-cases where you want to expand the URI tag to include the actual requested value instead, so the uri tag will be something like: \/users\/123 However this can lead to many tags as the URI is dynamic, so use this with care.",
+ "sourceType": "org.apache.camel.component.micrometer.springboot.metrics.CamelMetricsConfiguration",
+ "defaultValue": false
}
],
"hints": []
diff --git a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerTagsAutoConfiguration.java b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerTagsAutoConfiguration.java
index a517dab7bd5..8224a83ea72 100644
--- a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerTagsAutoConfiguration.java
+++ b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerTagsAutoConfiguration.java
@@ -23,6 +23,7 @@ import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigu
import org.springframework.boot.actuate.metrics.web.servlet.DefaultWebMvcTagsProvider;
import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsProvider;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
@@ -32,6 +33,7 @@ import javax.servlet.http.HttpServletResponse;
@Configuration(proxyBeanMethods = false)
@Conditional(ConditionalOnCamelContextAndAutoConfigurationBeans.class)
+@ConditionalOnProperty(prefix = "camel.metrics", name = "uriTagEnabled", havingValue = "true")
@AutoConfigureAfter({CamelAutoConfiguration.class})
public class MicrometerTagsAutoConfiguration {
diff --git a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsConfiguration.java b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsConfiguration.java
index 5bdeae53ab0..ed048170b3d 100644
--- a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsConfiguration.java
+++ b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/metrics/CamelMetricsConfiguration.java
@@ -21,6 +21,16 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "camel.metrics")
public class CamelMetricsConfiguration {
+ /**
+ * Whether HTTP uri tags should be expanded or not. For example a REST service defined with
+ * base URL: /users/{id} will capture metrics with uri tag: /users/{id}.
+ *
+ * There can be some use-cases where you want to expand the URI tag to include the actual requested value instead,
+ * so the uri tag will be something like: /users/123
+ * However this can lead to many tags as the URI is dynamic, so use this with care.
+ */
+ private boolean uriTagExpandValues;
+
/**
* Set whether to enable the MicrometerRoutePolicyFactory for capturing metrics
* on route processing times.
@@ -48,6 +58,14 @@ public class CamelMetricsConfiguration {
*/
private boolean enableRouteEventNotifier = true;
+ public boolean isUriTagExpandValues() {
+ return uriTagExpandValues;
+ }
+
+ public void setUriTagExpandValues(boolean uriTagExpandValues) {
+ this.uriTagExpandValues = uriTagExpandValues;
+ }
+
public boolean isEnableRoutePolicy() {
return enableRoutePolicy;
}