Documentation
¶
Index ¶
- func FindSpan(ctx context.Context, r *monkit.Registry, matcher func(s *monkit.Span) bool)
- func ObserveAllTraces(r *monkit.Registry, collector monkit.SpanObserver) (cancel func())
- type FinishedSpan
- type SpanCollector
- func (c *SpanCollector) Done() <-chan struct{}
- func (c *SpanCollector) Finish(s *monkit.Span, err error, panicked bool, finish time.Time)
- func (c *SpanCollector) ForceStart(endSpan *monkit.Span)
- func (c *SpanCollector) Spans() (spans []*FinishedSpan)
- func (c *SpanCollector) Start(s *monkit.Span)
- func (c *SpanCollector) Stop()
- type StartTimeSorter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindSpan ¶ added in v3.0.18
FindSpan will call matcher until matcher returns true. Due to the nature of span creation, matcher is likely to be concurrently called and therefore matcher may get more than one matching span.
func ObserveAllTraces ¶ added in v3.0.18
func ObserveAllTraces(r *monkit.Registry, collector monkit.SpanObserver) (cancel func())
ObserveAllTraces will register collector with all traces present and future on the given monkit.Registry until cancel is called.
Types ¶
type FinishedSpan ¶
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)