|
|
@ -24,20 +24,20 @@ import ( |
|
|
|
"io" |
|
|
|
"io" |
|
|
|
"io/ioutil" |
|
|
|
"io/ioutil" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
|
|
|
|
"net/url" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// ProfilerType represents the profiler type
|
|
|
|
// ProfilerType represents the profiler type
|
|
|
|
// passed to the profiler subsystem, currently
|
|
|
|
// passed to the profiler subsystem.
|
|
|
|
// it can be only "cpu", "mem" or "block"
|
|
|
|
|
|
|
|
type ProfilerType string |
|
|
|
type ProfilerType string |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Different supported profiler types.
|
|
|
|
const ( |
|
|
|
const ( |
|
|
|
// ProfilerCPU represents CPU profiler type
|
|
|
|
ProfilerCPU ProfilerType = "cpu" // represents CPU profiler type
|
|
|
|
ProfilerCPU = ProfilerType("cpu") |
|
|
|
ProfilerMEM = "mem" // represents MEM profiler type
|
|
|
|
// ProfilerMEM represents MEM profiler type
|
|
|
|
ProfilerBlock = "block" // represents Block profiler type
|
|
|
|
ProfilerMEM = ProfilerType("mem") |
|
|
|
ProfilerMutex = "mutex" // represents Mutex profiler type
|
|
|
|
// ProfilerBlock represents Block profiler type
|
|
|
|
ProfilerTrace = "trace" // represents Trace profiler type
|
|
|
|
ProfilerBlock = ProfilerType("block") |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// StartProfilingResult holds the result of starting
|
|
|
|
// StartProfilingResult holds the result of starting
|
|
|
@ -51,9 +51,11 @@ type StartProfilingResult struct { |
|
|
|
// StartProfiling makes an admin call to remotely start profiling on a standalone
|
|
|
|
// StartProfiling makes an admin call to remotely start profiling on a standalone
|
|
|
|
// server or the whole cluster in case of a distributed setup.
|
|
|
|
// server or the whole cluster in case of a distributed setup.
|
|
|
|
func (adm *AdminClient) StartProfiling(profiler ProfilerType) ([]StartProfilingResult, error) { |
|
|
|
func (adm *AdminClient) StartProfiling(profiler ProfilerType) ([]StartProfilingResult, error) { |
|
|
|
path := fmt.Sprintf("/v1/profiling/start/%s", profiler) |
|
|
|
v := url.Values{} |
|
|
|
|
|
|
|
v.Set("profilerType", string(profiler)) |
|
|
|
resp, err := adm.executeMethod("POST", requestData{ |
|
|
|
resp, err := adm.executeMethod("POST", requestData{ |
|
|
|
relPath: path, |
|
|
|
relPath: "/v1/profiling/start", |
|
|
|
|
|
|
|
queryValues: v, |
|
|
|
}) |
|
|
|
}) |
|
|
|
defer closeResponse(resp) |
|
|
|
defer closeResponse(resp) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|