mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 01:02:42 +08:00
profiling: Support binding pprof server to custom network interfaces (#36580)
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
This commit is contained in:
@ -63,6 +63,7 @@ func main() {
|
||||
v = flag.Bool("v", false, "prints current version and exits")
|
||||
vv = flag.Bool("vv", false, "prints current version, all dependencies and exits")
|
||||
profile = flag.Bool("profile", false, "Turn on pprof profiling")
|
||||
profileAddr = flag.String("profile-addr", "localhost", "Define custom address for profiling")
|
||||
profilePort = flag.Uint64("profile-port", 6060, "Define custom port for profiling")
|
||||
tracing = flag.Bool("tracing", false, "Turn on tracing")
|
||||
tracingFile = flag.String("tracing-file", "trace.out", "Define tracing output file")
|
||||
@ -83,7 +84,7 @@ func main() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
profileDiagnostics := newProfilingDiagnostics(*profile, *profilePort)
|
||||
profileDiagnostics := newProfilingDiagnostics(*profile, *profileAddr, *profilePort)
|
||||
if err := profileDiagnostics.overrideWithEnv(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err.Error())
|
||||
os.Exit(1)
|
||||
@ -96,10 +97,10 @@ func main() {
|
||||
}
|
||||
|
||||
if profileDiagnostics.enabled {
|
||||
fmt.Println("diagnostics: pprof profiling enabled", "port", profileDiagnostics.port)
|
||||
fmt.Println("diagnostics: pprof profiling enabled", "addr", profileDiagnostics.addr, "port", profileDiagnostics.port)
|
||||
runtime.SetBlockProfileRate(1)
|
||||
go func() {
|
||||
err := http.ListenAndServe(fmt.Sprintf("localhost:%d", profileDiagnostics.port), nil)
|
||||
err := http.ListenAndServe(fmt.Sprintf("%s:%d", profileDiagnostics.addr, profileDiagnostics.port), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user