mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
33 lines
671 B
Go
33 lines
671 B
Go
|
package service
|
||
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
// DebugPprof calls the /debug/pprof/ endpoints.
|
||
|
func (c *Client) DebugPprof(name string) ([]byte, error) {
|
||
|
endpoint := "/debug/pprof/" + name
|
||
|
response, err := c.AuthenticatedDo("GET", endpoint, "", nil)
|
||
|
if err != nil {
|
||
|
return nil, errors.Wrapf(err, "GET %s", endpoint)
|
||
|
}
|
||
|
defer response.Body.Close()
|
||
|
|
||
|
if response.StatusCode != http.StatusOK {
|
||
|
return nil, errors.Errorf(
|
||
|
"get pprof received status %d",
|
||
|
response.StatusCode,
|
||
|
)
|
||
|
}
|
||
|
|
||
|
body, err := ioutil.ReadAll(response.Body)
|
||
|
if err != nil {
|
||
|
return nil, errors.Wrap(err, "read pprof response body")
|
||
|
}
|
||
|
|
||
|
return body, nil
|
||
|
}
|