Closed wilkinsona closed 1 month ago
Hi @wilkinsona,
I would like to work on this issue. Could you please assign it to me?
Additionally, I have a few questions to ensure I address the issue correctly:
EventPublishingContextWrapper
is thread-safe and idempotent?Thanks for your guidance! Best regards,
Thanks for the offer, @abounaime, but we'd prefer to handle this one ourselves.
@philwebb I looked at this fix and I think it will work great. There is only one situation where it won't work, and that is for a specific case when running unit tests. I encountered this in my own, similar, workaround for this early context wrapper initialization problem.
The situation is as follows: When a unit test runs first, that doesn't use Spring Boot Test, which accesses the OpenTelemetry context, then it will cause the Context wrappers to have been applied before the OpenTelemetryEventPublisherApplicationListener
was run. When a following test does use Spring Boot Test, running the OpenTelemetryEventPublisherApplicationListener
, the ContextStorage.addWrapper
won't have any effect.
I solved this by implementing a JUnit org.junit.platform.launcher.TestExecutionListener
that triggers that the delegate wrapper is added to the context wrappers. It might be good to consider implementing something similar, or at least provide a public method with which users, as myself, can trigger the adding of the context wrapper.
If you want me to create a new issue for this, then I will happily do so.
Thanks for trying it @mzeijen, I've opened #42005 based on your feedback.
https://github.com/spring-projects/spring-boot/blob/a34917007308fbcd22028c2a39522a4fad5e9651/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryAutoConfiguration.java#L168