mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 12:16:44 +00:00
internal/debug: add basic authentication support for pyroscope profiler
This commit is contained in:
parent
2c3aa48b5b
commit
aa6a37d591
2 changed files with 30 additions and 5 deletions
|
|
@ -150,6 +150,8 @@ func (l *pyroscopeLogger) Errorf(format string, v ...interface{}) {
|
|||
// StartPyroscopeProfiler starts the Pyroscope profiler for later use
|
||||
func (h *HandlerT) StartPyroscopeProfiler(
|
||||
server string,
|
||||
authUsername string,
|
||||
authPassword string,
|
||||
tags map[string]string,
|
||||
) error {
|
||||
h.mu.Lock()
|
||||
|
|
@ -160,10 +162,12 @@ func (h *HandlerT) StartPyroscopeProfiler(
|
|||
}
|
||||
profiler, err := pyroscope.Start(
|
||||
pyroscope.Config{
|
||||
ApplicationName: "geth",
|
||||
ServerAddress: server,
|
||||
Logger: &pyroscopeLogger{Logger: log.Root().With("module", "pyroscope")},
|
||||
Tags: tags,
|
||||
ApplicationName: "geth",
|
||||
ServerAddress: server,
|
||||
BasicAuthUser: authUsername,
|
||||
BasicAuthPassword: authPassword,
|
||||
Logger: &pyroscopeLogger{Logger: log.Root().With("module", "pyroscope")},
|
||||
Tags: tags,
|
||||
ProfileTypes: []pyroscope.ProfileType{
|
||||
// Enabling all profile types
|
||||
pyroscope.ProfileCPU,
|
||||
|
|
|
|||
|
|
@ -153,6 +153,18 @@ var (
|
|||
Value: "http://localhost:4040",
|
||||
Category: flags.LoggingCategory,
|
||||
}
|
||||
pyroscopeAuthUsernameFlag = &cli.StringFlag{
|
||||
Name: "pyroscope.username",
|
||||
Usage: "Pyroscope basic authentication username",
|
||||
Value: "",
|
||||
Category: flags.LoggingCategory,
|
||||
}
|
||||
pyroscopeAuthPasswordFlag = &cli.StringFlag{
|
||||
Name: "pyroscope.password",
|
||||
Usage: "Pyroscope basic authentication password",
|
||||
Value: "",
|
||||
Category: flags.LoggingCategory,
|
||||
}
|
||||
pyroscopeTagsFlag = &cli.StringFlag{
|
||||
Name: "pyroscope.tags",
|
||||
Usage: "Comma separated list of key=value tags to add to profiling data",
|
||||
|
|
@ -183,6 +195,8 @@ var Flags = []cli.Flag{
|
|||
traceFlag,
|
||||
pyroscopeFlag,
|
||||
pyroscopeServerFlag,
|
||||
pyroscopeAuthUsernameFlag,
|
||||
pyroscopeAuthPasswordFlag,
|
||||
pyroscopeTagsFlag,
|
||||
}
|
||||
|
||||
|
|
@ -324,6 +338,8 @@ func Setup(ctx *cli.Context) error {
|
|||
// Pyroscope profiling
|
||||
if ctx.Bool(pyroscopeFlag.Name) {
|
||||
pyroscopeServer := ctx.String(pyroscopeServerFlag.Name)
|
||||
pyroscopeAuthUsername := ctx.String(pyroscopeAuthUsernameFlag.Name)
|
||||
pyroscopeAuthPassword := ctx.String(pyroscopeAuthPasswordFlag.Name)
|
||||
|
||||
rawTags := ctx.String(pyroscopeTagsFlag.Name)
|
||||
tags := make(map[string]string)
|
||||
|
|
@ -335,7 +351,12 @@ func Setup(ctx *cli.Context) error {
|
|||
}
|
||||
}
|
||||
|
||||
Handler.StartPyroscopeProfiler(pyroscopeServer, tags)
|
||||
Handler.StartPyroscopeProfiler(
|
||||
pyroscopeServer,
|
||||
pyroscopeAuthUsername,
|
||||
pyroscopeAuthPassword,
|
||||
tags,
|
||||
)
|
||||
}
|
||||
|
||||
if len(logFile) > 0 || rotation {
|
||||
|
|
|
|||
Loading…
Reference in a new issue