Documentation ¶
Overview ¶
Package debugstatus provides facilities for inspecting information about a running HTTP service.
Index ¶
- Variables
- func Check(checkers ...CheckerFunc) map[string]CheckResult
- type CheckResult
- type CheckerFunc
- type Collector
- type DebugInfoRequest
- type DebugPprofEndpointsRequest
- type DebugPprofRequest
- type DebugStatusRequest
- type Handler
- func (h *Handler) DebugInfo(*DebugInfoRequest) (Version, error)
- func (h *Handler) DebugPprof(p httprequest.Params, _ *DebugPprofRequest) error
- func (h *Handler) DebugPprofEndpoints(p httprequest.Params, r *DebugPprofEndpointsRequest) error
- func (h *Handler) DebugStatus(*DebugStatusRequest) (map[string]CheckResult, error)
- type Pinger
- type Version
Constants ¶
This section is empty.
Variables ¶
var ErrNoPprofConfigured = errgo.New("no pprof access configured")
ErrNoPprofConfigured is the error returned on access to endpoints when Handler.CheckPprofAllowed is nil.
var StartTime = time.Now().UTC()
StartTime holds the time that the code started running.
Functions ¶
func Check ¶
func Check(checkers ...CheckerFunc) map[string]CheckResult
Check collects the status check results from the given checkers.
Types ¶
type CheckResult ¶
type CheckResult struct { // Name is the human readable name for the check. Name string // Value is the check result. Value string // Passed reports whether the check passed. Passed bool // Duration holds the duration that the // status check took to run. Duration time.Duration }
CheckResult holds the result of a single status check.
func ServerStartTime ¶
func ServerStartTime() (key string, result CheckResult)
ServerStartTime reports the time when the application was started.
type CheckerFunc ¶
type CheckerFunc func() (key string, result CheckResult)
CheckerFunc represents a function returning the check machine friendly key and the result.
func Connection ¶
func Connection(p Pinger) CheckerFunc
Connection returns a status checker reporting whether the given Pinger is connected.
func MongoCollections ¶
func MongoCollections(c Collector) CheckerFunc
MongoCollections returns a status checker checking that all the expected Mongo collections are present in the database.
func Rename ¶
func Rename(newKey, newName string, check CheckerFunc) CheckerFunc
Rename changes the key and/or result name returned by the given check. It is possible to pass an empty string to avoid changing one of the values. This means that if both key are name are empty, this closure is a no-op.
type Collector ¶
type Collector interface { // Collections returns the Mongo collections that we expect to exist in // the Mongo database. Collections() []*mgo.Collection // CollectionNames returns the names of the collections actually present in // the Mongo database. CollectionNames() ([]string, error) }
Collector is an interface that groups the methods used to check that a Mongo database has the expected collections. It is usually implemented by types extending mgo.Database to add the Collections() method.
type DebugInfoRequest ¶
type DebugInfoRequest struct {
httprequest.Route `httprequest:"GET /debug/info"`
}
DebugInfoRequest describes the /debug/info endpoint.
type DebugPprofEndpointsRequest ¶
type DebugPprofEndpointsRequest struct { httprequest.Route `httprequest:"GET /debug/pprof/:name"` Name string `httprequest:"name,path"` }
DebugPprofEndpointsRequest describes the endpoints under /debug/prof.
type DebugPprofRequest ¶
type DebugPprofRequest struct {
httprequest.Route `httprequest:"GET /debug/pprof/"`
}
DebugPprofRequest describes the /debug/pprof/ endpoint.
type DebugStatusRequest ¶
type DebugStatusRequest struct {
httprequest.Route `httprequest:"GET /debug/status"`
}
DebugStatusRequest describes the /debug/status endpoint.
type Handler ¶
type Handler struct { // Check will be called to obtain the current health of the // system. It should return a map as returned from the // Check function. If this is nil, an empty result will // always be returned from /debug/status. Check func() map[string]CheckResult // Version should hold the current version // of the binary running the server, served // from the /debug/info endpoint. Version Version // CheckPprofAllowed will be used to check whether the // given pprof request should be allowed. // It should return an error if not, which will not be masked. // If this is nil, no access will be allowed to any // of the endpoints under /debug/pprof - the // error returned will be ErrNoPprofConfigured. CheckPprofAllowed func(req *http.Request) error }
Handler implements a type that can be used with httprequest.Handlers to serve a standard set of /debug endpoints, including the version of the system, its current health status the runtime profiling information.
func (*Handler) DebugInfo ¶
func (h *Handler) DebugInfo(*DebugInfoRequest) (Version, error)
DebugInfo returns version information on the current server.
func (*Handler) DebugPprof ¶
func (h *Handler) DebugPprof(p httprequest.Params, _ *DebugPprofRequest) error
DebugPprof serves index information on the available pprof endpoints.
func (*Handler) DebugPprofEndpoints ¶
func (h *Handler) DebugPprofEndpoints(p httprequest.Params, r *DebugPprofEndpointsRequest) error
DebugPprofEndpoints serves all the endpoints under DebugPprof.
func (*Handler) DebugStatus ¶
func (h *Handler) DebugStatus(*DebugStatusRequest) (map[string]CheckResult, error)
DebugStatus returns the current status of the server.