diff --git a/cmd/flags_misc.go b/cmd/flags_misc.go index 93c56ce8ca..83002287f5 100644 --- a/cmd/flags_misc.go +++ b/cmd/flags_misc.go @@ -20,19 +20,21 @@ import ( ) 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" //nolint:gosec ) // MiscFlags gives a set of hardcoded miscellaneous flags. @@ -118,6 +120,18 @@ and their lower-case forms`, "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 } @@ -183,6 +197,8 @@ func ParseMiscFlags(ctx context.Context, cmd *cobra.Command) (context.Context, e ctx = WithNodeOptions(ctx, nodebuilder.WithPyroscope( cmd.Flag(pyroscopeEndpoint).Value.String(), + cmd.Flag(pyroscopeBasicAuthUser).Value.String(), + cmd.Flag(pyroscopeBasicAuthPassword).Value.String(), NodeType(ctx), ), ) diff --git a/nodebuilder/settings.go b/nodebuilder/settings.go index ea1aac2d37..328c5ea682 100644 --- a/nodebuilder/settings.go +++ b/nodebuilder/settings.go @@ -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, basicAuthUser, 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, @@ -69,7 +69,11 @@ func WithPyroscope(endpoint string, nodeType node.Type) fx.Option { pyroscope.ProfileInuseSpace, pyroscope.ProfileGoroutines, }, - }) + BasicAuthUser: basicAuthUser, + BasicAuthPassword: basicAuthPassword, + } + + _, err := pyroscope.Start(config) return err }), )