jamesnetherton commented on code in PR #8879: URL: https://github.com/apache/camel-quarkus/pull/8879#discussion_r3620180325
########## extensions/micrometer-observability/runtime/src/main/java/org/apache/camel/quarkus/component/micrometer/observability/MicrometerObservabilityTracerProducer.java: ########## @@ -0,0 +1,93 @@ +/* + * 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.observability; + +import java.util.List; + +import io.micrometer.observation.ObservationHandler; +import io.micrometer.observation.ObservationRegistry; +import io.micrometer.tracing.handler.DefaultTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler; +import io.micrometer.tracing.otel.bridge.OtelBaggageManager; +import io.micrometer.tracing.otel.bridge.OtelCurrentTraceContext; +import io.micrometer.tracing.otel.bridge.OtelPropagator; +import io.micrometer.tracing.otel.bridge.OtelTracer; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.api.trace.Tracer; +import io.quarkus.arc.DefaultBean; +import io.quarkus.opentelemetry.runtime.config.runtime.OTelRuntimeConfig; +import jakarta.enterprise.inject.Produces; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; +import org.apache.camel.CamelContext; +import org.apache.camel.micrometer.observability.MicrometerObservabilityTracer; + +@Singleton +public class MicrometerObservabilityTracerProducer { + + @Inject + CamelMicrometerObservabilityConfig config; + + @Inject + OTelRuntimeConfig oTelRuntimeConfig; + + @Inject + OpenTelemetry openTelemetry; + + @Produces + @Singleton + @DefaultBean + public MicrometerObservabilityTracer getMicrometerObservabilityTracer(CamelContext camelContext) { + if (oTelRuntimeConfig.sdkDisabled()) { + return null; + } + + // Bridge from the Quarkus-provided OpenTelemetry bean to Micrometer Tracing + Tracer nativeOtelTracer = openTelemetry.getTracer("camel"); + OtelCurrentTraceContext currentTraceContext = new OtelCurrentTraceContext(); + OtelTracer otelTracer = new OtelTracer( + nativeOtelTracer, + currentTraceContext, + event -> { + }, + new OtelBaggageManager(currentTraceContext, List.of(), List.of())); + OtelPropagator otelPropagator = new OtelPropagator(openTelemetry.getPropagators(), nativeOtelTracer); + + // Wire up the ObservationRegistry with the standard tracing handlers + ObservationRegistry observationRegistry = ObservationRegistry.create(); + observationRegistry.observationConfig().observationHandler( + new ObservationHandler.FirstMatchingCompositeObservationHandler( + new PropagatingSenderTracingObservationHandler<>(otelTracer, otelPropagator), + new PropagatingReceiverTracingObservationHandler<>(otelTracer, otelPropagator), + new DefaultTracingObservationHandler(otelTracer))); Review Comment: I think this might be redundant. It might be enough to set the tracer and propagator on the `MicrometerObservabilityTracer` and `tracer.init` will end up handling everything. I think with the current state we potentially register duplicate observation handlers. ########## extensions/micrometer-observability/deployment/pom.xml: ########## @@ -0,0 +1,72 @@ +<?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-observability-parent</artifactId> + <version>3.38.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-micrometer-observability-deployment</artifactId> + <name>Camel Quarkus :: Micrometer Observability 2 :: Deployment</name> + + <dependencies> + <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-observability</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-opentelemetry-deployment</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5-internal</artifactId> Review Comment: ```suggestion <artifactId>quarkus-junit-internal</artifactId> ``` ########## extensions/micrometer-observability/runtime/pom.xml: ########## @@ -0,0 +1,110 @@ +<?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-observability-parent</artifactId> + <version>3.38.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-micrometer-observability</artifactId> + <name>Camel Quarkus :: Micrometer Observability 2 :: Runtime</name> + <description>Micrometer Observability implementation of Camel Telemetry</description> + + <properties> + <camel.quarkus.jvmSince>3.38.0</camel.quarkus.jvmSince> + <camel.quarkus.nativeSince>3.38.0</camel.quarkus.nativeSince> + <quarkus.metadata.keywords>monitoring,observability,telemetry,tracing,micrometer</quarkus.metadata.keywords> Review Comment: We don't need to set `quarkus.metadata.keywords`. We abandoned setting specific keywords for extensions a long time ago. ########## poms/build-parent/pom.xml: ########## @@ -44,6 +44,11 @@ <artifactId>assertj-core</artifactId> <version>${assertj.version}</version> </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-tracing-bridge-otel</artifactId> + <version>${micrometer-tracing-version}</version> + </dependency> Review Comment: This should be removed from build-parent. ########## poms/bom/pom.xml: ########## @@ -2311,6 +2311,16 @@ <artifactId>camel-micrometer</artifactId> <version>${camel.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-micrometer-observability</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-tracing-bridge-otel</artifactId> + <version>${micrometer-tracing-version}</version> + </dependency> Review Comment: 1. The dependency should be listed further down with the other third-party deps 2. The version property naming convention is `<artifactId>.version` 3. If `micrometer-tracing-bridge-otel` is not part of `micrometer-bom`, you'll need to add an `micrometer-tracing-bridge-otel.version` property to the root pom.xml and use an `@sync` comment to keep it aligned to the Micrometer version used by Quarkus ```suggestion <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-tracing-bridge-otel</artifactId> <version>${micrometer-tracing-bridge-otel.version}</version> </dependency> ``` ########## integration-tests/micrometer-observability/pom.xml: ########## @@ -0,0 +1,142 @@ +<?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-it</artifactId> + <version>3.38.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent-it/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-micrometer-observability</artifactId> + <name>Camel Quarkus :: Integration Tests :: Micrometer Observability 2</name> + <description>Integration tests for Camel Quarkus Micrometer Observability 2 extension</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-micrometer-observability</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-rest</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-rest-jackson</artifactId> + </dependency> + <dependency> + <groupId>io.opentelemetry</groupId> + <artifactId>opentelemetry-sdk-testing</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> Review Comment: ```suggestion <artifactId>quarkus-junit</artifactId> ``` ########## poms/bom-test/pom.xml: ########## @@ -88,6 +88,11 @@ <artifactId>langchain4j-web-search-engine-tavily</artifactId> <version>${langchain4j-beta.version}</version> </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-tracing-test</artifactId> + <version>${micrometer-tracing-version}</version> + </dependency> Review Comment: Can be removed now I think. -- 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]
