Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(observability): add start parameter to provide basic auth to pyr… #3996

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions cmd/flags_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@
)

var (
LogLevelFlag = "log.level"
LogLevelModuleFlag = "log.level.module"
pprofFlag = "pprof"
tracingFlag = "tracing"
tracingEndpointFlag = "tracing.endpoint"
tracingTlS = "tracing.tls"
metricsFlag = "metrics"
metricsEndpointFlag = "metrics.endpoint"
metricsTlS = "metrics.tls"
p2pMetrics = "p2p.metrics"
pyroscopeFlag = "pyroscope"
pyroscopeTracing = "pyroscope.tracing"
pyroscopeEndpoint = "pyroscope.endpoint"
LogLevelFlag = "log.level"
LogLevelModuleFlag = "log.level.module"
pprofFlag = "pprof"
tracingFlag = "tracing"
tracingEndpointFlag = "tracing.endpoint"
tracingTlS = "tracing.tls"
metricsFlag = "metrics"
metricsEndpointFlag = "metrics.endpoint"
metricsTlS = "metrics.tls"
p2pMetrics = "p2p.metrics"
pyroscopeFlag = "pyroscope"
pyroscopeTracing = "pyroscope.tracing"
pyroscopeEndpoint = "pyroscope.endpoint"
pyroscopeBasicAuthUser = "pyroscope.basic-auth.user"
pyroscopeBasicAuthPassword = "pyroscope.basic-auth.password"

Check failure on line 37 in cmd/flags_misc.go

View workflow job for this annotation

GitHub Actions / go-ci / Lint

G101: Potential hardcoded credentials (gosec)
)

// MiscFlags gives a set of hardcoded miscellaneous flags.
Expand Down Expand Up @@ -118,6 +120,18 @@
"Sets HTTP endpoint for Pyroscope profiles to be exported to. Depends on '--pyroscope'",
)

flags.String(
pyroscopeBasicAuthUser,
"",
"Sets basic auth user for Pyroscope. Depends on '--pyroscope'",
)

flags.String(
pyroscopeBasicAuthPassword,
"",
"Sets basic auth password for Pyroscope. Depends on '--pyroscope'",
)

return flags
}

Expand Down Expand Up @@ -183,6 +197,8 @@
ctx = WithNodeOptions(ctx,
nodebuilder.WithPyroscope(
cmd.Flag(pyroscopeEndpoint).Value.String(),
cmd.Flag(pyroscopeBasicAuthUser).Value.String(),
cmd.Flag(pyroscopeBasicAuthPassword).Value.String(),
NodeType(ctx),
),
)
Expand Down
13 changes: 10 additions & 3 deletions nodebuilder/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func WithBootstrappers(peers p2p.Bootstrappers) fx.Option {
}

// WithPyroscope enables pyroscope profiling for the node.
func WithPyroscope(endpoint string, nodeType node.Type) fx.Option {
func WithPyroscope(endpoint string, basicAuthUser string, basicAuthPassword string, nodeType node.Type) fx.Option {
return fx.Options(
fx.Invoke(func(peerID peer.ID) error {
_, err := pyroscope.Start(pyroscope.Config{
config := pyroscope.Config{
UploadRate: 15 * time.Second,
ApplicationName: "celestia.da-node",
ServerAddress: endpoint,
Expand All @@ -69,7 +69,14 @@ func WithPyroscope(endpoint string, nodeType node.Type) fx.Option {
pyroscope.ProfileInuseSpace,
pyroscope.ProfileGoroutines,
},
})
}

if basicAuthUser != "" && basicAuthPassword != "" {
config.BasicAuthUser = basicAuthUser
config.BasicAuthPassword = basicAuthPassword
}

_, err := pyroscope.Start(config)
return err
}),
)
Expand Down
Loading