tracing

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRelay

func NewRelay(ctx context.Context, in, out ITracer, transformer Transformer)

NewRelay starts a goroutine that relays traces from `in` Tracer to `out` Tracer using a given Transformer

This is typically used to compartmentalize tracers.

Types

type ErrorTrace

type ErrorTrace struct {
	Error error
}

func (ErrorTrace) TraceInterface

func (t ErrorTrace) TraceInterface()

type ISenderHandle

type ISenderHandle interface {
	// Done indicates that the sender has terminated
	Done()
}

ISenderHandle is an interface for registered senders

type ITrace

type ITrace interface {
	TraceInterface()
}

ITrace is an interface for actual data traces

func Unwrap

func Unwrap(trace ITrace) ITrace

Unwrap will recursively unwrap a trace if wrapped, or return the trace as is if it isn't wrapped.

type ITracer

type ITracer interface {
	// Subscribe creates a new unbuffered channel and subscribes it to
	// traces from the Tracer
	//
	// Note that this channel should be continuously read from until unsubscribed
	// from, otherwise, the Tracer will block.
	Subscribe() chan ITrace

	// SubscribeChannel subscribe a channel to traces from the Tracer
	//
	// Note that this channel should be continuously read from (modulo buffering),
	// otherwise, the Tracer will block.
	SubscribeChannel(channel chan ITrace) chan ITrace

	// Unsubscribe removes channel from subscription list
	Unsubscribe(channel chan ITrace)

	// Trace sends in a trace to a tracer
	Trace(trace ITrace)

	// RegisterSender register a sender for terminate purposes
	//
	// Once Sender is being terminated, before closing subscription channels,
	// it'll wait until all senders call SenderHandle.Done
	RegisterSender() ISenderHandle

	// Done returns a channel that is closed when the tracer is done and terminated
	Done() chan struct{}
}

func NewTracer

func NewTracer(ctx context.Context) ITracer

type IWrappedTrace

type IWrappedTrace interface {
	ITrace
	// Unwrap returns a wrapped trace
	Unwrap() ITrace
}

IWrappedTrace is a trace that wraps another trace.

The purpose of it is to allow components to produce traces that will be wrapped into additional context, without being aware of it.

Typically this would be done by creating a NewTraceTransformingTracer tracer over the original one and passing it to such components.

Consumers looking for individual traces should use Unwrap to retrieve the original trace (as opposed to the wrapped one)

type Transformer

type Transformer func(trace ITrace) []ITrace

type WarningTrace

type WarningTrace struct {
	Warning any
}

func (WarningTrace) TraceInterface

func (t WarningTrace) TraceInterface()

Jump to

Keyboard shortcuts

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