Documentation ¶
Overview ¶
Package amqptracer provides OpenTracing instrumentation for the github.com/streadway/amqp package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
func Extract(hdrs amqp.Table) (opentracing.SpanContext, error)
Extract extracts the span context out of the AMQP header.
Example:
func ConsumeMessage(ctx context.Context, msg *amqp.Delivery) error { // Extract the span context out of the AMQP header. spCtx, _ := amqptracer.Extract(msg.Headers) sp := opentracing.StartSpan( "ConsumeMessage", opentracing.FollowsFrom(spCtx), ) defer sp.Finish() // Update the context with the span for the subsequent reference. ctx = opentracing.ContextWithSpan(ctx, sp) // Actual message processing. return ProcessMessage(ctx, msg) }
func Inject ¶
func Inject(span opentracing.Span, hdrs amqp.Table) error
Inject injects the span context into the AMQP header.
Example:
func PublishMessage( ctx context.Context, ch *amqp.Channel, exchange, key string, mandatory, immediate bool, msg *amqp.Publishing, ) error { sp := opentracing.SpanFromContext(ctx) defer sp.Finish() // Inject the span context into the AMQP header. if err := amqptracer.Inject(sp, msg.Headers); err != nil { return err } // Publish the message with the span context. return ch.Publish(exchange, key, mandatory, immediate, msg) }
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.