amqptracer

package
v0.0.0-...-e26701f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2017 License: MIT Imports: 2 Imported by: 7

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL