You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by "marcingrzejszczak (via GitHub)" <gi...@apache.org> on 2023/07/19 12:02:44 UTC
[GitHub] [cxf] marcingrzejszczak opened a new pull request, #1346: Micrometer Observation
marcingrzejszczak opened a new pull request, #1346:
URL: https://github.com/apache/cxf/pull/1346
This PR adds support for Micrometer Observation instrumentation of Apache CXF.
NOTE: This PR is heavily influenced by Brave's implementation.
Dependencies
- Adds micrometer tracing
- Adds zipkin sender
CXF metrics project
- Now also does tracing (TODO: maybe this should be done in a separate module?)
- Adds dependency on `rt-management` since metrics will now also be related to tracing
- Adds dependency to Micrometer Observation
- Is a copy of the Brave Tracing module but adopted to Micrometer Observation API
- Uses low and high cardinality tags basing on OpenTelemetry Semantic Conventions for RPC and HTTP (JaxRs) from 19.07.2023. VERY IMPORTANT: This doesn't mean that this project is OTel Semantic Convention compliant!!!
- Uses `ObservationDocumentation` that using https://micrometer.io/docs/observation#_documentation_generation could generate asciidoctor documentation of observability data
Spring Boot
- adds `MicrometerObservationAutoConfiguration` that registers `Feature`s as beans
Tests
- reused existing Brave tests with Micrometer Observation, altered existing tagging and naming defaults to make the test pass with Brave tagging and naming defaults
- reused existing Boot tests to additionally assert observation based metrics and traces
TODO ? :
- maybe the code shouldn't be in CXF metrics module but a completely separate one?
- add Javadocs?
- add documentation - where should it be added?
Fixes https://issues.apache.org/jira/browse/CXF-8817
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1288373654
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
Thanks @marcingrzejszczak , if supporting beans are optional, I think we don't need this configuration at all, the `CxfAutoConfiguration` would take care of that (these features also *MAY BE* provided by the user).
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1288429930
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
In general if you have `actuator` on the classpath then you have the `ObservationRegistry` bean present. There's a dedicated autoconfiguration for creating the `ObservationRegistry` that comes with Spring Boot.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1289858662
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
I tried removing the autoconfiguration but from what I see the `AbstractSpringComponentScanServer` is trying to call a default constructor that the `ObservationProvider` or `ObservationClientProvider` just don't have. I wonder if it makes sense to have providers that have a non default constructor :shrug:
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on PR #1346:
URL: https://github.com/apache/cxf/pull/1346#issuecomment-1671127939
Hey @reta . I've applied all the suggestions and rebased the branch against `main`. Anything else you would like me to do?
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1272916197
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
I am unsure about this particular auto configuration, it conflicts with the way CXF uses scans, either by components or classes (coming from CxfAutoConfiguration).
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1292806238
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabiityTest.java:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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.cxf.systest.jaxrs.spring.boot;
+
+import java.time.Duration;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import brave.sampler.Sampler;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.systest.ArrayListSpanReporter;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import zipkin2.Span;
+import zipkin2.reporter.Reporter;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.tck.MeterRegistryAssert;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.Span.Kind;
+import io.micrometer.tracing.test.simple.SpansAssert;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.hasSize;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsObservabiityTest.TestConfig.class)
+@ActiveProfiles("jaxrs")
+@AutoConfigureObservability
+public class SpringJaxrsObservabiityTest {
+
+ @Autowired
+ private MeterRegistry registry;
+
+ @Autowired
+ private ObservationRegistry observationRegistry;
+
+ @Autowired
+ private ArrayListSpanReporter arrayListSpanReporter;
+
+ @LocalServerPort
+ private int port;
+
+ @EnableAutoConfiguration(exclude = WebMvcObservationAutoConfiguration.class)
+ @ComponentScan(basePackageClasses = Library.class)
+ static class TestConfig {
+ @Bean
+ public Feature observationFeature(ObservationRegistry observationRegistry) {
+ return new ObservationFeature(observationRegistry);
+ }
+
+ @Bean
+ public JacksonJsonProvider jacksonJsonProvider() {
+ return new JacksonJsonProvider();
+ }
+
+ @Bean
+ Sampler sampler() {
+ return Sampler.ALWAYS_SAMPLE;
+ }
+
+ @Bean
+ ArrayListSpanReporter arrayListSpanReporter() {
+ return new ArrayListSpanReporter();
+ }
+
+ @Bean
+ Reporter<Span> reporter() {
+ return Reporter.CONSOLE;
+ }
+ }
+
+ @Autowired
+ public void setBus(Bus bus) {
+ // By default, the exception are propagated and out fault interceptors are not called
+ bus.setProperty("org.apache.cxf.propagate.exception", Boolean.FALSE);
+ }
+
+ @AfterEach
+ public void clear() {
+ registry.clear();
+ arrayListSpanReporter.close();
+ }
+
+ @Test
+ public void testJaxrsSuccessMetric() {
+ final WebTarget target = createWebTarget();
+
+ try (Response r = target.request().get()) {
+ assertThat(r.getStatus()).isEqualTo(200);
+ }
+
+ await()
+ .atMost(Duration.ofSeconds(1))
+ .until(() -> arrayListSpanReporter.getSpans(), hasSize(2));
+
+ // Micrometer Observation with Micrometer Tracing
+ SpansAssert.assertThat(arrayListSpanReporter.getSpans())
+ .haveSameTraceId()
+ .hasASpanWithName("GET", spanAssert -> {
+ spanAssert.hasKindEqualTo(Kind.CLIENT)
+ .hasTag("rpc.service", "WebClient")
+ .hasTag("rpc.system", "cxf")
+ .hasTagWithKey("server.address")
+ .hasTagWithKey("server.port")
+ .isStarted()
+ .isEnded();
+ })
+ .hasASpanWithName("rpc.server.duration", spanAssert -> {
Review Comment:
Should be all set, the JAX-RS HTTP instrumentations works pretty well (shouldn't be using the RPC one)
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1291747079
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
> added more test cases for Spring Boot (and here was confused, asking for your help)
I've replied to the comment
> Hope you have no objections, thank you.
Oh absolutely not, I'm just the guest here :) Do all the changes that you think make sense!
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1289966094
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
OK I gave it another thought and I don't see any difference between `MicrometerMetricsProvider` which is defined as a Spring bean and `ObservationProvider` or `ObservationClientProvider`. Trying to change the existing code to allow construction injection is not enough for all test to pass. I would leave the current auto-configuration cause that prepares the providers the way they should be set up given that the ObservationRegistry is on the classpath. From my perspective this PR is ready.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1290854141
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabiityTest.java:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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.cxf.systest.jaxrs.spring.boot;
+
+import java.time.Duration;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import brave.sampler.Sampler;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.systest.ArrayListSpanReporter;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import zipkin2.Span;
+import zipkin2.reporter.Reporter;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.tck.MeterRegistryAssert;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.Span.Kind;
+import io.micrometer.tracing.test.simple.SpansAssert;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.hasSize;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsObservabiityTest.TestConfig.class)
+@ActiveProfiles("jaxrs")
+@AutoConfigureObservability
+public class SpringJaxrsObservabiityTest {
+
+ @Autowired
+ private MeterRegistry registry;
+
+ @Autowired
+ private ObservationRegistry observationRegistry;
+
+ @Autowired
+ private ArrayListSpanReporter arrayListSpanReporter;
+
+ @LocalServerPort
+ private int port;
+
+ @EnableAutoConfiguration(exclude = WebMvcObservationAutoConfiguration.class)
Review Comment:
For JAX-RS (aka WebMvc :D), the most common scenario would be to have HTTP traces but I have not found the way to trade `rpc` for `http`, without `WebMvcObservationAutoConfiguration` I do have both on server side, could you help me please to understand the proper configuration?
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1272916197
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
I am unsure about this particular auto configuration, it conflicts with the way CXF uses scans, either by components or classes (coming from CxfAutoConfiguration).
The way we approach that (which is not necessarily the best one) is to pre-create all needed beans (like in this case, `MessageInObservationConvention` and `MessageOutObservationConvention`) so the feature could be constructed.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on PR #1346:
URL: https://github.com/apache/cxf/pull/1346#issuecomment-1646948998
Thanks a lot for the pull request @marcingrzejszczak !
> Now also does tracing (TODO: maybe this should be done in a separate module?)
This is the way CXF structures the integrations: the tracing is separated from metrics (integration/tracing). Could you please split them into separate modules? Thank you.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on PR #1346:
URL: https://github.com/apache/cxf/pull/1346#issuecomment-1647997817
@reta I've moved the Micrometer Observation integration under the tracing folder. The integration allows you to actually not have tracing at all and in essence is tracing agnostic, however for the sake of consistency I put it under the tracing folder
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1291746155
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabiityTest.java:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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.cxf.systest.jaxrs.spring.boot;
+
+import java.time.Duration;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import brave.sampler.Sampler;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.systest.ArrayListSpanReporter;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import zipkin2.Span;
+import zipkin2.reporter.Reporter;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.tck.MeterRegistryAssert;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.Span.Kind;
+import io.micrometer.tracing.test.simple.SpansAssert;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.hasSize;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsObservabiityTest.TestConfig.class)
+@ActiveProfiles("jaxrs")
+@AutoConfigureObservability
+public class SpringJaxrsObservabiityTest {
+
+ @Autowired
+ private MeterRegistry registry;
+
+ @Autowired
+ private ObservationRegistry observationRegistry;
+
+ @Autowired
+ private ArrayListSpanReporter arrayListSpanReporter;
+
+ @LocalServerPort
+ private int port;
+
+ @EnableAutoConfiguration(exclude = WebMvcObservationAutoConfiguration.class)
+ @ComponentScan(basePackageClasses = Library.class)
+ static class TestConfig {
+ @Bean
+ public Feature observationFeature(ObservationRegistry observationRegistry) {
Review Comment:
> the MicrometerObservationAutoConfiguration is removed (the features are created manually now but I will take care of it)
I haven't noticed this messed from you so disregard the comment
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1272914333
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsComponentScanningTest.java:
##########
@@ -51,8 +52,8 @@ public void testCxfComponentScan() {
// The component scanner only looks for CXF's @Provider annotations,
// not JAX-RS Features/@Provider.
assertThat(scanner.getFeatures())
- .hasSize(2)
- .hasOnlyElementsOfTypes(OpenApiFeature.class, JAXRSBeanValidationFeature.class);
+ .hasSize(3)
+ .hasOnlyElementsOfTypes(ObservationFeature.class, OpenApiFeature.class, OpenApiFeature.class, JAXRSBeanValidationFeature.class);
Review Comment:
Seems like `OpenApiFeature.class` is included twice:
```suggestion
.hasOnlyElementsOfTypes(ObservationFeature.class, OpenApiFeature.class, JAXRSBeanValidationFeature.class);
```
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1289999052
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
> Trying to change the existing code to allow construction injection is not enough for all test to pass.
Thanks @marcingrzejszczak , do you mind if I push this specific change? Thank you.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1288393444
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
Yes, there are 2 way it works (managed by property):
- scanning classpath and extracting JAX-RS annotated classes (done by https://github.com/apache/cxf/blob/main/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractJaxrsClassesScanServer.java)
- scanning Spring components (done by https://github.com/apache/cxf/blob/main/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java)
Depending on that, the bean instances (including features) will be fed into the JAX-RS server factory.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1288426888
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
Correct, that is why I was suggesting to have pre-created all needed beans (guarded by @ConditionalOnMissingBean, `ObservationRegistry` falls into this category) in this auto configuration if there are chances in may not be present. But if you think it is redundant, the configuration could be removed.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta merged pull request #1346: CXF-8817: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta merged PR #1346:
URL: https://github.com/apache/cxf/pull/1346
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1288426888
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
Correct, that is why I was suggesting to have pre-created all needed beans (guarded by @ConditionalOnMissingBean, `ObservationRegistry` falls into this category) in this auto configuration (if there are chances in may not be present. But you think it is redundant, the configuration could be removed.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1290014179
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
Oh be my guest :)
What I did is I modified the `JAXRSServerFactoryBeanDefinitionParser` to have its last static method to fallback to constructor autowiring.
```java
static List<Object> createBeansFromDiscoveredClasses(ApplicationContext context,
Collection<Class<?>> classes,
Class<? extends Annotation> serviceClassAnnotation) {
AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
final List< Object > providers = new ArrayList<>();
for (final Class< ? > clazz: classes) {
if (serviceClassAnnotation != null && clazz.getAnnotation(serviceClassAnnotation) == null) {
continue;
}
Object bean;
try {
bean = beanFactory.createBean(clazz, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);
} catch (Exception ex) {
String stackTrace = ExceptionUtils.getStackTrace(ex);
LOG.fine("Autowire failure for a " + clazz.getName() + " bean: " + stackTrace);
try {
bean = beanFactory.createBean(clazz);
} catch (Exception ex2) {
// Fallback to constructor based injection
String stackTrace2 = ExceptionUtils.getStackTrace(ex2);
LOG.fine("Bean creation failure for a " + clazz.getName() + " bean: " + stackTrace2);
GenericBeanDefinition definition = new GenericBeanDefinition();
definition.setBeanClass(clazz);
definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR);
String name = clazz.getName() + "_" + System.currentTimeMillis();
((BeanDefinitionRegistry) context).registerBeanDefinition(name, definition);
bean = context.getBean(name);
}
}
providers.add(bean);
}
return providers;
}
```
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1289929046
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
I will modify the component scanning logic to allow trying to autowire by constructor. That way if you have a provider that has constructors Spring will try to autowire using it
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1290853155
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
@marcingrzejszczak pushed my changes
- the `MicrometerObservationAutoConfiguration` is removed (the features are created manually now but I will take care of it)
- refactored a bit test cases for systests/tracing (to separate Brave and Micrometer)
- added more test cases for Spring Boot (and here was confused, asking for your help)
Hope you have no objections, thank you.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on PR #1346:
URL: https://github.com/apache/cxf/pull/1346#issuecomment-1648268644
> @reta I've moved the Micrometer Observation integration under the tracing folder. The integration allows you to actually not have tracing at all and in essence is tracing agnostic, however for the sake of consistency I put it under the tracing folder
Thanks a lot @marcingrzejszczak , there are some failures in the build, could you please take a look? thank you
```
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.apache.cxf.spring.boot.autoconfigure.micrometer.MicrometerObservationAutoConfiguration] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@5cb0d902]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:483)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:360)
```
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1291743653
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabiityTest.java:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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.cxf.systest.jaxrs.spring.boot;
+
+import java.time.Duration;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import brave.sampler.Sampler;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.systest.ArrayListSpanReporter;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import zipkin2.Span;
+import zipkin2.reporter.Reporter;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.tck.MeterRegistryAssert;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.Span.Kind;
+import io.micrometer.tracing.test.simple.SpansAssert;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.hasSize;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsObservabiityTest.TestConfig.class)
+@ActiveProfiles("jaxrs")
+@AutoConfigureObservability
+public class SpringJaxrsObservabiityTest {
+
+ @Autowired
+ private MeterRegistry registry;
+
+ @Autowired
+ private ObservationRegistry observationRegistry;
+
+ @Autowired
+ private ArrayListSpanReporter arrayListSpanReporter;
+
+ @LocalServerPort
+ private int port;
+
+ @EnableAutoConfiguration(exclude = WebMvcObservationAutoConfiguration.class)
+ @ComponentScan(basePackageClasses = Library.class)
+ static class TestConfig {
+ @Bean
+ public Feature observationFeature(ObservationRegistry observationRegistry) {
+ return new ObservationFeature(observationRegistry);
+ }
+
+ @Bean
+ public JacksonJsonProvider jacksonJsonProvider() {
+ return new JacksonJsonProvider();
+ }
+
+ @Bean
+ Sampler sampler() {
+ return Sampler.ALWAYS_SAMPLE;
+ }
+
+ @Bean
+ ArrayListSpanReporter arrayListSpanReporter() {
+ return new ArrayListSpanReporter();
+ }
+
+ @Bean
+ Reporter<Span> reporter() {
+ return Reporter.CONSOLE;
+ }
+ }
+
+ @Autowired
+ public void setBus(Bus bus) {
+ // By default, the exception are propagated and out fault interceptors are not called
+ bus.setProperty("org.apache.cxf.propagate.exception", Boolean.FALSE);
+ }
+
+ @AfterEach
+ public void clear() {
+ registry.clear();
+ arrayListSpanReporter.close();
+ }
+
+ @Test
+ public void testJaxrsSuccessMetric() {
+ final WebTarget target = createWebTarget();
+
+ try (Response r = target.request().get()) {
+ assertThat(r.getStatus()).isEqualTo(200);
+ }
+
+ await()
+ .atMost(Duration.ofSeconds(1))
+ .until(() -> arrayListSpanReporter.getSpans(), hasSize(2));
+
+ // Micrometer Observation with Micrometer Tracing
+ SpansAssert.assertThat(arrayListSpanReporter.getSpans())
+ .haveSameTraceId()
+ .hasASpanWithName("GET", spanAssert -> {
+ spanAssert.hasKindEqualTo(Kind.CLIENT)
+ .hasTag("rpc.service", "WebClient")
+ .hasTag("rpc.system", "cxf")
+ .hasTagWithKey("server.address")
+ .hasTagWithKey("server.port")
+ .isStarted()
+ .isEnded();
+ })
+ .hasASpanWithName("rpc.server.duration", spanAssert -> {
Review Comment:
Interesting. That would mean that the default, "metric" related name hooked in and the contextual name wasn't called. Here you can see how the contextual name should be set (https://github.com/apache/cxf/pull/1346/files#diff-05b29f9cca6ab07f827c4985ccf14e61f6c878510b4e18c37634b360041ed658R42) and here (https://github.com/apache/cxf/pull/1346/files#diff-3a451c2c9618eb5753ffd9960d384ffa6685f97fedf6605d787c7c018556d871R77) but maybe I messed sth up 😬
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabiityTest.java:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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.cxf.systest.jaxrs.spring.boot;
+
+import java.time.Duration;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import brave.sampler.Sampler;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.systest.ArrayListSpanReporter;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import zipkin2.Span;
+import zipkin2.reporter.Reporter;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.tck.MeterRegistryAssert;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.Span.Kind;
+import io.micrometer.tracing.test.simple.SpansAssert;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.hasSize;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsObservabiityTest.TestConfig.class)
+@ActiveProfiles("jaxrs")
+@AutoConfigureObservability
+public class SpringJaxrsObservabiityTest {
+
+ @Autowired
+ private MeterRegistry registry;
+
+ @Autowired
+ private ObservationRegistry observationRegistry;
+
+ @Autowired
+ private ArrayListSpanReporter arrayListSpanReporter;
+
+ @LocalServerPort
+ private int port;
+
+ @EnableAutoConfiguration(exclude = WebMvcObservationAutoConfiguration.class)
+ @ComponentScan(basePackageClasses = Library.class)
+ static class TestConfig {
+ @Bean
+ public Feature observationFeature(ObservationRegistry observationRegistry) {
+ return new ObservationFeature(observationRegistry);
+ }
+
+ @Bean
+ public JacksonJsonProvider jacksonJsonProvider() {
+ return new JacksonJsonProvider();
+ }
+
+ @Bean
+ Sampler sampler() {
+ return Sampler.ALWAYS_SAMPLE;
+ }
+
+ @Bean
+ ArrayListSpanReporter arrayListSpanReporter() {
+ return new ArrayListSpanReporter();
+ }
+
+ @Bean
+ Reporter<Span> reporter() {
+ return Reporter.CONSOLE;
+ }
+ }
+
+ @Autowired
+ public void setBus(Bus bus) {
+ // By default, the exception are propagated and out fault interceptors are not called
+ bus.setProperty("org.apache.cxf.propagate.exception", Boolean.FALSE);
+ }
+
+ @AfterEach
+ public void clear() {
+ registry.clear();
+ arrayListSpanReporter.close();
+ }
+
+ @Test
+ public void testJaxrsSuccessMetric() {
+ final WebTarget target = createWebTarget();
+
+ try (Response r = target.request().get()) {
+ assertThat(r.getStatus()).isEqualTo(200);
+ }
+
+ await()
+ .atMost(Duration.ofSeconds(1))
+ .until(() -> arrayListSpanReporter.getSpans(), hasSize(2));
+
+ // Micrometer Observation with Micrometer Tracing
+ SpansAssert.assertThat(arrayListSpanReporter.getSpans())
+ .haveSameTraceId()
+ .hasASpanWithName("GET", spanAssert -> {
+ spanAssert.hasKindEqualTo(Kind.CLIENT)
+ .hasTag("rpc.service", "WebClient")
+ .hasTag("rpc.system", "cxf")
+ .hasTagWithKey("server.address")
+ .hasTagWithKey("server.port")
+ .isStarted()
+ .isEnded();
+ })
+ .hasASpanWithName("rpc.server.duration", spanAssert -> {
Review Comment:
Interesting. That would mean that the default, "metric" related name hooked in and the contextual name wasn't called. Here you can see how the contextual name should be set (https://github.com/apache/cxf/pull/1346/files#diff-05b29f9cca6ab07f827c4985ccf14e61f6c878510b4e18c37634b360041ed658R42) and here (https://github.com/apache/cxf/pull/1346/files#diff-3a451c2c9618eb5753ffd9960d384ffa6685f97fedf6605d787c7c018556d871R77) but maybe I messed sth up 😬
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabiityTest.java:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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.cxf.systest.jaxrs.spring.boot;
+
+import java.time.Duration;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import brave.sampler.Sampler;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.systest.ArrayListSpanReporter;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import zipkin2.Span;
+import zipkin2.reporter.Reporter;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.tck.MeterRegistryAssert;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.Span.Kind;
+import io.micrometer.tracing.test.simple.SpansAssert;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.hasSize;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsObservabiityTest.TestConfig.class)
+@ActiveProfiles("jaxrs")
+@AutoConfigureObservability
+public class SpringJaxrsObservabiityTest {
+
+ @Autowired
+ private MeterRegistry registry;
+
+ @Autowired
+ private ObservationRegistry observationRegistry;
+
+ @Autowired
+ private ArrayListSpanReporter arrayListSpanReporter;
+
+ @LocalServerPort
+ private int port;
+
+ @EnableAutoConfiguration(exclude = WebMvcObservationAutoConfiguration.class)
+ @ComponentScan(basePackageClasses = Library.class)
+ static class TestConfig {
+ @Bean
+ public Feature observationFeature(ObservationRegistry observationRegistry) {
Review Comment:
Here you are creating the feature manually and I guess we want that to happen out of the box?
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabiityTest.java:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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.cxf.systest.jaxrs.spring.boot;
+
+import java.time.Duration;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import brave.sampler.Sampler;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.systest.ArrayListSpanReporter;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import zipkin2.Span;
+import zipkin2.reporter.Reporter;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.tck.MeterRegistryAssert;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.Span.Kind;
+import io.micrometer.tracing.test.simple.SpansAssert;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.hasSize;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsObservabiityTest.TestConfig.class)
+@ActiveProfiles("jaxrs")
+@AutoConfigureObservability
+public class SpringJaxrsObservabiityTest {
+
+ @Autowired
+ private MeterRegistry registry;
+
+ @Autowired
+ private ObservationRegistry observationRegistry;
+
+ @Autowired
+ private ArrayListSpanReporter arrayListSpanReporter;
+
+ @LocalServerPort
+ private int port;
+
+ @EnableAutoConfiguration(exclude = WebMvcObservationAutoConfiguration.class)
Review Comment:
You did it right - I think I did the same thing. So `WebMvcObservationAutoConfiguration` is the configuration that hooks in for MVC observations on the Servlet level. The Cxf instrumentation is on a different level and should take precedense for that matter. You would have the same problem with e.g. Tomcat Valve instrumentation. Tomcat would hook in earlier and we would have to disable the `WebMvcAutoConfiguration` (or just the observation filter) so as not to do double instrumentation.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1288387990
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
So `CxfAutoConfiguration` will create a bean for the `ObservationFeature` ? I can't find the code that does that.
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
So `CxfAutoConfiguration` will create a bean for the `ObservationFeature` and `ObservationClientFeature` ? I can't find the code that does that.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1288408846
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
So if the `ObservationFeature` and `ObservationClientFeature` will be automatically created as beans assuming that there's an `ObservationRegistry` bean present then the whole autoconfiguration is not required.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1291761336
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabiityTest.java:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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.cxf.systest.jaxrs.spring.boot;
+
+import java.time.Duration;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import brave.sampler.Sampler;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.systest.ArrayListSpanReporter;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import zipkin2.Span;
+import zipkin2.reporter.Reporter;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.tck.MeterRegistryAssert;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.Span.Kind;
+import io.micrometer.tracing.test.simple.SpansAssert;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.hasSize;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsObservabiityTest.TestConfig.class)
+@ActiveProfiles("jaxrs")
+@AutoConfigureObservability
+public class SpringJaxrsObservabiityTest {
+
+ @Autowired
+ private MeterRegistry registry;
+
+ @Autowired
+ private ObservationRegistry observationRegistry;
+
+ @Autowired
+ private ArrayListSpanReporter arrayListSpanReporter;
+
+ @LocalServerPort
+ private int port;
+
+ @EnableAutoConfiguration(exclude = WebMvcObservationAutoConfiguration.class)
+ @ComponentScan(basePackageClasses = Library.class)
+ static class TestConfig {
+ @Bean
+ public Feature observationFeature(ObservationRegistry observationRegistry) {
+ return new ObservationFeature(observationRegistry);
+ }
+
+ @Bean
+ public JacksonJsonProvider jacksonJsonProvider() {
+ return new JacksonJsonProvider();
+ }
+
+ @Bean
+ Sampler sampler() {
+ return Sampler.ALWAYS_SAMPLE;
+ }
+
+ @Bean
+ ArrayListSpanReporter arrayListSpanReporter() {
+ return new ArrayListSpanReporter();
+ }
+
+ @Bean
+ Reporter<Span> reporter() {
+ return Reporter.CONSOLE;
+ }
+ }
+
+ @Autowired
+ public void setBus(Bus bus) {
+ // By default, the exception are propagated and out fault interceptors are not called
+ bus.setProperty("org.apache.cxf.propagate.exception", Boolean.FALSE);
+ }
+
+ @AfterEach
+ public void clear() {
+ registry.clear();
+ arrayListSpanReporter.close();
+ }
+
+ @Test
+ public void testJaxrsSuccessMetric() {
+ final WebTarget target = createWebTarget();
+
+ try (Response r = target.request().get()) {
+ assertThat(r.getStatus()).isEqualTo(200);
+ }
+
+ await()
+ .atMost(Duration.ofSeconds(1))
+ .until(() -> arrayListSpanReporter.getSpans(), hasSize(2));
+
+ // Micrometer Observation with Micrometer Tracing
+ SpansAssert.assertThat(arrayListSpanReporter.getSpans())
+ .haveSameTraceId()
+ .hasASpanWithName("GET", spanAssert -> {
+ spanAssert.hasKindEqualTo(Kind.CLIENT)
+ .hasTag("rpc.service", "WebClient")
+ .hasTag("rpc.system", "cxf")
+ .hasTagWithKey("server.address")
+ .hasTagWithKey("server.port")
+ .isStarted()
+ .isEnded();
+ })
+ .hasASpanWithName("rpc.server.duration", spanAssert -> {
Review Comment:
I will try to debug that, but besides that - I think we should be all set
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1272916197
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
I am unsure about this particular auto configuration, it conflicts with the way CXF uses scans (coming from CxfAutoConfiguration).
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1288393444
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
Yes, there are 2 way it works (managed by property):
- scanning classpath and extracting JAX-RS annotated classes (done by https://github.com/apache/cxf/blob/main/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractJaxrsClassesScanServer.java)
- scanning Spring components (done by https://github.com/apache/cxf/blob/main/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java)
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1288408846
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
So if the `ObservationFeature` and `ObservationClientFeature` will be automatically created as beans assuming that there's an `ObservationFeature` then the whole autoconfiguration is not required.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1290853558
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabiityTest.java:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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.cxf.systest.jaxrs.spring.boot;
+
+import java.time.Duration;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import brave.sampler.Sampler;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.systest.ArrayListSpanReporter;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import zipkin2.Span;
+import zipkin2.reporter.Reporter;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.tck.MeterRegistryAssert;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.Span.Kind;
+import io.micrometer.tracing.test.simple.SpansAssert;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.hasSize;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsObservabiityTest.TestConfig.class)
+@ActiveProfiles("jaxrs")
+@AutoConfigureObservability
+public class SpringJaxrsObservabiityTest {
+
+ @Autowired
+ private MeterRegistry registry;
+
+ @Autowired
+ private ObservationRegistry observationRegistry;
+
+ @Autowired
+ private ArrayListSpanReporter arrayListSpanReporter;
+
+ @LocalServerPort
+ private int port;
+
+ @EnableAutoConfiguration(exclude = WebMvcObservationAutoConfiguration.class)
+ @ComponentScan(basePackageClasses = Library.class)
+ static class TestConfig {
+ @Bean
+ public Feature observationFeature(ObservationRegistry observationRegistry) {
+ return new ObservationFeature(observationRegistry);
+ }
+
+ @Bean
+ public JacksonJsonProvider jacksonJsonProvider() {
+ return new JacksonJsonProvider();
+ }
+
+ @Bean
+ Sampler sampler() {
+ return Sampler.ALWAYS_SAMPLE;
+ }
+
+ @Bean
+ ArrayListSpanReporter arrayListSpanReporter() {
+ return new ArrayListSpanReporter();
+ }
+
+ @Bean
+ Reporter<Span> reporter() {
+ return Reporter.CONSOLE;
+ }
+ }
+
+ @Autowired
+ public void setBus(Bus bus) {
+ // By default, the exception are propagated and out fault interceptors are not called
+ bus.setProperty("org.apache.cxf.propagate.exception", Boolean.FALSE);
+ }
+
+ @AfterEach
+ public void clear() {
+ registry.clear();
+ arrayListSpanReporter.close();
+ }
+
+ @Test
+ public void testJaxrsSuccessMetric() {
+ final WebTarget target = createWebTarget();
+
+ try (Response r = target.request().get()) {
+ assertThat(r.getStatus()).isEqualTo(200);
+ }
+
+ await()
+ .atMost(Duration.ofSeconds(1))
+ .until(() -> arrayListSpanReporter.getSpans(), hasSize(2));
+
+ // Micrometer Observation with Micrometer Tracing
+ SpansAssert.assertThat(arrayListSpanReporter.getSpans())
+ .haveSameTraceId()
+ .hasASpanWithName("GET", spanAssert -> {
+ spanAssert.hasKindEqualTo(Kind.CLIENT)
+ .hasTag("rpc.service", "WebClient")
+ .hasTag("rpc.system", "cxf")
+ .hasTagWithKey("server.address")
+ .hasTagWithKey("server.port")
+ .isStarted()
+ .isEnded();
+ })
+ .hasASpanWithName("rpc.server.duration", spanAssert -> {
Review Comment:
The server span name is very unexpected `rpc.server.duration`, do you know why is that?
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on a diff in pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1288202617
##########
integration/spring-boot/autoconfigure/src/main/java/org/apache/cxf/spring/boot/autoconfigure/micrometer/MicrometerObservationAutoConfiguration.java:
##########
@@ -0,0 +1,58 @@
+/**
+ * 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.cxf.spring.boot.autoconfigure.micrometer;
+
+import org.apache.cxf.tracing.micrometer.MessageInObservationConvention;
+import org.apache.cxf.tracing.micrometer.MessageOutObservationConvention;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import io.micrometer.observation.ObservationRegistry;
+
+@Configuration
+@AutoConfigureAfter(ObservationAutoConfiguration.class)
+@ConditionalOnClass({ ObservationRegistry.class, ObservationFeature.class })
+@ConditionalOnProperty(name = "cxf.observation.enabled", matchIfMissing = true)
+@ConditionalOnBean(ObservationRegistry.class)
+public class MicrometerObservationAutoConfiguration {
Review Comment:
The `MessageInObservationConvention` and `MessageOutObservationConvention` *MAY BE* provided by the user. This is to override the defaults that CXF would provide. It is perfectly valid *NOT* to have these defined by the user
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1292806238
##########
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabiityTest.java:
##########
@@ -0,0 +1,173 @@
+/**
+ * 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.cxf.systest.jaxrs.spring.boot;
+
+import java.time.Duration;
+
+import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
+
+import brave.sampler.Sampler;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.systest.ArrayListSpanReporter;
+import org.apache.cxf.systest.jaxrs.resources.Library;
+import org.apache.cxf.tracing.micrometer.ObservationClientFeature;
+import org.apache.cxf.tracing.micrometer.ObservationFeature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.server.LocalServerPort;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.ActiveProfiles;
+import zipkin2.Span;
+import zipkin2.reporter.Reporter;
+
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
+import io.micrometer.core.tck.MeterRegistryAssert;
+import io.micrometer.observation.ObservationRegistry;
+import io.micrometer.tracing.Span.Kind;
+import io.micrometer.tracing.test.simple.SpansAssert;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.Matchers.hasSize;
+
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = SpringJaxrsObservabiityTest.TestConfig.class)
+@ActiveProfiles("jaxrs")
+@AutoConfigureObservability
+public class SpringJaxrsObservabiityTest {
+
+ @Autowired
+ private MeterRegistry registry;
+
+ @Autowired
+ private ObservationRegistry observationRegistry;
+
+ @Autowired
+ private ArrayListSpanReporter arrayListSpanReporter;
+
+ @LocalServerPort
+ private int port;
+
+ @EnableAutoConfiguration(exclude = WebMvcObservationAutoConfiguration.class)
+ @ComponentScan(basePackageClasses = Library.class)
+ static class TestConfig {
+ @Bean
+ public Feature observationFeature(ObservationRegistry observationRegistry) {
+ return new ObservationFeature(observationRegistry);
+ }
+
+ @Bean
+ public JacksonJsonProvider jacksonJsonProvider() {
+ return new JacksonJsonProvider();
+ }
+
+ @Bean
+ Sampler sampler() {
+ return Sampler.ALWAYS_SAMPLE;
+ }
+
+ @Bean
+ ArrayListSpanReporter arrayListSpanReporter() {
+ return new ArrayListSpanReporter();
+ }
+
+ @Bean
+ Reporter<Span> reporter() {
+ return Reporter.CONSOLE;
+ }
+ }
+
+ @Autowired
+ public void setBus(Bus bus) {
+ // By default, the exception are propagated and out fault interceptors are not called
+ bus.setProperty("org.apache.cxf.propagate.exception", Boolean.FALSE);
+ }
+
+ @AfterEach
+ public void clear() {
+ registry.clear();
+ arrayListSpanReporter.close();
+ }
+
+ @Test
+ public void testJaxrsSuccessMetric() {
+ final WebTarget target = createWebTarget();
+
+ try (Response r = target.request().get()) {
+ assertThat(r.getStatus()).isEqualTo(200);
+ }
+
+ await()
+ .atMost(Duration.ofSeconds(1))
+ .until(() -> arrayListSpanReporter.getSpans(), hasSize(2));
+
+ // Micrometer Observation with Micrometer Tracing
+ SpansAssert.assertThat(arrayListSpanReporter.getSpans())
+ .haveSameTraceId()
+ .hasASpanWithName("GET", spanAssert -> {
+ spanAssert.hasKindEqualTo(Kind.CLIENT)
+ .hasTag("rpc.service", "WebClient")
+ .hasTag("rpc.system", "cxf")
+ .hasTagWithKey("server.address")
+ .hasTagWithKey("server.port")
+ .isStarted()
+ .isEnded();
+ })
+ .hasASpanWithName("rpc.server.duration", spanAssert -> {
Review Comment:
Should be all set, the JAX-RS HTTP instrumentations works pretty well.
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] marcingrzejszczak commented on pull request #1346: Micrometer Observation
Posted by "marcingrzejszczak (via GitHub)" <gi...@apache.org>.
marcingrzejszczak commented on PR #1346:
URL: https://github.com/apache/cxf/pull/1346#issuecomment-1676446426
LGTM!
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [cxf] reta commented on a diff in pull request #1346: Micrometer Observation
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #1346:
URL: https://github.com/apache/cxf/pull/1346#discussion_r1272910129
##########
integration/tracing/tracing-micrometer/pom.xml:
##########
@@ -0,0 +1,103 @@
+<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>
+ <artifactId>cxf-integration-tracing-micrometer</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache CXF Observability using Micrometer Observation</name>
+ <description>Apache CXF Observability using Micrometer Observation</description>
+ <url>https://cxf.apache.org</url>
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>4.0.3-SNAPSHOT</version>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
+
+ <properties>
+ <cxf.module.name>org.apache.cxf.tracing.micrometer</cxf.module.name>
+ <cxf.osgi.export>
+ org.apache.cxf.tracing,
+ org.apache.cxf.tracing.micrometer,
+ org.apache.cxf.tracing.micrometer.jaxrs
+ </cxf.osgi.export>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>jakarta.xml.ws</groupId>
+ <artifactId>jakarta.xml.ws-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-management</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
Review Comment:
I think these two artifacts shouldn't be optional since they are always required for this integration, right?
--
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: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org