Documentation ¶
Overview ¶
OpenCensus tracing for Watermill
Index ¶
- func GetSpanContext(message *message.Message) (sc trace.SpanContext, ok bool)
- func PublisherDecorator(pub message.Publisher, logger watermill.LoggerAdapter) message.Publisher
- func SetSpanContext(sc trace.SpanContext, msg *message.Message)
- func TracingMiddleware(h message.HandlerFunc) message.HandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSpanContext ¶
func GetSpanContext(message *message.Message) (sc trace.SpanContext, ok bool)
GetSpanContext gets and deserialize trace.SpanContext from a message's metadata.
func PublisherDecorator ¶ added in v1.1.0
PublisherDecorator decorates `message.Publisher` with propagating span context in the published message's metadata.
Note: Please keep in mind that the span context needs to be passed as message's context, otherwise no action will be taken.
func SetSpanContext ¶
func SetSpanContext(sc trace.SpanContext, msg *message.Message)
SetSpanContext serialize trace.SpanContext to binary format and sets it in a message's metadata.
func TracingMiddleware ¶
func TracingMiddleware(h message.HandlerFunc) message.HandlerFunc
TracingMiddleware is a Watermill middleware providing OpenCensus tracing.
It creates a span with a name derived from the handler. The span is ended after message is handled. It tries to extract an existing span context from the incoming message and use it as a parent - if there's no such it creates a new one.
The span context is set as the message's context so message handlers' code can start children spans out of it.
spanCtx := trace.FromContext(message.Context())
Depending on a result of the message handling, the span's status is set.
All messages procuded by the handler have span context set so it gets propagated further. Span context is serialized to binary format and is transported in messages' metadata.
Types ¶
This section is empty.