Documentation ¶
Index ¶
- Variables
- func AddTracer(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 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 Logger
- type Logrus
- type NoopTracer
- type OpenTracer
- func (o *OpenTracer) AddTracer(service string) error
- func (o *OpenTracer) Close() error
- func (o *OpenTracer) Disable()
- func (o *OpenTracer) Enable()
- func (o *OpenTracer) Get(service string) Tracer
- func (o *OpenTracer) GetOk(service string) (Tracer, bool)
- func (o *OpenTracer) IsEnabled() bool
- func (o *OpenTracer) Set(service string, tr Tracer)
- func (o *OpenTracer) SetLogger(log Logger)
- func (o *OpenTracer) SetupTracing(name string, opts map[string]interface{})
- type Tracer
Constants ¶
This section is empty.
Variables ¶
var ErrManagerDisabled = errors.New("trace: trace is diabled")
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 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 OpenTracer ¶
type OpenTracer struct {
// contains filtered or unexported fields
}
OpenTracer manages initializing,storage and retrieving on multiple tracers based on service names.
func NewManager ¶
func NewManager(log Logger) *OpenTracer
NewManager returns a new opentrace manager. If log is not nil it will be used to log errors and info by the manager.
func (*OpenTracer) AddTracer ¶
func (o *OpenTracer) AddTracer(service string) error
AddTracer initializes a tracer based on the configuration stored in o for the given service name and caches. This does donthing when there is already a tracer for the given service.
func (*OpenTracer) Close ¶
func (o *OpenTracer) Close() error
Close calls Close on the active tracer.
func (*OpenTracer) Get ¶
func (o *OpenTracer) Get(service string) Tracer
Get returns a tracer for a given service, it returns a NoopTracer if there is no tracer for the service found.
func (*OpenTracer) GetOk ¶
func (o *OpenTracer) GetOk(service string) (Tracer, bool)
GetOk like Get but instead of returning NoopTracer for missing tracer it returns nil and false when the service tracer wasn't found.
func (*OpenTracer) IsEnabled ¶
func (o *OpenTracer) IsEnabled() bool
IsEnabled returns true if the manager is enabled.
func (*OpenTracer) Set ¶
func (o *OpenTracer) Set(service string, tr Tracer)
Set saves tr using service as key on o.
func (*OpenTracer) SetLogger ¶
func (o *OpenTracer) SetLogger(log Logger)
SetLogger sets log as the default logger for o.
func (*OpenTracer) SetupTracing ¶
func (o *OpenTracer) SetupTracing(name string, opts map[string]interface{})