Documentation
¶
Overview ¶
Package nettrace implements tracing of requests. Traces are created by nettrace.New, and can then be viewed over HTTP on /debug/traces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
NewContext returns a new context with the given trace attached.
func RegisterHandler ¶
RegisterHandler registers a the trace handler in the given ServeMux, on `/debug/traces`.
func RenderTraces ¶
func RenderTraces(w http.ResponseWriter, req *http.Request)
RenderTraces is an http.Handler that renders the tracing information.
Types ¶
type Trace ¶
type Trace interface {
// NewChild creates a new trace, that is a child of this one.
NewChild(family, title string) Trace
// Link to another trace with the given message.
Link(other Trace, msg string)
// SetMaxEvents sets the maximum number of events that will be stored in
// the trace. It must be called right after initialization.
SetMaxEvents(n int)
// SetError marks that the trace was for an error event.
SetError()
// Printf adds a message to the trace.
Printf(format string, a ...any)
// Errorf adds a message to the trace, marks it as an error, and returns
// an error for it.
Errorf(format string, a ...any) error
// Finish marks the trace as complete.
// The trace should not be used after calling this method.
Finish()
}
Trace represents a single request trace.
func ChildFromContext ¶
ChildFromContext returns a new trace that is a child of the one attached to the context (if any).
func FromContext ¶
FromContext returns the trace attached to the given context (if any).
func FromContextOrNew ¶
FromContextOrNew returns the trace attached to the given context, or a new trace if there is none.