From 55e7f169e03a8f0dd4c02311200199e68e3fc4fb Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 14 May 2019 15:20:21 -0500 Subject: [PATCH 1/2] config reporters --- prometheus/config.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/prometheus/config.go b/prometheus/config.go index 96e7818f..28bda24b 100644 --- a/prometheus/config.go +++ b/prometheus/config.go @@ -26,6 +26,8 @@ import ( "net/http" "os" "strings" + + prom "github.com/m3db/prometheus_client_golang/prometheus" ) // Configuration is a configuration for a Prometheus reporter. @@ -49,6 +51,12 @@ type Configuration struct { // objectives to be used by the reporter. DefaultSummaryObjectives []SummaryObjective `yaml:"defaultSummaryObjectives"` + // DisableProcessReporter disables the process reporter. + DisableProcessReporter bool `yaml:"disableProcessReporter"` + + // DisableGoReporter disables the go reporter. + DisableGoReporter bool `yaml:"disableGoReporter"` + // OnError specifies what to do when an error either with listening // on the specified listen address or registering a metric with the // Prometheus. By default the registerer will panic. @@ -122,6 +130,19 @@ func (c Configuration) NewReporter( opts.DefaultSummaryObjectives = values } + registerer := prom.NewRegistry() + if !c.DisableGoReporter { + if err := registerer.Register(prom.NewGoCollector()); err != nil { + return nil, err + } + } + if !c.DisableProcessReporter { + if err := registerer.Register(prom.NewProcessCollector(os.Getpid(), "")); err != nil { + return nil, err + } + } + opts.Registerer = registerer + reporter := NewReporter(opts) path := "/metrics" From c97f422de549d51f6ef4cacdab13ab09525ec151 Mon Sep 17 00:00:00 2001 From: Richard Artoul Date: Tue, 14 May 2019 15:22:41 -0500 Subject: [PATCH 2/2] rename vars --- prometheus/config.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/prometheus/config.go b/prometheus/config.go index 28bda24b..ee872efe 100644 --- a/prometheus/config.go +++ b/prometheus/config.go @@ -51,11 +51,11 @@ type Configuration struct { // objectives to be used by the reporter. DefaultSummaryObjectives []SummaryObjective `yaml:"defaultSummaryObjectives"` - // DisableProcessReporter disables the process reporter. - DisableProcessReporter bool `yaml:"disableProcessReporter"` + // DisableProcessCollector disables the process reporter. + DisableProcessCollector bool `yaml:"disableProcessCollector"` - // DisableGoReporter disables the go reporter. - DisableGoReporter bool `yaml:"disableGoReporter"` + // DisableGoCollector disables the go reporter. + DisableGoCollector bool `yaml:"disableGoCollector"` // OnError specifies what to do when an error either with listening // on the specified listen address or registering a metric with the @@ -131,12 +131,12 @@ func (c Configuration) NewReporter( } registerer := prom.NewRegistry() - if !c.DisableGoReporter { + if !c.DisableGoCollector { if err := registerer.Register(prom.NewGoCollector()); err != nil { return nil, err } } - if !c.DisableProcessReporter { + if !c.DisableProcessCollector { if err := registerer.Register(prom.NewProcessCollector(os.Getpid(), "")); err != nil { return nil, err }