Documentation ¶
Index ¶
- Constants
- func Begin()
- func End(parent int)
- func HasEvent() bool
- func ID() int
- func Notef(title string, format string, args ...interface{})
- func Profile(f func(), name string)
- func Profilef(f func(), title string, name string, format string, args ...interface{})
- func Profiling() bool
- func ReadCloser(r io.ReadCloser, name string, note string) io.ReadCloser
- func Reader(r io.Reader, name string, note string) io.Reader
- type Event
- type Note
- type Timed
- type Timing
Constants ¶
const ( // HeaderName is the header used for transmitting profiling // information while profiling a remote application. HeaderName = "X-Gondola-Profile" // Salt is the salt used for signing the app secret for requesting // profiling information. Salt = "gnd.la/app/profile.salt" )
const On = profileIsOn
Variables ¶
This section is empty.
Functions ¶
func Begin ¶
func Begin()
Begin enables profiling for the current goroutine. This function is idempotent. Any goroutine which calls Begin must also call End to avoid leaking resources.
func End ¶
func End(parent int)
End removes any profiling data for this goroutine. It must called before the goroutine ends for each goroutine which called Begin(). If parent is non-zero, the events in the ending goroutine are added to the goroutine with the given ID.
func HasEvent ¶
func HasEvent() bool
HasEvent returns true iff there's current an ongoing timed event for the current goroutine.
func Profile ¶
func Profile(f func(), name string)
Profile is a shorthand function for calling Start(), executing f and the calling Timed.End() on the resulting Timed.
func Profilef ¶
Profilef is a shorthand function for calling Startf(), executing f and the calling Timed.End() on the resulting Timed.
func Profiling ¶
func Profiling() bool
Profiling returns wheter profiling has been enabled for this goroutine.
func ReadCloser ¶
func ReadCloser(r io.ReadCloser, name string, note string) io.ReadCloser
ReadCloser works like Reader, but wraps an io.ReadCloser.
Types ¶
type Event ¶
type Event struct { Started time.Time `json:"s"` Ended time.Time `json:"e"` Notes []*Note `json:"n"` }
Event represents a finished event when its timing information and any notes it might have attached.
type Timed ¶
type Timed struct {
// contains filtered or unexported fields
}
Timed represents an ongoing timed event. Use Start or Startf to start a timed event.
func Start ¶
Start starts a timed event. Use Timed.End to terminate the event or Timed.AutoEnd to finish it when the request finishes processing. Note that if profiling is not enabled for the current goroutine, this function does nothing and returns an empty event.
func Startf ¶
Startf is a shorthand function for calling Start and then Timed.Notef on the resulting Ev.
type Timing ¶
Timing represents a set of events of the same kind.
func Timings ¶
func Timings() []*Timing
Timings returns the available timings for the current goroutine. Note that calling Timings will end any events which have been set to automatically end (with Timed.AutoEnd) so this function should only be called at the end of the request lifecycle.