trace

package
v1.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = &logrus.Logger{
	Out: os.Stderr,

	Formatter: log.NewTextFormatter(),
	Hooks:     make(logrus.LevelHooks),
	Level:     logrus.InfoLevel,
}

Functions

func DisableTracing

func DisableTracing()

Disable global tracing.

func EnableTracing

func EnableTracing()

Enable global tracing.

func End

func End(t *Message)

End ends the trace.

func InitLogger

func InitLogger(cfg *log.LoggingConfig) error

Add Syslog hook This method is not thread safe, this is currently not a problem because it is only called once from main

Types

type Entry

type Entry struct {
	// Contains all the fields set by the user.
	Data logrus.Fields
	// contains filtered or unexported fields
}

Entry is like logrus.Entry, but for Operation. Functionality is added as needed.

func (*Entry) Debug

func (e *Entry) Debug(args ...interface{})

type Message

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

trace object used to grab run-time state

func Audit added in v1.5.0

func Audit(msg string, op Operation) *Message

Audit is a wrapper around Begin which logs an Audit message after

func Begin

func Begin(msg string, ctx ...context.Context) *Message

type Operation

type Operation struct {
	context.Context

	// Logger is used to configure an Operation-specific destination for log messages, in addition
	// to the global logger. This logger is passed to any children which are created.
	Logger *logrus.Logger
	// contains filtered or unexported fields
}

func FromContext

func FromContext(ctx context.Context, message string, args ...interface{}) Operation

FromContext will return an Operation

The Operation returned will be one of the following:

The operation in the context value
The operation passed as the context param
A new operation

func FromOperation

func FromOperation(parent Operation, format string, args ...interface{}) Operation

FromOperation creates a child operation from the one supplied uses the same context as the parent

func NewOperation

func NewOperation(ctx context.Context, format string, args ...interface{}) Operation

NewOperation will return a new operation with operationID added as a value to the context

func NewOperationFromID added in v1.5.0

func NewOperationFromID(ctx context.Context, ID *string, format string, args ...interface{}) Operation

NewOperationFromID returns a an Operation with the incoming ID if valid It creates a parent operation with the incoming ID and a child with the parent operation ID as a prefix and a monotonically incremented integer as the suffix

func NewOperationWithLoggerFrom deprecated

func NewOperationWithLoggerFrom(ctx context.Context, oldOp Operation, format string, args ...interface{}) Operation

NewOperationWithLoggerFrom will return a new operation with operationID added as a value to the context and logging settings copied from the supplied operation.

Deprecated: This method was added to aid in converting old code to use operation-based logging.

Its use almost always indicates a broken context/operation model (e.g., a context
being improperly stored in a struct instead of being passed between functions).

func WithCancel

func WithCancel(parent *Operation, format string, args ...interface{}) (Operation, context.CancelFunc)

WithCancel creates a new operation from parent with context.WithCancel

func WithDeadline

func WithDeadline(parent *Operation, expiration time.Time, format string, args ...interface{}) (Operation, context.CancelFunc)

WithDeadline creates a new operation from parent with context.WithDeadline

func WithTimeout

func WithTimeout(parent *Operation, timeout time.Duration, format string, args ...interface{}) (Operation, context.CancelFunc)

WithTimeout creates a new operation from parent with context.WithTimeout

func WithValue

func WithValue(parent *Operation, key, val interface{}, format string, args ...interface{}) Operation

WithValue creates a new operation from parent with context.WithValue

func (*Operation) Auditf added in v1.5.0

func (o *Operation) Auditf(format string, args ...interface{})

func (*Operation) Debug

func (o *Operation) Debug(args ...interface{})

func (*Operation) Debugf

func (o *Operation) Debugf(format string, args ...interface{})

func (Operation) Err

func (o Operation) Err() error

Err returns a non-nil error value after Done is closed. Err returns Canceled if the context was canceled or DeadlineExceeded if the context's deadline passed. No other values for Err are defined. After Done is closed, successive calls to Err return the same value.

func (*Operation) Error

func (o *Operation) Error(args ...interface{})

func (*Operation) Errorf

func (o *Operation) Errorf(format string, args ...interface{})

func (*Operation) Fatal

func (o *Operation) Fatal(args ...interface{})

func (*Operation) Fatalf

func (o *Operation) Fatalf(format string, args ...interface{})

func (*Operation) ID

func (o *Operation) ID() string

func (*Operation) Info

func (o *Operation) Info(args ...interface{})

func (*Operation) Infof

func (o *Operation) Infof(format string, args ...interface{})

func (*Operation) Panic

func (o *Operation) Panic(args ...interface{})

func (*Operation) Panicf

func (o *Operation) Panicf(format string, args ...interface{})

func (Operation) String

func (o Operation) String() string

func (*Operation) Warn

func (o *Operation) Warn(args ...interface{})

func (*Operation) Warnf

func (o *Operation) Warnf(format string, args ...interface{})

func (*Operation) WithFields

func (o *Operation) WithFields(fields logrus.Fields) *Entry

type OperationKey

type OperationKey string
const OpTraceKey OperationKey = "traceKey"

Jump to

Keyboard shortcuts

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