// Do calls f with a copy of the parent context with the // given labels added to the parent's label map. // Goroutines spawned while executing f will inherit the augmented label-set. // Each key/value pair in labels is inserted into the label map in the // order provided, overriding any previous value for the same key. // The augmented label map will be set for the duration of the call to f // and restored once f returns. func Do(ctx context.Context, labels LabelSet, f func(context.Context))


// ForLabels invokes f with each label set on the context. // The function f should return true to continue iteration or false to stop iteration early. func ForLabels(ctx context.Context, f func(key, value string) bool)


// Label returns the value of the label with the given key on ctx, and a boolean indicating // whether that label exists. func Label(ctx context.Context, key string) (string, bool)


// Labels takes an even number of strings representing key-value pairs // and makes a LabelSet containing them. // A label overwrites a prior label with the same key. // Currently only the CPU and goroutine profiles utilize any labels // information. // See https://golang.org/issue/23458 for details. func Labels(args ...string) LabelSet


// Lookup returns the profile with the given name, or nil if no such profile exists. func Lookup(name string) *Profile


// NewProfile creates a new profile with the given name. // If a profile with that name already exists, NewProfile panics. // The convention is to use a 'import/path.' prefix to create // separate name spaces for each package. // For compatibility with various tools that read pprof data, // profile names should not contain spaces. func NewProfile(name string) *Profile


// Profiles returns a slice of all the known profiles, sorted by name. func Profiles() []*Profile


// SetGoroutineLabels sets the current goroutine's labels to match ctx. // A new goroutine inherits the labels of the goroutine that created it. // This is a lower-level API than Do, which should be used instead when possible. func SetGoroutineLabels(ctx context.Context)


// StartCPUProfile enables CPU profiling for the current process. // While profiling, the profile will be buffered and written to w. // StartCPUProfile returns an error if profiling is already enabled. // // On Unix-like systems, StartCPUProfile does not work by default for // Go code built with -buildmode=c-archive or -buildmode=c-shared. // StartCPUProfile relies on the SIGPROF signal, but that signal will // be delivered to the main program's SIGPROF signal handler (if any) // not to the one used by Go. To make it work, call os/signal.Notify // for syscall.SIGPROF, but note that doing so may break any profiling // being done by the main program. func StartCPUProfile(w io.Writer) error


// StopCPUProfile stops the current CPU profile, if any. // StopCPUProfile only returns after all the writes for the // profile have completed. func StopCPUProfile()


// WithLabels returns a new context.Context with the given labels added. // A label overwrites a prior label with the same key. func WithLabels(ctx context.Context, labels LabelSet) context.Context


// WriteHeapProfile is shorthand for Lookup("heap").WriteTo(w, 0). // It is preserved for backwards compatibility. func WriteHeapProfile(w io.Writer) error