trace

package
v2.9.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrManagerDisabled = errors.New("trace: trace is diabled")

ErrManagerDisabled is returned when trying to use global trace manager when it is disabled.

Functions

func AddTracer

func AddTracer(tracer, service string) error

AddTracer initialize a tracer for the service.

func Close

func Close() error

Close calls Close on the global tace manager.

func Debug

func Debug(ctx context.Context, logrus Logrus, args ...interface{})

Debug creates debug log on both logrus and span.

func Disable

func Disable()

Disable disables the global trace manager.

func Enable

func Enable()

Enable sets the global manager to enabled.

func Error

func Error(ctx context.Context, logrus Logrus, args ...interface{})

func Extract

func Extract(tr Tracer, h http.Header) (opentracing.SpanContext, error)

func ExtractFromContext

func ExtractFromContext(ctx context.Context, h http.Header) (opentracing.SpanContext, error)

func GetServiceID

func GetServiceID(ctx context.Context) string

GetServiceID returns service name attched to context returns an empty string if the service name key is not found.

func Handle

func Handle(service string, h http.Handler) http.Handler

Handle returns a http.Handler with root opentracting setup. This should be the topmost handler.

func Info

func Info(ctx context.Context, logrus Logrus, args ...interface{})

func Inject

func Inject(service string, span opentracing.Span, h http.Header) error

func InjectFromContext

func InjectFromContext(ctx context.Context, span opentracing.Span, h http.Header) error

func IsEnabled

func IsEnabled() bool

IsEnabled returns true if the global trace manager is enabled.

func Log

func Log(ctx context.Context, fields ...log.Field)

Log tries to check if there is a span in ctx and adds logs fields on the span.

func Root

func Root(service string, r *http.Request) (opentracing.Span, *http.Request)

func SetInit

func SetInit(fn InitFunc)

func SetLogger

func SetLogger(log Logger)

func SetServiceID

func SetServiceID(ctx context.Context, service string) context.Context

SetServiceID returns context with service assigned to it.

func SetupTracing

func SetupTracing(name string, opts map[string]interface{})

func Span

Span creates a new span for the given ops. If tracing is disabled in this ctx then a noop span is created and the same ctx is returned.

Note that the returned context contains the returned span as active span. So any spans created form the returned context will be children of the returned span.

func Warning

func Warning(ctx context.Context, logrus Logrus, args ...interface{})

Types

type Config

type Config struct {
	Name string
	Opts map[string]interface{}
}

type InitFunc

type InitFunc func(name string, service string, opts map[string]interface{}, logger Logger) (Tracer, error)

InitFunc this is a function for initializing a Tracer

type Logger

type Logger interface {
	Errorf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
}

Logger defines api for logging messages by the OpenTracer struct. This is a workaround to avoid trying this to logrus

type Logrus

type Logrus interface {
	Debug(args ...interface{})
	Error(args ...interface{})
	Warning(args ...interface{})
	Info(args ...interface{})
}

Logrus implements a subset of logrus api to reduce friction when we want to log both on opentracing and on logrus.

type NoopTracer

type NoopTracer struct {
	opentracing.NoopTracer
}

NoopTracer wraps opentracing.NoopTracer to satisfy Tracer interface.

func (NoopTracer) Close

func (n NoopTracer) Close() error

Close implements io.Closer interface by doing nothing.

func (NoopTracer) Name

func (n NoopTracer) Name() string

type StdLogger

type StdLogger struct{}

func (StdLogger) Error

func (StdLogger) Error(args ...interface{})

func (StdLogger) Errorf

func (StdLogger) Errorf(format string, args ...interface{})

func (StdLogger) Info

func (StdLogger) Info(args ...interface{})

func (StdLogger) Infof

func (StdLogger) Infof(format string, args ...interface{})

type Tracer

type Tracer interface {
	Name() string
	opentracing.Tracer
	io.Closer
}

func Get

func Get(service string) Tracer

Get returns a tracer stored on the global trace manager.

func Init

func Init(name string, service string, opts map[string]interface{}, logger Logger) (Tracer, error)

Init returns a tracer for a given name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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