Documentation

Overview

    Package dump provides the endpoint "debug/dump", registered with http.DefaultServeMux, which returns a dump of useful diagnostic information as a tarball. The base configuration includes several useful diagnostics (see init). You may also register your own dump parts to be included, e.g.:

    Register("mystuff", func(ctx context.Context, w io.Writer) error {
        w.Write([]byte("mystuff diagnostic data"))
        return nil
    })
    

    The endpoint responds with a gzipped tarball. The Content-Disposition of the response suggests a pseudo-unique filename to make it easier to deal with multiple dumps. Use curl flags to accept the suggested filename (recommended).

    curl -OJ http://example:1234/debug/dump
    

    Note that it will take at least 30 seconds to respond, as some of the parts of the base configuration are 30-second profiles.

    Index

    Constants

    This section is empty.

    Variables

    View Source
    var DefaultRegistry = NewRegistry(readExec())

      DefaultRegistry is a default registry that has this process's GUID as its ID.

      Functions

      func Name

      func Name() string

        Name returns the name of the default registry. See (*Registry).Name.

        func Register

        func Register(name string, f Func)

          Register registers a new part to be included in the dump of the DefaultRegistry. name will become the filename of the part file in the dump tarball. f will be called to produce the contents of that file.

          func WriteDump

          func WriteDump(ctx context.Context, pfx string, w io.Writer)

            WriteDump writes a dump of the default registry.

            Types

            type Func

            type Func func(ctx context.Context, w io.Writer) error

              Func is the function to be called when producing a dump for a part.

              type Registry

              type Registry struct {
              	// contains filtered or unexported fields
              }

                Registry maintains the set of parts that will compose the dump.

                func NewRegistry

                func NewRegistry(id string) *Registry

                  NewRegistry returns a new registry for the parts to be included in the dump.

                  func (*Registry) Name

                  func (reg *Registry) Name() string

                    Name returns a name for reg that is convenient for naming dump files, as it is pseudo-unique and includes the registry ID, the time at which the registry was created, and the duration from that creation time.

                    func (*Registry) Register

                    func (reg *Registry) Register(name string, f Func)

                      Register registers a new part to be included in the dump of reg. Name will become the filename of the part file in the dump tarball. Func f will be called to produce the contents of that file.

                      func (*Registry) ServeHTTP

                      func (reg *Registry) ServeHTTP(w http.ResponseWriter, r *http.Request)

                        ServeHTTP serves the dump as a tarball, with a Content-Disposition set with a unique filename.

                        func (*Registry) WriteDump

                        func (reg *Registry) WriteDump(ctx context.Context, pfx string, w io.Writer)

                          WriteDump writes the dump to w. pfx is prepended to the names of the parts of the dump, e.g. if pfx == "dump-123" and part name == "cpu", "dump-123/cpu" will be written into the archive. It returns no error, as it is best-effort.

                          Source Files