Documentation ¶
Index ¶
- Variables
- func AddTracer(tracer, service string) error
- func Close() error
- func Debug(ctx context.Context, logrus Logrus, args ...interface{})
- func Disable()
- func Enable()
- func Error(ctx context.Context, logrus Logrus, args ...interface{})
- func Extract(tr Tracer, h http.Header) (opentracing.SpanContext, error)
- func ExtractFromContext(ctx context.Context, h http.Header) (opentracing.SpanContext, error)
- func GetServiceID(ctx context.Context) string
- func Handle(service string, h http.Handler) http.Handler
- func Info(ctx context.Context, logrus Logrus, args ...interface{})
- func Inject(service string, span opentracing.Span, h http.Header) error
- func InjectFromContext(ctx context.Context, span opentracing.Span, h http.Header) error
- func IsEnabled() bool
- func Log(ctx context.Context, fields ...log.Field)
- func Root(service string, r *http.Request) (opentracing.Span, *http.Request)
- func SetInit(fn InitFunc)
- func SetLogger(log Logger)
- func SetServiceID(ctx context.Context, service string) context.Context
- func SetupTracing(name string, opts map[string]interface{})
- func Span(ctx context.Context, ops string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)
- func Warning(ctx context.Context, logrus Logrus, args ...interface{})
- type Config
- type InitFunc
- type Logger
- type Logrus
- type NoopTracer
- type StdLogger
- type Tracer
Constants ¶
This section is empty.
Variables ¶
var ErrManagerDisabled = errors.New("trace: trace is diabled")
ErrManagerDisabled is returned when trying to use global trace manager when it is disabled.
Functions ¶
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 ¶
GetServiceID returns service name attched to context returns an empty string if the service name key is not found.
func Handle ¶
Handle returns a http.Handler with root opentracting setup. This should be the topmost handler.
func InjectFromContext ¶
func IsEnabled ¶
func IsEnabled() bool
IsEnabled returns true if the global trace manager is enabled.
func SetServiceID ¶
SetServiceID returns context with service assigned to it.
func SetupTracing ¶
func Span ¶
func Span(ctx context.Context, ops string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)
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.
Types ¶
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