package traceutil
import "go.etcd.io/etcd/pkg/v3/traceutil"
Package traceutil implements tracing utilities using "context".
Index ¶
- Constants
- type Field
- type Trace
- func Get(ctx context.Context) *Trace
- func New(op string, lg *zap.Logger, fields ...Field) *Trace
- func TODO() *Trace
- func (t *Trace) AddField(fields ...Field)
- func (t *Trace) GetStartTime() time.Time
- func (t *Trace) InsertStep(at int, time time.Time, msg string, fields ...Field)
- func (t *Trace) IsEmpty() bool
- func (t *Trace) Log()
- func (t *Trace) LogAllStepsIfLong(threshold time.Duration)
- func (t *Trace) LogIfLong(threshold time.Duration)
- func (t *Trace) LogWithStepThreshold(threshold time.Duration)
- func (t *Trace) SetStartTime(time time.Time)
- func (t *Trace) StartSubTrace(fields ...Field)
- func (t *Trace) Step(msg string, fields ...Field)
- func (t *Trace) StepWithFunction(f func(), msg string, fields ...Field)
- func (t *Trace) StopSubTrace(fields ...Field)
Constants ¶
const ( TraceKey = "trace" StartTimeKey = "startTime" )
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 New ¶
func TODO ¶
func TODO() *Trace
TODO returns a non-nil, empty Trace
func (*Trace) AddField ¶
func (*Trace) GetStartTime ¶
func (*Trace) InsertStep ¶
func (*Trace) IsEmpty ¶
func (*Trace) Log ¶
func (t *Trace) Log()
Log dumps all steps in the Trace
func (*Trace) LogAllStepsIfLong ¶
LogAllStepsIfLong dumps all logs if the duration is longer than threshold
func (*Trace) LogIfLong ¶
LogIfLong dumps logs if the duration is longer than threshold
func (*Trace) LogWithStepThreshold ¶
LogWithStepThreshold only dumps step whose duration is longer than step threshold
func (*Trace) SetStartTime ¶
func (*Trace) StartSubTrace ¶
StartSubTrace adds step to trace as a start sign of sublevel trace All steps in the subtrace will log out the input fields of this function
func (*Trace) Step ¶
Step adds step to trace
func (*Trace) StepWithFunction ¶
StepWithFunction will measure the input function as a single step
func (*Trace) StopSubTrace ¶
StopSubTrace adds step to trace as a end sign of sublevel trace All steps in the subtrace will log out the input fields of this function
Source Files ¶
trace.go
- Version
- v3.5.18 (latest)
- Published
- Jan 24, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 5 days ago –
Tools for package owners.