cockroach: Index | Files | Directories

package debug

import ""


Package Files

cpuprofile.go logspy.go server.go


const Endpoint = "/debug/"

Endpoint is the entry point under which the debug tools are housed.


var DebugRemote = func() *settings.StringSetting {
    s := settings.RegisterValidatedStringSetting(
        "set to enable remote debugging, localhost-only or disable (any, local, off)",
        func(sv *settings.Values, s string) error {
            switch RemoteMode(strings.ToLower(s)) {
            case RemoteOff, RemoteLocal, RemoteAny:
                return nil
                return errors.Errorf("invalid mode: '%s'", s)
    return s

DebugRemote controls which clients are allowed to access certain confidential debug pages, such as those served under the /debug/ prefix.

func CPUProfileDo Uses

func CPUProfileDo(st *cluster.Settings, typ cluster.CPUProfileType, do func() error) error

CPUProfileDo invokes the closure while enabling (and disabling) the supplied CPUProfileMode. Errors if the profiling mode could not be set or if do() returns an error.

func CPUProfileHandler Uses

func CPUProfileHandler(st *cluster.Settings, w http.ResponseWriter, r *http.Request)

CPUProfileHandler is replacement for `pprof.Profile` that supports additional options.

func GatewayRemoteAllowed Uses

func GatewayRemoteAllowed(ctx context.Context, st *cluster.Settings) bool

GatewayRemoteAllowed returns whether a request that has been passed through the grpc gateway should be allowed accessed to privileged debugging information. Because this function assumes the presence of a context field populated by the grpc gateway, it's not applicable for other uses.

type CPUProfileOptions Uses

type CPUProfileOptions struct {
    // Number of seconds to profile for.
    Seconds int32
    // Whether to enable pprof labels while the profile is taken.
    WithLabels bool

CPUProfileOptions contains options for generating a CPU profile.

func CPUProfileOptionsFromRequest Uses

func CPUProfileOptionsFromRequest(r *http.Request) CPUProfileOptions

CPUProfileOptionsFromRequest parses the `seconds` and `labels` fragments from the URL and populates CPUProfileOptions from it.

For convenience, `labels` defaults to true, that is, `?labels=false` must be specified to disable them. `seconds` defaults to the pprof default of 30s.

func (CPUProfileOptions) Type Uses

func (opts CPUProfileOptions) Type() cluster.CPUProfileType

Type returns the CPUProfileType corresponding to the options.

type RemoteMode Uses

type RemoteMode string

RemoteMode controls who can access /debug/requests.

const (
    // RemoteOff disallows access to /debug/requests.
    RemoteOff RemoteMode = "off"
    // RemoteLocal allows only host-local access to /debug/requests.
    RemoteLocal RemoteMode = "local"
    // RemoteAny allows all access to /debug/requests.
    RemoteAny RemoteMode = "any"

type Server Uses

type Server struct {
    // contains filtered or unexported fields

Server serves the /debug/* family of tools.

func NewServer Uses

func NewServer(st *cluster.Settings, hbaConfDebugFn http.HandlerFunc) *Server

NewServer sets up a debug server.

func (*Server) RegisterEngines Uses

func (ds *Server) RegisterEngines(specs []base.StoreSpec, engines []storage.Engine) error

RegisterEngines setups up debug engine endpoints for the known storage engines.

func (*Server) ServeHTTP Uses

func (ds *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves various tools under the /debug endpoint. It restricts access according to the `server.remote_debugging.mode` cluster variable.



Package debug imports 34 packages (graph) and is imported by 13 packages. Updated 2020-07-29. Refresh now. Tools for package owners.