Skip to content

Commit 074d544

Browse files
committed
GH-9001: Revise Observation propagation over the channel
Fixes: #9001 The `ObservationPropagationChannelInterceptor` does not propagate an observation properly. And it fully cannot when the message channel is persistent. * Deprecate `ObservationPropagationChannelInterceptor` in favor of enabled observation on the channel and target `MessageHandler` which is a consumer of this channel. * Remove tests with an `ObservationPropagationChannelInterceptor` * Mention a correct behavior in the `metrics.adoc` and `ObservationPropagationChannelInterceptor` Javadocs **Auto-cherry-pick to `6.2.x`**
1 parent a4c354d commit 074d544

File tree

5 files changed

+18
-389
lines changed

5 files changed

+18
-389
lines changed

spring-integration-core/src/main/java/org/springframework/integration/channel/interceptor/ObservationPropagationChannelInterceptor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,22 @@
3232
* implementation responsible for an {@link Observation} propagation from one message
3333
* flow's thread to another through the {@link MessageChannel}s involved in the flow.
3434
* Opens a new {@link Observation.Scope} on another thread and cleans up it in the end.
35+
* <p>
36+
* NOTE: This interceptor is proven to be wrong since an existing observation usually is closed
37+
* on the sender side before the message is consumed on the receiver side.
38+
* Therefore, it is better to have a {@code sender} observation on this channel,
39+
* and then {@code receiver} observation on a subscriber for this channel.
40+
* This way a tracing information is stored into message headers passing this channel.
41+
* Such an approach also eliminate a problem with persistent message channels where
42+
* an {@link Observation} is not serializable to be stored into database as a part of the message.
3543
*
3644
* @author Artem Bilan
3745
*
3846
* @since 6.0
47+
*
48+
* @deprecated since 6.1.7 for removal in 6.4 in favor of enabling observation on the channel and its consumer.
3949
*/
50+
@Deprecated(since = "6.1.7", forRemoval = true)
4051
public class ObservationPropagationChannelInterceptor extends ThreadStatePropagationChannelInterceptor<Observation> {
4152

4253
private final ThreadLocal<Observation.Scope> scopes = new ThreadLocal<>();

spring-integration-core/src/test/java/org/springframework/integration/channel/interceptor/ObservationPropagationChannelInterceptorTests.java

Lines changed: 0 additions & 359 deletions
This file was deleted.

0 commit comments

Comments
 (0)