Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit b0b911e

Browse files
committed
Make command-line arguments namespaced and consistent
This changes the command-line args to use a dot-separated namespace prefix to be consistent with common practices in other projects and dependencies.
1 parent 511e8d5 commit b0b911e

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func parseFlags() *config {
103103

104104
pgprometheus.ParseFlags(&cfg.pgPrometheusConfig)
105105

106-
flag.DurationVar(&cfg.remoteTimeout, "send-timeout", 30*time.Second, "The timeout to use when sending samples to the remote storage.")
106+
flag.DurationVar(&cfg.remoteTimeout, "adapter.send-timeout", 30*time.Second, "The timeout to use when sending samples to the remote storage.")
107107
flag.StringVar(&cfg.listenAddr, "web.listen-address", ":9201", "Address to listen on for web endpoints.")
108108
flag.StringVar(&cfg.telemetryPath, "web.telemetry-path", "/metrics", "Address to listen on for web endpoints.")
109109
flag.StringVar(&cfg.logLevel, "log.level", "debug", "The log level to use [ \"error\", \"warn\", \"info\", \"debug\" ].")

postgresql/client.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,21 @@ type Config struct {
4141

4242
// ParseFlags parses the configuration flags specific to PostgreSQL and TimescaleDB
4343
func ParseFlags(cfg *Config) *Config {
44-
flag.StringVar(&cfg.host, "pg-host", "localhost", "The PostgreSQL host")
45-
flag.IntVar(&cfg.port, "pg-port", 5432, "The PostgreSQL port")
46-
flag.StringVar(&cfg.user, "pg-user", "postgres", "The PostgreSQL user")
47-
flag.StringVar(&cfg.password, "pg-password", "", "The PostgreSQL password")
48-
flag.StringVar(&cfg.database, "pg-database", "postgres", "The PostgreSQL database")
49-
flag.StringVar(&cfg.schema, "pg-schema", "", "The PostgreSQL schema")
50-
flag.StringVar(&cfg.sslMode, "pg-ssl-mode", "disable", "The PostgreSQL connection ssl mode")
51-
flag.StringVar(&cfg.table, "pg-table", "metrics", "The PostgreSQL table")
52-
flag.StringVar(&cfg.copyTable, "pg-copy-table", "metrics_copy", "The PostgreSQL table")
53-
flag.IntVar(&cfg.maxOpenConns, "pg-max-open-conns", 50, "The max number of open connections to the database")
54-
flag.IntVar(&cfg.maxIdleConns, "pg-max-idle-conns", 10, "The max number of idle connections to the database")
55-
flag.BoolVar(&cfg.pgPrometheusNormalize, "pg-prometheus-normalized-schema", true, "Insert metric samples into normalized schema")
56-
flag.BoolVar(&cfg.pgPrometheusLogSamples, "pg-prometheus-log-samples", false, "Log raw samples to stdout")
57-
flag.DurationVar(&cfg.pgPrometheusChunkInterval, "pg-prometheus-chunk-interval", time.Hour*12, "The size of a time-partition chunk in TimescaleDB")
58-
flag.BoolVar(&cfg.useTimescaleDb, "pg-use-timescaledb", true, "Use timescaleDB")
44+
flag.StringVar(&cfg.host, "pg.host", "localhost", "The PostgreSQL host")
45+
flag.IntVar(&cfg.port, "pg.port", 5432, "The PostgreSQL port")
46+
flag.StringVar(&cfg.user, "pg.user", "postgres", "The PostgreSQL user")
47+
flag.StringVar(&cfg.password, "pg.password", "", "The PostgreSQL password")
48+
flag.StringVar(&cfg.database, "pg.database", "postgres", "The PostgreSQL database")
49+
flag.StringVar(&cfg.schema, "pg.schema", "", "The PostgreSQL schema")
50+
flag.StringVar(&cfg.sslMode, "pg.ssl-mode", "disable", "The PostgreSQL connection ssl mode")
51+
flag.StringVar(&cfg.table, "pg.table", "metrics", "The PostgreSQL table")
52+
flag.StringVar(&cfg.copyTable, "pg.copy-table", "metrics_copy", "The PostgreSQL table")
53+
flag.IntVar(&cfg.maxOpenConns, "pg.max-open-conns", 50, "The max number of open connections to the database")
54+
flag.IntVar(&cfg.maxIdleConns, "pg.max-idle-conns", 10, "The max number of idle connections to the database")
55+
flag.BoolVar(&cfg.pgPrometheusNormalize, "pg.prometheus-normalized-schema", true, "Insert metric samples into normalized schema")
56+
flag.BoolVar(&cfg.pgPrometheusLogSamples, "pg.prometheus-log-samples", false, "Log raw samples to stdout")
57+
flag.DurationVar(&cfg.pgPrometheusChunkInterval, "pg.prometheus-chunk-interval", time.Hour*12, "The size of a time-partition chunk in TimescaleDB")
58+
flag.BoolVar(&cfg.useTimescaleDb, "pg.use-timescaledb", true, "Use timescaleDB")
5959
return cfg
6060
}
6161

0 commit comments

Comments
 (0)