-
Notifications
You must be signed in to change notification settings - Fork 38k
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
ServerHttpObservationFilter does not register against new async operations #33451
Comments
This sounds very specific. We're going to need a minimal sample application to reproduce the case and properly test it. |
We did some further investigation while creating a minimal Spring Boot demo application showing this error. The difference is that The first call will create an observation that is never "stopped", the listener added here will not be called. Attached is a small zip file containing a very simple example.
The outcome when this works is that we get json data from the actuator endpoint. |
Project seems empty with no controller endpoint nor custom filter. Am I missing something? |
THe zip file indeed look to be broken! attached a new one. The application.properties is bit different, ran it on a custom port 10000 locally not 8080 |
Thanks for the update.
I know that coming up with a minimal sample can be hard, but here the Async filter looks invalid for several reasons:
|
Our understanding is that this is the way you have to write filter classes where you want to do async work that has to happen before next filter in the chain. The "later" method actually does .complete() or dispatch() depending on the outcome of that request (in our real production code). The |
Thanks, I understand better now. I do see that our I also see that adding a listener in the custom filter is also failing, because completion is never called:
This only happens when we have a Spring controller returning a I think that we might need to call I'm renaming this issue to reflect that, as I don't think there is a bug in the |
One thing that I do not understand, is the different behavior between Spring Boot 3.3.1 and 3.3.(2|3) . |
The documentation on The Jakarta documentation states:
That is why we think this was the problem. We do have couple of more filters we use in the filter chain that do add themself on calls to |
Found out why there is a different behavior between Spring Boot 3.3.1 and 3.3.2, It is this change done in Spring Framework 6.1.11 that make it look like it works. Spring Framework 6.1.10 causes the original observation created then the first execution of the My guess is that the change above introduced in 6.1.11 tried to fix this, but the side effect is that there now is 2 Observations created in this demo app, the first one is lost and a new one is created on every filterChain pass during async handling. |
Thanks for bearing with me. I think this is due to the change we introduced in #32730 to avoid leaking observations when async requests are completed directly, without any dispatching back to the container.
This is inconsistent with what I'm seeing in your repro. The filter is only called once, and a single observation is created. Because there are several async starts in the same exchange, our observation async listener indeed needs to add itself to subsequent starts in Is this consistent with your tests or am I missing something here? |
You are correct, I missed the call to It might be that using |
@hanson76 I've pushed some changes and they should be available soon as 6.1.13-SNAPSHOT. |
Affects: Spring Framework 6.1.9 - current
The change introduced to
ServerHttpObservationFilter
in 6.1.9 causes requests that executes multiple asynchronous cycles to not get any observations and the observation will never be closed, the listener will not receive any callbacks.The listener in
ServerHttpObservationFilter
need to add itself to theAsyncContext
provided in theAsyncEvent
provide whenonStartAsync(AsyncEvent event)
is being called. The listener will not receive any other callbacks unless this is done.This happens if there is a servlet filter with lower priority in the filter chain that do asynchronous work (calls
startAsync()
on the request) before dispatching the request to further filters or Spring handlers, that in turn callsstartAsync()
on the request.The text was updated successfully, but these errors were encountered: