chore_: add telemetry url flag to status cli (#5201)

This commit adds a TelemetryUrl param to request for creating
account and to the WakuV2Config. Adds a flag to the cli for
passing in the telemetry server url.
This commit is contained in:
Arseniy Klempner 2024-05-22 15:01:54 -07:00 committed by GitHub
parent c8dfbe682d
commit ad4fb204ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 27 additions and 8 deletions

View File

@ -283,6 +283,10 @@ func defaultNodeConfig(installationID string, request *requests.CreateAccount, o
nodeConfig.WakuV2Config.Nameserver = *request.WakuV2Nameserver nodeConfig.WakuV2Config.Nameserver = *request.WakuV2Nameserver
} }
if request.TelemetryServerURL != "" {
nodeConfig.WakuV2Config.TelemetryServerURL = request.TelemetryServerURL
}
nodeConfig.ShhextConfig = params.ShhextConfig{ nodeConfig.ShhextConfig = params.ShhextConfig{
BackupDisabledDataDir: request.BackupDisabledDataDir, BackupDisabledDataDir: request.BackupDisabledDataDir,
InstallationID: installationID, InstallationID: installationID,

View File

@ -19,6 +19,7 @@ const NameFlag = "name"
const AddFlag = "add" const AddFlag = "add"
const PortFlag = "port" const PortFlag = "port"
const APIModulesFlag = "api-modules" const APIModulesFlag = "api-modules"
const TelemetryServerURLFlag = "telemetry-server-url"
const RetrieveInterval = 300 * time.Millisecond const RetrieveInterval = 300 * time.Millisecond
const SendInterval = 1 * time.Second const SendInterval = 1 * time.Second
@ -36,6 +37,11 @@ var CommonFlags = []cli.Flag{
Value: "waku,wakuext,wakuv2,permissions,eth", Value: "waku,wakuext,wakuv2,permissions,eth",
Usage: "API modules to enable", Usage: "API modules to enable",
}, },
&cli.StringFlag{
Name: TelemetryServerURLFlag,
Aliases: []string{"t"},
Usage: "Telemetry server URL",
},
} }
var SimulateFlags = append([]cli.Flag{ var SimulateFlags = append([]cli.Flag{

View File

@ -36,8 +36,9 @@ func serve(cCtx *cli.Context) error {
name := cCtx.String(NameFlag) name := cCtx.String(NameFlag)
port := cCtx.Int(PortFlag) port := cCtx.Int(PortFlag)
apiModules := cCtx.String(APIModulesFlag) apiModules := cCtx.String(APIModulesFlag)
telemetryUrl := cCtx.String(TelemetryServerURLFlag)
cli, err := start(cCtx, name, port, apiModules) cli, err := start(cCtx, name, port, apiModules, telemetryUrl)
if err != nil { if err != nil {
return err return err
} }

View File

@ -37,14 +37,15 @@ func simulate(cCtx *cli.Context) error {
// Start messengers // Start messengers
apiModules := cCtx.String(APIModulesFlag) apiModules := cCtx.String(APIModulesFlag)
telemetryUrl := cCtx.String(TelemetryServerURLFlag)
alice, err := start(cCtx, "Alice", 0, apiModules) alice, err := start(cCtx, "Alice", 0, apiModules, telemetryUrl)
if err != nil { if err != nil {
return err return err
} }
defer alice.stop() defer alice.stop()
charlie, err := start(cCtx, "Charlie", 0, apiModules) charlie, err := start(cCtx, "Charlie", 0, apiModules, telemetryUrl)
if err != nil { if err != nil {
return err return err
} }

View File

@ -34,7 +34,7 @@ func setupLogger(file string) *zap.Logger {
return logutils.ZapLogger() return logutils.ZapLogger()
} }
func start(cCtx *cli.Context, name string, port int, apiModules string) (*StatusCLI, error) { func start(cCtx *cli.Context, name string, port int, apiModules string, telemetryUrl string) (*StatusCLI, error) {
namedLogger := logger.Named(name) namedLogger := logger.Named(name)
namedLogger.Info("starting messager") namedLogger.Info("starting messager")
@ -60,6 +60,7 @@ func start(cCtx *cli.Context, name string, port int, apiModules string) (*Status
HTTPHost: "127.0.0.1", HTTPHost: "127.0.0.1",
HTTPPort: port, HTTPPort: port,
}, },
TelemetryServerURL: telemetryUrl,
} }
_, err = backend.CreateAccountAndLogin(createAccountRequest) _, err = backend.CreateAccountAndLogin(createAccountRequest)
if err != nil { if err != nil {

View File

@ -142,9 +142,11 @@ func (b *StatusNode) initServices(config *params.NodeConfig, mediaServer *server
if err != nil { if err != nil {
return err return err
} }
if telemetryServerURL != "" {
config.WakuV2Config.TelemetryServerURL = telemetryServerURL
} }
}
waku2Service, err := b.wakuV2Service(config, telemetryServerURL) waku2Service, err := b.wakuV2Service(config)
if err != nil { if err != nil {
return err return err
} }
@ -312,7 +314,7 @@ func (b *StatusNode) wakuService(wakuCfg *params.WakuConfig, clusterCfg *params.
} }
func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig, telemetryServerURL string) (*wakuv2.Waku, error) { func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig) (*wakuv2.Waku, error) {
if b.wakuV2Srvc == nil { if b.wakuV2Srvc == nil {
cfg := &wakuv2.Config{ cfg := &wakuv2.Config{
MaxMessageSize: wakucommon.DefaultMaxMessageSize, MaxMessageSize: wakucommon.DefaultMaxMessageSize,
@ -332,7 +334,7 @@ func (b *StatusNode) wakuV2Service(nodeConfig *params.NodeConfig, telemetryServe
AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate, AutoUpdate: nodeConfig.WakuV2Config.AutoUpdate,
DefaultShardPubsubTopic: shard.DefaultShardPubsubTopic(), DefaultShardPubsubTopic: shard.DefaultShardPubsubTopic(),
UseShardAsDefaultTopic: nodeConfig.WakuV2Config.UseShardAsDefaultTopic, UseShardAsDefaultTopic: nodeConfig.WakuV2Config.UseShardAsDefaultTopic,
TelemetryServerURL: telemetryServerURL, TelemetryServerURL: nodeConfig.WakuV2Config.TelemetryServerURL,
ClusterID: nodeConfig.ClusterConfig.ClusterID, ClusterID: nodeConfig.ClusterConfig.ClusterID,
} }

View File

@ -214,6 +214,8 @@ type WakuV2Config struct {
// StoreSeconds indicates the maximum number of seconds before a message is removed from the store // StoreSeconds indicates the maximum number of seconds before a message is removed from the store
StoreSeconds int StoreSeconds int
TelemetryServerURL string
// UseShardAsDefaultTopic indicates whether the default shard should be used instead of the default relay topic // UseShardAsDefaultTopic indicates whether the default shard should be used instead of the default relay topic
UseShardAsDefaultTopic bool UseShardAsDefaultTopic bool
} }

View File

@ -66,6 +66,8 @@ type CreateAccount struct {
TorrentConfigEnabled *bool TorrentConfigEnabled *bool
TorrentConfigPort *int TorrentConfigPort *int
TelemetryServerURL string `json:"telemetryServerURL"`
APIConfig *APIConfig `json:"apiConfig"` APIConfig *APIConfig `json:"apiConfig"`
} }