Skip to content

Commit e065c15

Browse files
Add command line flag to disable metrics about the exporter it-self (#885)
PR #356 introduced an API option to disable default exporter metrics (process_* and go_*). However there is no command line flag to actually set this option. This change adds the command line flag `--no-collector.exporter-metrics` to disable those metrics. Signed-off-by: Christian Pointner <[email protected]> Co-authored-by: Roman Novikov <[email protected]>
1 parent 7b587d0 commit e065c15

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

main.go

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type GlobalFlags struct {
4949
LogLevel string `name:"log.level" help:"Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]" enum:"debug,info,warn,error,fatal" default:"error"`
5050
ConnectTimeoutMS int `name:"mongodb.connect-timeout-ms" help:"Connection timeout in milliseconds" default:"5000"`
5151

52+
EnableExporterMetrics bool `name:"collector.exporter-metrics" help:"Enable collecting metrics about the exporter itself (process_*, go_*)" negatable:"" default:"True"`
5253
EnableDiagnosticData bool `name:"collector.diagnosticdata" help:"Enable collecting metrics from getDiagnosticData"`
5354
EnableReplicasetStatus bool `name:"collector.replicasetstatus" help:"Enable collecting metrics from replSetGetStatus"`
5455
EnableDBStats bool `name:"collector.dbstats" help:"Enable collecting metrics from dbStats"`
@@ -147,6 +148,7 @@ func buildExporter(opts GlobalFlags, uri string, log *logrus.Logger) *exporter.E
147148
ConnectTimeoutMS: opts.ConnectTimeoutMS,
148149
TimeoutOffset: opts.TimeoutOffset,
149150

151+
DisableDefaultRegistry: !opts.EnableExporterMetrics,
150152
EnableDiagnosticData: opts.EnableDiagnosticData,
151153
EnableReplicasetStatus: opts.EnableReplicasetStatus,
152154
EnableCurrentopMetrics: opts.EnableCurrentopMetrics,

0 commit comments

Comments
 (0)