New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve logging for missing dependencies in MicrometerObservationRegistryTestExecutionListener
#30747
Comments
This has been addressed in acb786d. As stated in the commit comments, the following demonstrate the generated DEBUG message when
@wilkinsona and @lynchie14, please let me know if the current behavior now meets your expectations. |
Prior to this commit, dependency checks in the static initialization block for MicrometerObservationRegistryTestExecutionListener resulted in an ExceptionInInitializerError which led to verbose logging in TestContextFailureHandler. This commit improves the logging for missing dependencies in MicrometerObservationRegistryTestExecutionListener by moving the dependency checks to the constructor and by throwing a NoClassDefFoundError instead of an IllegalStateException. This allows TestContextFailureHandler to log a concise DEBUG message denoting that the listener is being skipped due to missing dependencies. This commit also now checks for the presence of io.micrometer.context.ThreadLocalAccessor in addition to io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor. Furthermore, this commit now explicitly mentions the need for io.micrometer:context-propagation in the error message. The following demonstrate the generated DEBUB message when ObservationThreadLocalAccessor and ThreadLocalAccessor are missing, respectively. Skipping candidate TestExecutionListener [org.springframework.test.context.observation.MicrometerObservationRegistryTestExecutionListener] due to a missing dependency. Specify custom TestExecutionListener classes or make the default TestExecutionListener classes and their required dependencies available. Offending class: io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor. MicrometerObservationRegistryTestExecutionListener requires io.micrometer:micrometer-observation:1.10.8 or higher and io.micrometer:context-propagation:1.0.3 or higher. Skipping candidate TestExecutionListener [org.springframework.test.context.observation.MicrometerObservationRegistryTestExecutionListener] due to a missing dependency. Specify custom TestExecutionListener classes or make the default TestExecutionListener classes and their required dependencies available. Offending class: io.micrometer.context.ThreadLocalAccessor. MicrometerObservationRegistryTestExecutionListener requires io.micrometer:micrometer-observation:1.10.8 or higher and io.micrometer:context-propagation:1.0.3 or higher. Closes spring-projectsgh-30747
…tener Prior to this commit, the required runtime dependencies were checked via reflection each time an attempt was made to instantiate MicrometerObservationRegistryTestExecutionListener. Since it's sufficient to check for the presence of required runtime dependencies only once, this commit caches the results of the dependency checks in a static field. This commit also introduces automated tests for the runtime dependency checks in MicrometerObservationRegistryTestExecutionListener. See gh-30747
See #30726 (comment) for details.
The text was updated successfully, but these errors were encountered: