mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
Improve profiling API endpoint docs
This commit is contained in:
parent
eda7a122db
commit
52a2a1f673
1 changed files with 29 additions and 15 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/safing/portbase/utils/debug"
|
"github.com/safing/portbase/utils/debug"
|
||||||
|
@ -44,11 +45,16 @@ func registerDebugEndpoints() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := RegisterEndpoint(Endpoint{
|
if err := RegisterEndpoint(Endpoint{
|
||||||
Path: "debug/cpu",
|
Path: "debug/cpu",
|
||||||
Read: PermitAnyone,
|
Read: PermitAnyone,
|
||||||
DataFunc: handleCPUProfile,
|
DataFunc: handleCPUProfile,
|
||||||
Name: "Get CPU Profile",
|
Name: "Get CPU Profile",
|
||||||
Description: "",
|
Description: strings.ReplaceAll(`Gather and return the CPU profile.
|
||||||
|
This data needs to gathered over a period of time, which is specified using the duration parameter.
|
||||||
|
|
||||||
|
You can easily view this data in your browser with this command (with Go installed):
|
||||||
|
"go tool pprof -http :8888 http://127.0.0.1:817/api/v1/debug/cpu"
|
||||||
|
`, `"`, "`"),
|
||||||
Parameters: []Parameter{{
|
Parameters: []Parameter{{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Field: "duration",
|
Field: "duration",
|
||||||
|
@ -60,21 +66,29 @@ func registerDebugEndpoints() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := RegisterEndpoint(Endpoint{
|
if err := RegisterEndpoint(Endpoint{
|
||||||
Path: "debug/heap",
|
Path: "debug/heap",
|
||||||
Read: PermitAnyone,
|
Read: PermitAnyone,
|
||||||
DataFunc: handleHeapProfile,
|
DataFunc: handleHeapProfile,
|
||||||
Name: "Get Heap Profile",
|
Name: "Get Heap Profile",
|
||||||
Description: "",
|
Description: strings.ReplaceAll(`Gather and return the heap memory profile.
|
||||||
|
|
||||||
|
You can easily view this data in your browser with this command (with Go installed):
|
||||||
|
"go tool pprof -http :8888 http://127.0.0.1:817/api/v1/debug/heap"
|
||||||
|
`, `"`, "`"),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := RegisterEndpoint(Endpoint{
|
if err := RegisterEndpoint(Endpoint{
|
||||||
Path: "debug/allocs",
|
Path: "debug/allocs",
|
||||||
Read: PermitAnyone,
|
Read: PermitAnyone,
|
||||||
DataFunc: handleAllocsProfile,
|
DataFunc: handleAllocsProfile,
|
||||||
Name: "Get Allocs Profile",
|
Name: "Get Allocs Profile",
|
||||||
Description: "",
|
Description: strings.ReplaceAll(`Gather and return the memory allocation profile.
|
||||||
|
|
||||||
|
You can easily view this data in your browser with this command (with Go installed):
|
||||||
|
"go tool pprof -http :8888 http://127.0.0.1:817/api/v1/debug/allocs"
|
||||||
|
`, `"`, "`"),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue