-
Notifications
You must be signed in to change notification settings - Fork 1k
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
ObservationThreadLocalAccessor.restore() generating errors in tests #3943
Comments
Came across the same issue when invoking a rest endpoint. Spring Boot 3.0.8 or higher. |
I'm trying to reduce the problem to a simple example, but it's quite difficult... For the moment, depending on where I put the following test, it either succeeds (in a simple JUnit test) or fails (in a test in a class annotated with import io.micrometer.observation.ObservationRegistry;
import java.util.concurrent.CompletableFuture;
import org.junit.jupiter.api.Test;
import reactor.core.observability.micrometer.Micrometer;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
public class MicrometerTest {
@Test
void monoWithoutException() {
final Mono<String> response =
Mono.fromFuture(CompletableFuture.supplyAsync(() -> "OK"))
.name("mono-without-exception")
.tap(Micrometer.observation(ObservationRegistry.NOOP))
.thenReturn("OK");
StepVerifier.create(response).expectNext("OK").expectComplete().verify();
}
} |
I'm not sure why the test fails with
My understanding is that :
|
Strange, I tried following step by step in the debugger what's happening, with a breakpoint in
|
I've opened a PR to fix the NPE (I tested locally that it indeed fixes the NPE), but this doesn't solve the initial issue, so I will have to dwelve deeper... |
First PR #3946 merged on 1.10.x branch, I will try another PR for fixing the Scope hierarchy when using |
I'm starting to think that OTLA should take into account whether we're using a NOOP observation registry or sth like that. I'll also look into this topic |
Yes, that's what I'm trying to do too |
I think I fixed it, let me file a PR |
without this change there was a problem with OTLA, default ObservationRegistry and NoOpRegistry interop. They didn't see each other scopes with this change we're allowing scopes for NoOpRegistry and NoOpObservations fixes gh-3943
Related PR - #3947 |
Can someone check the latest micrometer snapshots if they helped? |
Hi @marcingrzejszczak , I've managed to force micrometer version on the project that had failing tests, here's what I see :
So it seems a lot better 👍 |
Fantastic! Thank you for checking it out. I'll close the issue for now and will reopen it if there are any issues |
I guess it's also been fixed on the 1.11.x branch and the main 👍 |
Yes, I merged it forward |
Describe the bug
When upgrading from spring-boot 3.0.4 (micrometer 1.10.4) to spring-boot 3.0.8 or 3.1.1 (micrometer 1.11.1), some of my tests are now failing with a message comparing a
NoopObservation
with null :It seems related to #3831 which introduced
NullObservation
and the verification inObservationThreadLocalAccessor.restore()
.Environment
To Reproduce
I'm trying to extract a test case from my own code to show how to reproduce it. I will post it here once I'm able to reproduce it on a sample application.
For the moment, it seems related to observations created by
Mono.tap(Micrometer.observation(registry))
.Exemple of test that fails with the new version :
Code under test :
Expected behavior
Test should not fail when testing an error happening inside a reactive stream which is observed.
Additional context
The text was updated successfully, but these errors were encountered: