cinder

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package cinder provides instrumentation capabilities to applications and components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Branch

func Branch(ctx context.Context) context.Context

Branch will wrap the provided context with the tail of the found trace in the context if the root span matches the span found in the context. This ensures that opentracing compatible code will properly branch of the trace tail rather than the root.

func RootHandler

func RootHandler() func(http.Handler) http.Handler

RootHandler is the middleware used to create the root trace span for incoming HTTP requests.

func SetupTesting

func SetupTesting(name string) func()

SetupTesting will configure a local jaeger instance to receive test traces.

Types

type Span

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

Span is the underlying span used for tracing.

func Track

func Track(ctx context.Context, name string) (context.Context, *Span)

Track is used to mark and annotate a function call. It will automatically wrap the context with a child from the span history found in the provided context. If no span history was found it will return a noop span.

If the function finds a trace in the context and its root span matches the span from the context it will create a child from the traces tail. If not it considers the span history to have diverged from the trace.

func (*Span) Finish

func (s *Span) Finish()

Finish will finish the span.

func (*Span) Log

func (s *Span) Log(key string, value interface{})

Log will log to the span.

func (*Span) Native

func (s *Span) Native() opentracing.Span

Native will return the underlying native span.

func (*Span) Tag

func (s *Span) Tag(key string, value interface{})

Tag will tag the span.

type Trace

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

Trace implements a span stack that can be used with fat contexts. Rather than branching of the context for every function call, a span is pushed onto the stack to track execution.

Code that uses Track will automatically discover the stack and branch of its tail if no previous branch has been detected. Other opentracing compatible code would not be able to find the stack and would use the root span instead. This can be prevented by ensuring a branch using the Branch function.

func CreateTrace

func CreateTrace(ctx context.Context, name string) (*Trace, context.Context)

CreateTrace returns a new trace that will use the span found in the provided context as its root or start a new one. The returned context is the provided context wrapped with the new span and trace.

func GetTrace

func GetTrace(ctx context.Context) *Trace

GetTrace will return the trace from the context or nil if absent.

func (*Trace) Finish

func (t *Trace) Finish()

Finish will finish the root and all stacked spans.

func (*Trace) Log

func (t *Trace) Log(key string, value interface{})

Log adds a log to the last pushed span.

func (*Trace) Pop

func (t *Trace) Pop()

Pop finishes and removes the last pushed span. This call is usually deferred right after a push.

func (*Trace) Push

func (t *Trace) Push(name string)

Push will add a new span to the trace.

func (*Trace) Root

func (t *Trace) Root() opentracing.Span

Root will return the root of the span stack.

func (*Trace) Tag

func (t *Trace) Tag(key string, value interface{})

Tag adds a tag to the last pushed span.

func (*Trace) Tail

func (t *Trace) Tail() opentracing.Span

Tail returns the tail or root of the span stack.

Jump to

Keyboard shortcuts

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