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

[Merged by Bors] - config: add public metrics group #4737

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ func EnsureCLIFlags(cmd *cobra.Command, appCFG *config.Config) error {
ff = reflect.TypeOf(appCFG.TestConfig)
elem = reflect.ValueOf(&appCFG.TestConfig).Elem()
assignFields(ff, elem, name)

ff = reflect.TypeOf(appCFG.PublicMetrics)
elem = reflect.ValueOf(&appCFG.PublicMetrics).Elem()
assignFields(ff, elem, name)
}
})
return nil
Expand Down
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func AddCommands(cmd *cobra.Command) {
cfg.CollectMetrics, "collect node metrics")
cmd.PersistentFlags().IntVar(&cfg.MetricsPort, "metrics-port",
cfg.MetricsPort, "metric server port")
cmd.PersistentFlags().StringVar(&cfg.MetricsPush, "metrics-push",
cfg.MetricsPush, "Push metrics to url")
cmd.PersistentFlags().DurationVar(&cfg.MetricsPushPeriod, "metrics-push-period",
cfg.MetricsPushPeriod, "Push period")
cmd.PersistentFlags().StringVar(&cfg.PublicMetrics.MetricsURL, "metrics-push",
cfg.PublicMetrics.MetricsURL, "Push metrics to url")
cmd.PersistentFlags().DurationVar(&cfg.PublicMetrics.MetricsPushPeriod, "metrics-push-period",
cfg.PublicMetrics.MetricsPushPeriod, "Push period")
cmd.PersistentFlags().StringArrayVar(&cfg.PoETServers, "poet-server",
cfg.PoETServers, "The poet server url. (temporary) Can be passed multiple times")
cmd.PersistentFlags().StringVar(&cfg.Genesis.GenesisTime, "genesis-time",
Expand Down
16 changes: 9 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ type BaseConfig struct {
CollectMetrics bool `mapstructure:"metrics"`
MetricsPort int `mapstructure:"metrics-port"`

MetricsPush string `mapstructure:"metrics-push"`
MetricsPushPeriod time.Duration `mapstructure:"metrics-push-period"`
MetricsPushUser string `mapstructure:"metrics-push-user"`
MetricsPushPass string `mapstructure:"metrics-push-pass"`
MetricsPushHeader map[string]string `mapstructure:"metrics-push-header"`
PublicMetrics PublicMetrics `mapstructure:"public-metrics"`

ProfilerName string `mapstructure:"profiler-name"`
ProfilerURL string `mapstructure:"profiler-url"`
Expand All @@ -115,6 +111,14 @@ type BaseConfig struct {
NetworkHRP string `mapstructure:"network-hrp"`
}

type PublicMetrics struct {
MetricsURL string `mapstructure:"metrics-url"`
MetricsPushPeriod time.Duration `mapstructure:"metrics-push-period"`
MetricsPushUser string `mapstructure:"metrics-push-user"`
MetricsPushPass string `mapstructure:"metrics-push-pass"`
MetricsPushHeader map[string]string `mapstructure:"metrics-push-header"`
}

// SmeshingConfig defines configuration for the node's smeshing (mining).
type SmeshingConfig struct {
Start bool `mapstructure:"smeshing-start"`
Expand Down Expand Up @@ -164,8 +168,6 @@ func defaultBaseConfig() BaseConfig {
FileLock: filepath.Join(os.TempDir(), "spacemesh.lock"),
CollectMetrics: false,
MetricsPort: 1010,
MetricsPush: "", // "" = doesn't push
MetricsPushPeriod: 60,
ProfilerName: "gp-spacemesh",
LayerDuration: 30 * time.Second,
LayersPerEpoch: 3,
Expand Down
1 change: 0 additions & 1 deletion config/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func MainnetConfig() Config {
DataDirParent: defaultDataDir,
FileLock: filepath.Join(os.TempDir(), "spacemesh.lock"),
MetricsPort: 1010,
MetricsPushPeriod: 60,
DatabaseConnections: 16,
NetworkHRP: "sm",

Expand Down
12 changes: 6 additions & 6 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1380,13 +1380,13 @@
metrics.StartMetricsServer(app.Config.MetricsPort)
}

if app.Config.MetricsPush != "" {
if app.Config.PublicMetrics.MetricsURL != "" {
metrics.StartPushingMetrics(
app.Config.MetricsPush,
app.Config.MetricsPushUser,
app.Config.MetricsPushPass,
app.Config.MetricsPushHeader,
app.Config.MetricsPushPeriod,
app.Config.PublicMetrics.MetricsURL,
app.Config.PublicMetrics.MetricsPushUser,
app.Config.PublicMetrics.MetricsPushPass,
app.Config.PublicMetrics.MetricsPushHeader,
app.Config.PublicMetrics.MetricsPushPeriod,

Check warning on line 1389 in node/node.go

View check run for this annotation

Codecov / codecov/patch

node/node.go#L1385-L1389

Added lines #L1385 - L1389 were not covered by tests
app.host.ID().String()[:5], app.Config.Genesis.GenesisID().ShortString())
}

Expand Down