traceutil

package
v3.4.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package traceutil implements tracing utilities using "context".

Index

Constants

View Source
const (
	TraceKey     = "trace"
	StartTimeKey = "startTime"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Key   string
	Value interface{}
}

Field is a kv pair to record additional details of the trace.

type Trace

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

func Get

func Get(ctx context.Context) *Trace

func New

func New(op string, lg *zap.Logger, fields ...Field) *Trace

func TODO

func TODO() *Trace

TODO returns a non-nil, empty Trace

func (*Trace) AddField

func (t *Trace) AddField(fields ...Field)

func (*Trace) DisableStep

func (t *Trace) DisableStep()

DisableStep sets the flag to prevent the trace from adding steps

func (*Trace) EnableStep

func (t *Trace) EnableStep()

EnableStep re-enable the trace to add steps

func (*Trace) GetStartTime

func (t *Trace) GetStartTime() time.Time

func (*Trace) InsertStep

func (t *Trace) InsertStep(at int, time time.Time, msg string, fields ...Field)

func (*Trace) Log

func (t *Trace) Log()

Log dumps all steps in the Trace

func (*Trace) LogIfLong

func (t *Trace) LogIfLong(threshold time.Duration)

LogIfLong dumps logs if the duration is longer than threshold

func (*Trace) LogWithStepThreshold

func (t *Trace) LogWithStepThreshold(threshold time.Duration)

LogWithStepThreshold only dumps step whose duration is longer than step threshold

func (*Trace) SetStartTime

func (t *Trace) SetStartTime(time time.Time)

func (*Trace) Step

func (t *Trace) Step(msg string, fields ...Field)

Step adds step to trace

Jump to

Keyboard shortcuts

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