collect

package
v2.0.0-...-0981395 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2019 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FinishedSpan

type FinishedSpan struct {
	Span     *monkit.Span
	Err      error
	Panicked bool
	Finish   time.Time
}

FinishedSpan is a Span that has completed and contains information about how it finished.

func CollectSpans

func CollectSpans(ctx context.Context, work func(ctx context.Context)) (
	spans []*FinishedSpan)

CollectSpans is kind of like WatchForSpans, except that it uses the current span to figure out which trace to collect. It calls work(), then collects from the current trace until work() returns. CollectSpans won't work unless some ancestor function is also monitored and has modified the ctx.

func WatchForSpans

func WatchForSpans(ctx context.Context, r *monkit.Registry,
	matcher func(s *monkit.Span) bool) (spans []*FinishedSpan, err error)

WatchForSpans will watch for spans that 'matcher' returns true for. As soon as a trace generates a matched span, all spans from that trace that finish from that point on are collected until the matching span completes. All collected spans are returned. To cancel this operation, simply cancel the ctx argument. There is a small but permanent amount of overhead added by this function to every trace that is started while this function is running. This only really affects long-running traces.

type SpanCollector

type SpanCollector struct {
	// contains filtered or unexported fields
}

SpanCollector implements the SpanObserver interface. It stores all Spans observed after it starts collecting, typically when matcher returns true.

func NewSpanCollector

func NewSpanCollector(matcher func(s *monkit.Span) bool) (
	rv *SpanCollector)

NewSpanCollector takes a matcher that will return true when a span is found that should start collection. matcher can be nil if you intend to use ForceStart instead.

func (*SpanCollector) Done

func (c *SpanCollector) Done() <-chan struct{}

Done returns a channel that's closed when the SpanCollector has collected everything it cares about.

func (*SpanCollector) Finish

func (c *SpanCollector) Finish(s *monkit.Span, err error, panicked bool,
	finish time.Time)

Finish is to implement the monkit.SpanObserver interface. Finish gets called whenever a Span finishes.

func (*SpanCollector) ForceStart

func (c *SpanCollector) ForceStart(endSpan *monkit.Span)

ForceStart starts the span collector collecting spans, stopping when endSpan finishes. This is typically only used if matcher was nil at construction.

func (*SpanCollector) Spans

func (c *SpanCollector) Spans() (spans []*FinishedSpan)

Spans returns all spans found, rooted from the Span the collector started on.

func (*SpanCollector) Start

func (c *SpanCollector) Start(s *monkit.Span)

Start is to implement the monkit.SpanObserver interface. Start gets called whenever a Span starts.

func (*SpanCollector) Stop

func (c *SpanCollector) Stop()

Stop stops the SpanCollector from collecting.

type StartTimeSorter

type StartTimeSorter []*FinishedSpan

StartTimeSorter assists with sorting a slice of FinishedSpans by start time.

func (StartTimeSorter) Len

func (s StartTimeSorter) Len() int

func (StartTimeSorter) Less

func (s StartTimeSorter) Less(i, j int) bool

func (StartTimeSorter) Sort

func (s StartTimeSorter) Sort()

func (StartTimeSorter) Swap

func (s StartTimeSorter) Swap(i, j int)

Jump to

Keyboard shortcuts

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