Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct { Key string Value interface{} }
Field is a key value pair that provides additional details about the trace.
type Trace ¶
type Trace struct {
// contains filtered or unexported fields
}
Trace keeps track of a set of "steps" and allows us to log a specific step if it took longer than its share of the total allowed time
func New ¶
New creates a Trace with the specified name. The name identifies the operation to be traced. The Fields add key value pairs to provide additional details about the trace, such as operation inputs.
func (*Trace) Log ¶
func (t *Trace) Log()
Log is used to dump all the steps in the Trace. It also logs the nested trace messages using indentation. If the Trace is nested it is not immediately logged. Instead, it is logged when the trace it is nested within is logged.
func (*Trace) LogIfLong ¶
LogIfLong only logs the trace if the duration of the trace exceeds the threshold. Only steps that took longer than their share or the given threshold are logged. If klog is at verbosity level 4 or higher and the trace took longer than the threshold, all substeps and subtraces are logged. Otherwise, only those which took longer than their own threshold. If the Trace is nested it is not immediately logged. Instead, it is logged when the trace it is nested within is logged.
func (*Trace) Nest ¶
Nest adds a nested trace with the given message and fields and returns it. As a convenience, if the receiver is nil, returns a top level trace. This allows one to call FromContext(ctx).Nest without having to check if the trace in the context is nil.