This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 e6b7933df4b7 CAMEL-16866 add context-metrics to route-policy (#19932)
e6b7933df4b7 is described below
commit e6b7933df4b7aa9a5f4ec6ead7f53286cfda5cf0
Author: Jono Morris <[email protected]>
AuthorDate: Sun Nov 16 04:53:48 2025 +1300
CAMEL-16866 add context-metrics to route-policy (#19932)
---
.../OpenTelemetryContextMetricsStatistics.java | 72 ++++++++++++++
.../routepolicy/OpenTelemetryRoutePolicy.java | 14 +++
.../OpenTelemetryRoutePolicyConfiguration.java | 12 +++
.../OpenTelemetryRoutePolicyFactory.java | 10 ++
.../AbstractOpenTelemetryRoutePolicyTest.java | 1 +
.../OpenTelemetryContextOnlyPolicyTest.java | 98 ++++++++++++++++++++
.../OpenTelemetryContextPolicyTest.java | 103 +++++++++++++++++++++
...OpenTelemetryRoutePolicyExcludePatternTest.java | 1 +
.../routepolicy/OpenTelemetryRoutePolicyTest.java | 1 +
9 files changed, 312 insertions(+)
diff --git
a/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryContextMetricsStatistics.java
b/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryContextMetricsStatistics.java
new file mode 100644
index 000000000000..206183707e36
--- /dev/null
+++
b/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryContextMetricsStatistics.java
@@ -0,0 +1,72 @@
+/*
+ * 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.opentelemetry.metrics.routepolicy;
+
+import java.util.concurrent.TimeUnit;
+
+import io.opentelemetry.api.metrics.Meter;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.UnitOfWork;
+
+final class OpenTelemetryContextMetricsStatistics extends
OpenTelemetryRoutePolicy.MetricsStatistics {
+
+ private final boolean registerKamelets;
+ private final boolean registerTemplates;
+
+ OpenTelemetryContextMetricsStatistics(Meter meter, CamelContext
camelContext,
+
OpenTelemetryRoutePolicyNamingStrategy namingStrategy,
+
OpenTelemetryRoutePolicyConfiguration configuration,
+ boolean registerKamelets, boolean
registerTemplates,
+ TimeUnit timeUnit) {
+ super(meter, camelContext, null, namingStrategy, configuration,
timeUnit);
+ this.registerKamelets = registerKamelets;
+ this.registerTemplates = registerTemplates;
+ }
+
+ @Override
+ public void onExchangeBegin(Exchange exchange) {
+ // this metric is triggered for every route so we must only trigger on
the root level,
+ // otherwise this metric total counter will be incorrect. For example
if an exchange is
+ // routed via 3 routes we should only count this as 1 instead of 3.
+ UnitOfWork uow = exchange.getUnitOfWork();
+ if (uow != null) {
+ int level = uow.routeStackLevel(registerTemplates,
registerKamelets);
+ if (level <= 1) {
+ super.onExchangeBegin(exchange);
+ }
+ } else {
+ super.onExchangeBegin(exchange);
+ }
+ }
+
+ @Override
+ public void onExchangeDone(Exchange exchange) {
+ // this metric is triggered for every route so we must only trigger on
the root level,
+ // otherwise this metric total counter will be incorrect. For example
if an exchange is
+ // routed via 3 routes we should only count this as 1 instead of 3.
+ UnitOfWork uow = exchange.getUnitOfWork();
+ if (uow != null) {
+ int level = uow.routeStackLevel(registerTemplates,
registerKamelets);
+ if (level <= 1) {
+ super.onExchangeDone(exchange);
+ }
+ } else {
+ super.onExchangeDone(exchange);
+ }
+ }
+}
diff --git
a/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicy.java
b/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicy.java
index c404bec04585..6a4a4f575e95 100644
---
a/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicy.java
+++
b/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicy.java
@@ -62,10 +62,14 @@ public class OpenTelemetryRoutePolicy extends
RoutePolicySupport implements NonM
boolean registerKamelets;
boolean registerTemplates = true;
+ // options
private OpenTelemetryRoutePolicyNamingStrategy namingStrategy =
OpenTelemetryRoutePolicyNamingStrategy.DEFAULT;
private OpenTelemetryRoutePolicyConfiguration configuration = new
OpenTelemetryRoutePolicyConfiguration();
private TimeUnit timeUnit = TimeUnit.MILLISECONDS;
+
+ // metrics
private final Map<Route, MetricsStatistics> statisticsMap = new
HashMap<>();
+ private RouteMetric contextStatistic;
public OpenTelemetryRoutePolicy(OpenTelemetryRoutePolicyFactory factory) {
this.factory = factory;
@@ -129,6 +133,10 @@ public class OpenTelemetryRoutePolicy extends
RoutePolicySupport implements NonM
registerKamelets =
ms.getManagementAgent().getRegisterRoutesCreateByKamelet();
registerTemplates =
ms.getManagementAgent().getRegisterRoutesCreateByTemplate();
}
+
+ if (factory != null && configuration.isContextEnabled() &&
contextStatistic == null) {
+ contextStatistic = factory.createOrGetContextMetric(this);
+ }
}
@Override
@@ -162,12 +170,18 @@ public class OpenTelemetryRoutePolicy extends
RoutePolicySupport implements NonM
@Override
public void onExchangeBegin(Route route, Exchange exchange) {
+ if (contextStatistic != null) {
+ contextStatistic.onExchangeBegin(exchange);
+ }
Optional.ofNullable(statisticsMap.get(route))
.ifPresent(statistics -> statistics.onExchangeBegin(exchange));
}
@Override
public void onExchangeDone(Route route, Exchange exchange) {
+ if (contextStatistic != null) {
+ contextStatistic.onExchangeDone(exchange);
+ }
Optional.ofNullable(statisticsMap.get(route))
.ifPresent(statistics -> statistics.onExchangeDone(exchange));
}
diff --git
a/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyConfiguration.java
b/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyConfiguration.java
index 7ae0d4c33786..039331be07ab 100644
---
a/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyConfiguration.java
+++
b/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyConfiguration.java
@@ -21,6 +21,7 @@ package org.apache.camel.opentelemetry.metrics.routepolicy;
*/
public class OpenTelemetryRoutePolicyConfiguration {
+ private boolean contextEnabled = true;
private boolean routeEnabled = true;
private String excludePattern;
private boolean additionalCounters = true;
@@ -30,6 +31,17 @@ public class OpenTelemetryRoutePolicyConfiguration {
private boolean externalRedeliveries = true;
private boolean failuresHandled = true;
+ public boolean isContextEnabled() {
+ return contextEnabled;
+ }
+
+ /**
+ * Enable context level metric collection.
+ */
+ public void setContextEnabled(boolean contextEnabled) {
+ this.contextEnabled = contextEnabled;
+ }
+
public boolean isRouteEnabled() {
return routeEnabled;
}
diff --git
a/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyFactory.java
b/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyFactory.java
index f451f5785b06..c31b11335a49 100644
---
a/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyFactory.java
+++
b/components/camel-opentelemetry-metrics/src/main/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyFactory.java
@@ -83,6 +83,16 @@ public class OpenTelemetryRoutePolicyFactory extends
ServiceSupport
this.timeUnit = timeUnit;
}
+ public synchronized RouteMetric
createOrGetContextMetric(OpenTelemetryRoutePolicy policy) {
+ if (contextMetric == null) {
+ contextMetric = new OpenTelemetryContextMetricsStatistics(
+ meter, camelContext, policy.getNamingStrategy(),
policy.getConfiguration(),
+ policy.isRegisterKamelets(), policy.isRegisterTemplates(),
+ policy.getTimeUnit());
+ }
+ return contextMetric;
+ }
+
@Override
public RoutePolicy createRoutePolicy(CamelContext camelContext, String
routeId, NamedNode routeDefinition) {
OpenTelemetryRoutePolicy routePolicy = new
OpenTelemetryRoutePolicy(this);
diff --git
a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/AbstractOpenTelemetryRoutePolicyTest.java
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/AbstractOpenTelemetryRoutePolicyTest.java
index 2ef5734487d5..140aaaf51d5e 100644
---
a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/AbstractOpenTelemetryRoutePolicyTest.java
+++
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/AbstractOpenTelemetryRoutePolicyTest.java
@@ -23,6 +23,7 @@ public abstract class AbstractOpenTelemetryRoutePolicyTest
extends AbstractOpenT
protected OpenTelemetryRoutePolicyFactory
createOpenTelemetryRoutePolicyFactory() {
OpenTelemetryRoutePolicyFactory factory = new
OpenTelemetryRoutePolicyFactory();
+ factory.getPolicyConfiguration().setContextEnabled(false);
factory.getPolicyConfiguration().setExcludePattern(null);
return factory;
}
diff --git
a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryContextOnlyPolicyTest.java
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryContextOnlyPolicyTest.java
new file mode 100644
index 000000000000..4ca4942aa403
--- /dev/null
+++
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryContextOnlyPolicyTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.opentelemetry.metrics.routepolicy;
+
+import java.util.List;
+
+import io.opentelemetry.sdk.metrics.data.HistogramPointData;
+import io.opentelemetry.sdk.metrics.data.PointData;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static io.opentelemetry.api.common.AttributeKey.stringKey;
+import static
org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.DEFAULT_CAMEL_ROUTE_POLICY_METER_NAME;
+import static
org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.EVENT_TYPE_ATTRIBUTE;
+import static
org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.KIND_ATTRIBUTE;
+import static
org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.ROUTE_ID_ATTRIBUTE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Verifies that there are only context point data when only context metrics
are enabled.
+ */
+public class OpenTelemetryContextOnlyPolicyTest extends
AbstractOpenTelemetryRoutePolicyTest {
+
+ private static final long DELAY_FOO = 20;
+ private static final long DELAY_BAR = 50;
+ private static final long TOLERANCE = 20L;
+
+ @Override
+ public OpenTelemetryRoutePolicyFactory
createOpenTelemetryRoutePolicyFactory() {
+ OpenTelemetryRoutePolicyFactory factory = new
OpenTelemetryRoutePolicyFactory();
+ factory.getPolicyConfiguration().setContextEnabled(true);
+ factory.getPolicyConfiguration().setRouteEnabled(false);
+ return factory;
+ }
+
+ @Test
+ public void testMetricsRoutePolicy() throws Exception {
+ int count = 10;
+ MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
+ mockEndpoint.expectedMessageCount(count);
+ for (int i = 0; i < count; i++) {
+ if (i % 2 == 0) {
+ template.sendBody("direct:foo", "Hello " + i);
+ } else {
+ template.sendBody("direct:bar", "Hello " + i);
+ }
+ }
+ MockEndpoint.assertIsSatisfied(context);
+
+ // metrics for context only
+ List<PointData> pointDataList =
getAllPointData(DEFAULT_CAMEL_ROUTE_POLICY_METER_NAME);
+ assertEquals(1, pointDataList.size());
+
+ PointData pd = pointDataList.get(0);
+ assertEquals("",
pd.getAttributes().get(stringKey(ROUTE_ID_ATTRIBUTE)));
+ assertEquals("CamelRoute",
pd.getAttributes().get(stringKey(KIND_ATTRIBUTE)));
+ assertEquals("context",
pd.getAttributes().get(stringKey(EVENT_TYPE_ATTRIBUTE)));
+
+ assertInstanceOf(HistogramPointData.class, pd);
+ HistogramPointData hpd = (HistogramPointData) pd;
+ assertTrue(hpd.getMax() < DELAY_BAR + TOLERANCE);
+ assertTrue(hpd.getMin() >= DELAY_FOO);
+ assertEquals(count, hpd.getCount());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:foo").routeId("foo")
+ .delay(DELAY_FOO)
+ .to("mock:result");
+
+ from("direct:bar").routeId("bar")
+ .delay(DELAY_BAR)
+ .to("mock:result");
+ }
+ };
+ }
+}
diff --git
a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryContextPolicyTest.java
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryContextPolicyTest.java
new file mode 100644
index 000000000000..3cc63c141f57
--- /dev/null
+++
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryContextPolicyTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.opentelemetry.metrics.routepolicy;
+
+import java.util.List;
+
+import io.opentelemetry.sdk.metrics.data.HistogramPointData;
+import io.opentelemetry.sdk.metrics.data.PointData;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Test;
+
+import static io.opentelemetry.api.common.AttributeKey.stringKey;
+import static
org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.DEFAULT_CAMEL_ROUTE_POLICY_METER_NAME;
+import static
org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.EVENT_TYPE_ATTRIBUTE;
+import static
org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.KIND_ATTRIBUTE;
+import static
org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.ROUTE_ID_ATTRIBUTE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class OpenTelemetryContextPolicyTest extends
AbstractOpenTelemetryRoutePolicyTest {
+
+ private static final long DELAY_FOO = 20L;
+ private static final long DELAY_BAR = 50L;
+ private static final long TOLERANCE = 20L;
+
+ @Override
+ public OpenTelemetryRoutePolicyFactory
createOpenTelemetryRoutePolicyFactory() {
+ OpenTelemetryRoutePolicyFactory factory = new
OpenTelemetryRoutePolicyFactory();
+ factory.getPolicyConfiguration().setContextEnabled(true);
+ return factory;
+ }
+
+ @Test
+ public void testMetricsRoutePolicy() throws Exception {
+ int count = 10;
+ MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
+ mockEndpoint.expectedMessageCount(count);
+
+ for (int i = 0; i < count; i++) {
+ if (i % 2 == 0) {
+ template.sendBody("direct:foo", "Hello " + i);
+ } else {
+ template.sendBody("direct:bar", "Hello " + i);
+ }
+ }
+ MockEndpoint.assertIsSatisfied(context);
+
+ // metrics for routes
+ verifyMetricForRouteId("foo", DELAY_FOO, DELAY_FOO + TOLERANCE, count
/ 2);
+ verifyMetricForRouteId("bar", DELAY_BAR, DELAY_BAR + TOLERANCE, count
/ 2);
+
+ // metric for context, min and max delay of all routes
+ verifyMetricForRouteId("", DELAY_FOO, DELAY_BAR + TOLERANCE, count);
+ }
+
+ private void verifyMetricForRouteId(String routeId, long minDelay, long
maxDelay, int count) {
+ List<PointData> pdList =
getAllPointDataForRouteId(DEFAULT_CAMEL_ROUTE_POLICY_METER_NAME, routeId);
+ assertEquals(1, pdList.size());
+
+ PointData pd = pdList.get(0);
+ assertEquals(routeId,
pd.getAttributes().get(stringKey(ROUTE_ID_ATTRIBUTE)));
+ assertEquals("CamelRoute",
pd.getAttributes().get(stringKey(KIND_ATTRIBUTE)));
+ assertEquals("".equals(routeId) ? "context" : "route",
pd.getAttributes().get(stringKey(EVENT_TYPE_ATTRIBUTE)));
+
+ assertInstanceOf(HistogramPointData.class, pd);
+ HistogramPointData hpd = (HistogramPointData) pd;
+ assertTrue(hpd.getMax() < maxDelay);
+ assertTrue(hpd.getMin() >= minDelay);
+ assertEquals(count, hpd.getCount());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:foo").routeId("foo")
+ .delay(DELAY_FOO)
+ .to("mock:result");
+
+ from("direct:bar").routeId("bar")
+ .delay(DELAY_BAR)
+ .to("mock:result");
+ }
+ };
+ }
+}
diff --git
a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyExcludePatternTest.java
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyExcludePatternTest.java
index ffaac5fa7dcb..4f328784669a 100644
---
a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyExcludePatternTest.java
+++
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyExcludePatternTest.java
@@ -33,6 +33,7 @@ public class OpenTelemetryRoutePolicyExcludePatternTest
extends AbstractOpenTele
@Override
public OpenTelemetryRoutePolicyFactory
createOpenTelemetryRoutePolicyFactory() {
OpenTelemetryRoutePolicyFactory factory = new
OpenTelemetryRoutePolicyFactory();
+ factory.getPolicyConfiguration().setContextEnabled(false);
factory.getPolicyConfiguration().setRouteEnabled(true);
factory.getPolicyConfiguration().setExcludePattern("bar");
return factory;
diff --git
a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyTest.java
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyTest.java
index 708eed5e9471..21e93622a35c 100644
---
a/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyTest.java
+++
b/components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryRoutePolicyTest.java
@@ -39,6 +39,7 @@ public class OpenTelemetryRoutePolicyTest extends
AbstractOpenTelemetryRoutePoli
@Override
public OpenTelemetryRoutePolicyFactory
createOpenTelemetryRoutePolicyFactory() {
OpenTelemetryRoutePolicyFactory factory = new
OpenTelemetryRoutePolicyFactory();
+ factory.getPolicyConfiguration().setContextEnabled(false);
factory.getPolicyConfiguration().setExcludePattern(null);
factory.getPolicyConfiguration().setAdditionalCounters(false);
return factory;