tracing

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: BSD-3-Clause-Clear Imports: 11 Imported by: 0

Documentation

Overview

Tracing provides decorators which enable distributed tracing

How it works

This package provides two decorators which can be used to propagate tracing information. The topic decorator "tracing.Topic" will automatically attach tracing information to any outgoing messages. If no parent trace exists, it will create one automatically. The second decorator, tracing.Receiver is used to decode tracing information into the context.Context object which is passed into the receiver that you provide handle messages. Again if to trace is present a trace is started and set in the context.

Examples

Using the tracing.Topic:

func ExampleTopic() {
	// make a concrete topic eg SNS
	topic, _ := sns.NewTopic("arn://sns:xxx")
	// make a tracing topic with the span name "msg.Writer"
	topic := tracing.TracingTopic(topic, tracing.WithSpanName("msg.Writer"))
	// use topic as you would without tracing
}

Using the tracing.Receiver:

	func ExampleReceiver() {
     receiver := msg.Receiver(func(ctx context.Context, m *msg.Message) error {
         // your receiver implementation
         // ctx will contain tracing information
         // once decorated
     })
     receiver := tracing.Receiver(receiver)
     // use receiver as you would without tracing
	}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Receiver

func Receiver(next msg.Receiver, opts ...Option) msg.Receiver

Receiver Wraps another msg.Receiver, populating the context with any upstream tracing information.

func Topic

func Topic(next msg.Topic, opts ...Option) msg.Topic

Topic wraps a msg.Topic, attaching any tracing data via msg.Attributes to send downstream

Types

type Option

type Option func(*Options)

func WithSpanName

func WithSpanName(spanName string) Option

func WithStartOption

func WithStartOption(so trace.StartOptions) Option

type Options

type Options struct {
	SpanName     string
	StartOptions trace.StartOptions
}

Jump to

Keyboard shortcuts

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