mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +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
|
// StartPyroscopeProfiler starts the Pyroscope profiler for later use
|
||||||
func (h *HandlerT) StartPyroscopeProfiler(
|
func (h *HandlerT) StartPyroscopeProfiler(
|
||||||
server string,
|
server string,
|
||||||
|
authUsername string,
|
||||||
|
authPassword string,
|
||||||
tags map[string]string,
|
tags map[string]string,
|
||||||
) error {
|
) error {
|
||||||
h.mu.Lock()
|
h.mu.Lock()
|
||||||
|
|
@ -160,10 +162,12 @@ func (h *HandlerT) StartPyroscopeProfiler(
|
||||||
}
|
}
|
||||||
profiler, err := pyroscope.Start(
|
profiler, err := pyroscope.Start(
|
||||||
pyroscope.Config{
|
pyroscope.Config{
|
||||||
ApplicationName: "geth",
|
ApplicationName: "geth",
|
||||||
ServerAddress: server,
|
ServerAddress: server,
|
||||||
Logger: &pyroscopeLogger{Logger: log.Root().With("module", "pyroscope")},
|
BasicAuthUser: authUsername,
|
||||||
Tags: tags,
|
BasicAuthPassword: authPassword,
|
||||||
|
Logger: &pyroscopeLogger{Logger: log.Root().With("module", "pyroscope")},
|
||||||
|
Tags: tags,
|
||||||
ProfileTypes: []pyroscope.ProfileType{
|
ProfileTypes: []pyroscope.ProfileType{
|
||||||
// Enabling all profile types
|
// Enabling all profile types
|
||||||
pyroscope.ProfileCPU,
|
pyroscope.ProfileCPU,
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,18 @@ var (
|
||||||
Value: "http://localhost:4040",
|
Value: "http://localhost:4040",
|
||||||
Category: flags.LoggingCategory,
|
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{
|
pyroscopeTagsFlag = &cli.StringFlag{
|
||||||
Name: "pyroscope.tags",
|
Name: "pyroscope.tags",
|
||||||
Usage: "Comma separated list of key=value tags to add to profiling data",
|
Usage: "Comma separated list of key=value tags to add to profiling data",
|
||||||
|
|
@ -183,6 +195,8 @@ var Flags = []cli.Flag{
|
||||||
traceFlag,
|
traceFlag,
|
||||||
pyroscopeFlag,
|
pyroscopeFlag,
|
||||||
pyroscopeServerFlag,
|
pyroscopeServerFlag,
|
||||||
|
pyroscopeAuthUsernameFlag,
|
||||||
|
pyroscopeAuthPasswordFlag,
|
||||||
pyroscopeTagsFlag,
|
pyroscopeTagsFlag,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,6 +338,8 @@ func Setup(ctx *cli.Context) error {
|
||||||
// Pyroscope profiling
|
// Pyroscope profiling
|
||||||
if ctx.Bool(pyroscopeFlag.Name) {
|
if ctx.Bool(pyroscopeFlag.Name) {
|
||||||
pyroscopeServer := ctx.String(pyroscopeServerFlag.Name)
|
pyroscopeServer := ctx.String(pyroscopeServerFlag.Name)
|
||||||
|
pyroscopeAuthUsername := ctx.String(pyroscopeAuthUsernameFlag.Name)
|
||||||
|
pyroscopeAuthPassword := ctx.String(pyroscopeAuthPasswordFlag.Name)
|
||||||
|
|
||||||
rawTags := ctx.String(pyroscopeTagsFlag.Name)
|
rawTags := ctx.String(pyroscopeTagsFlag.Name)
|
||||||
tags := make(map[string]string)
|
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 {
|
if len(logFile) > 0 || rotation {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue