-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Spring integration error when using MessageRequestReplyReceiverContext data in observation predicate #8664
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
Comments
I think the problem is in the Micrometer Observation. We probably can do some workaround in Spring Integration for this or similar API usage, but the real bug and possible fix must go to Micrometer Observation. |
Right. My theory is correct.
and got the same exception:
Not sure what is the fix in Micrometer should be, but that |
Fixes spring-projects#8664 When an `Observation` is turned to `NoopObservation`, the `observeWithContext()` fails with `ClassCastException` since `NoopObservation` serves just plain `Context` not the one we supplied * Fix `MessagingGatewaySupport.sendAndReceiveWithObservation()` same way as it is in version `6.0.x` * Modify `IntegrationObservabilityZipkinTests` to reject some `Observation` via `observationPredicate()` configuration **Cherry-pick to `6.1.x`**
Thanks for checking, we will then just wait for the fix 😄 |
Yeah... Only as a workaround for you right now I see as a downgrade to Spring Integration |
I guess the behaviour should be that if there's a no op observation the function is not called at all, right? |
That's not correct, @marcingrzejszczak .
So, that If there is no way to propagate a proper I remember that exactly me asked for this kind of fluent API to avoid a |
I wonder if we could have another overloaded observation method? Something like default <T extends Observation.Context> Observation observation(@Nullable ObservationConvention<T> customConvention,
ObservationConvention<T> defaultConvention, Supplier<T> contextSupplier, ObservationRegistry registry
T noopContext) { Where the ?? |
Actually, no, the cast is avoided even if stored in the Context field. |
Yeah... The point is that Perhaps Not sure, though, how everything else works since it just delegates to this method anyway:
|
Looks like there is no the fix in Micrometer Observation yet, so we have to go for proposed workaround for our upcoming releases. Thanks |
Fixes #8664 When an `Observation` is turned to `NoopObservation`, the `observeWithContext()` fails with `ClassCastException` since `NoopObservation` serves just plain `Context` not the one we supplied * Fix `MessagingGatewaySupport.sendAndReceiveWithObservation()` same way as it is in version `6.0.x` * Modify `IntegrationObservabilityZipkinTests` to reject some `Observation` via `observationPredicate()` configuration **Cherry-pick to `6.1.x`**
Fixes #8664 When an `Observation` is turned to `NoopObservation`, the `observeWithContext()` fails with `ClassCastException` since `NoopObservation` serves just plain `Context` not the one we supplied * Fix `MessagingGatewaySupport.sendAndReceiveWithObservation()` same way as it is in version `6.0.x` * Modify `IntegrationObservabilityZipkinTests` to reject some `Observation` via `observationPredicate()` configuration **Cherry-pick to `6.1.x`**
In what version(s) of Spring Integration are you seeing this issue?
id 'org.springframework.boot' version '3.1.1'
implementation("org.springframework.integration:spring-integration-ip")
Describe the bug
When using the
ObservationPredicate
with Spring boot micrometer, I created some rules in order to observe certain contexts. But when using the contextMessageRequestReplyReceiverContext
and using some of its data in order to create a predicate, the rest of the chain of the application just fails with the exception:Our application flow is just a simple TCP nio inbound, with a broker outbound. But it seems to be going wrong before we receive it in the the TCP inbound.
Example of usage in observation predicate when using headers:
Example of usage in observation predicate when using payload:
Exception:

Expected behavior
Expected to not break the application when simply casting the payload or using the headers in the generic message.
The text was updated successfully, but these errors were encountered: