davsclaus commented on code in PR #30220:
URL: https://github.com/apache/camel/pull/30220#discussion_r4588424053


##########
components/camel-opentelemetry-metrics/src/test/java/org/apache/camel/opentelemetry/metrics/routepolicy/OpenTelemetryAndMicrometerRoutePolicyTest.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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 io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Timer;
+import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
+import io.opentelemetry.sdk.metrics.data.HistogramPointData;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.micrometer.MicrometerConstants;
+import 
org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.opentelemetry.metrics.AbstractOpenTelemetryTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static 
org.apache.camel.opentelemetry.metrics.OpenTelemetryConstants.DEFAULT_CAMEL_ROUTE_POLICY_METER_NAME;
+import static org.junit.jupiter.api.Assertions.assertAll;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * Verifies that the OpenTelemetry and the Micrometer route policies both 
measure a route they share.
+ */
+public class OpenTelemetryAndMicrometerRoutePolicyTest extends 
AbstractOpenTelemetryTestSupport {
+
+    private final MeterRegistry meterRegistry = new SimpleMeterRegistry();
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        MicrometerRoutePolicyFactory micrometerFactory = new 
MicrometerRoutePolicyFactory();
+        micrometerFactory.setMeterRegistry(meterRegistry);
+        context.addRoutePolicyFactory(micrometerFactory);

Review Comment:
   [Suggestion] This order follows Camel Main, with Micrometer first. With OTel 
first, the cast fails the other way round (`Timer$Sample` cannot be cast to 
`TaskTimer`), and no test covers it. A small subclass that adds the OTel 
factory first (or a shared base with an order flag) would keep both directions 
covered.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to