Class TracingChannelInterceptor
- java.lang.Object
-
- org.springframework.cloud.sleuth.instrument.messaging.TracingChannelInterceptor
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.messaging.support.ChannelInterceptor,org.springframework.messaging.support.ExecutorChannelInterceptor
public final class TracingChannelInterceptor extends Object implements org.springframework.messaging.support.ExecutorChannelInterceptor, org.springframework.context.ApplicationContextAware
This starts and propagatesSpan.Kind.PRODUCERspan for each message sent (via native headers. It also extracts or creates aSpan.Kind.CONSUMERspan for each message received. This span is injected onto each message so it becomes the parent when a handler later callsMessageHandler.handleMessage(Message).- Since:
- 3.0.0
- Author:
- Marcin Grzejszczak, Artem Bilan
-
-
Field Summary
Fields Modifier and Type Field Description static StringSTREAM_DIRECT_CHANNELName of the class in Spring Cloud Stream that is a direct channel.
-
Constructor Summary
Constructors Constructor Description TracingChannelInterceptor(Tracer tracer, Propagator propagator, Propagator.Setter<org.springframework.messaging.support.MessageHeaderAccessor> setter, Propagator.Getter<org.springframework.messaging.support.MessageHeaderAccessor> getter, Function<String,String> remoteServiceNameMapper, MessageSpanCustomizer messageSpanCustomizer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterMessageHandled(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler, Exception ex)voidafterReceiveCompletion(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, Exception ex)voidafterSendCompletion(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, boolean sent, Exception ex)org.springframework.messaging.Message<?>beforeHandle(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler)This starts a consumer span as a child of the incoming message or the current trace context.org.springframework.messaging.Message<?>postReceive(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel)This starts a consumer span as a child of the incoming message or the current trace context, placing it in scope until the receive completes.org.springframework.messaging.Message<?>preSend(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel)Starts and propagatesSpan.Kind.PRODUCERspan for each message sent.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
-
-
Field Detail
-
STREAM_DIRECT_CHANNEL
public static final String STREAM_DIRECT_CHANNEL
Name of the class in Spring Cloud Stream that is a direct channel.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TracingChannelInterceptor
public TracingChannelInterceptor(Tracer tracer, Propagator propagator, Propagator.Setter<org.springframework.messaging.support.MessageHeaderAccessor> setter, Propagator.Getter<org.springframework.messaging.support.MessageHeaderAccessor> getter, Function<String,String> remoteServiceNameMapper, MessageSpanCustomizer messageSpanCustomizer)
-
-
Method Detail
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
preSend
public org.springframework.messaging.Message<?> preSend(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel)Starts and propagatesSpan.Kind.PRODUCERspan for each message sent.- Specified by:
preSendin interfaceorg.springframework.messaging.support.ChannelInterceptor
-
afterSendCompletion
public void afterSendCompletion(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, boolean sent, Exception ex)- Specified by:
afterSendCompletionin interfaceorg.springframework.messaging.support.ChannelInterceptor
-
postReceive
public org.springframework.messaging.Message<?> postReceive(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel)This starts a consumer span as a child of the incoming message or the current trace context, placing it in scope until the receive completes.- Specified by:
postReceivein interfaceorg.springframework.messaging.support.ChannelInterceptor
-
afterReceiveCompletion
public void afterReceiveCompletion(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, Exception ex)- Specified by:
afterReceiveCompletionin interfaceorg.springframework.messaging.support.ChannelInterceptor
-
beforeHandle
public org.springframework.messaging.Message<?> beforeHandle(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler)This starts a consumer span as a child of the incoming message or the current trace context. It then creates a span for the handler, placing it in scope.- Specified by:
beforeHandlein interfaceorg.springframework.messaging.support.ExecutorChannelInterceptor
-
afterMessageHandled
public void afterMessageHandled(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel, org.springframework.messaging.MessageHandler handler, Exception ex)- Specified by:
afterMessageHandledin interfaceorg.springframework.messaging.support.ExecutorChannelInterceptor
-
-