Add PPROFLISTEN (#1019)
* Add PPROFLISTEN env var * Direct logging to more useful places * Space
This commit is contained in:
parent
0c892d59fa
commit
32624697fd
3 changed files with 15 additions and 2 deletions
|
|
@ -18,6 +18,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
|
@ -79,6 +80,17 @@ func callerPrettyfier(f *runtime.Frame) (string, string) {
|
|||
return funcname, filename
|
||||
}
|
||||
|
||||
// SetupPprof starts a pprof listener. We use the DefaultServeMux here because it is
|
||||
// simplest, and it gives us the freedom to run pprof on a separate port.
|
||||
func SetupPprof() {
|
||||
if hostPort := os.Getenv("PPROFLISTEN"); hostPort != "" {
|
||||
logrus.Warn("Starting pprof on ", hostPort)
|
||||
go func() {
|
||||
logrus.WithError(http.ListenAndServe(hostPort, nil)).Error("Failed to setup pprof listener")
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// SetupStdLogging configures the logging format to standard output. Typically, it is called when the config is not yet loaded.
|
||||
func SetupStdLogging() {
|
||||
logrus.SetReportCaller(true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue