Skip to content

Commit

Permalink
feat: add datacenter to metadata exporter_time metrics
Browse files Browse the repository at this point in the history
Fixes: #1432
  • Loading branch information
cgrinds committed Mar 1, 2023
1 parent 2ea4141 commit 97cc98f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/exporters/influxdb/influxdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func setupInfluxDB(t *testing.T, exporterName string) *InfluxDB {
t.Fatalf(`exporter (%v) not defined in config`, exporterName)
}

influx := &InfluxDB{AbstractExporter: exporter.New("InfluxDB", exporterName, opts, e)}
influx := &InfluxDB{AbstractExporter: exporter.New("InfluxDB", exporterName, opts, e, nil)}
if err := influx.Init(); err != nil {
t.Fatal(err)
}
Expand Down
9 changes: 6 additions & 3 deletions cmd/poller/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type AbstractExporter struct {
// @n - exporter name
// @o - poller options
// @p - exporter parameters
func New(c, n string, o *options.Options, p conf.Exporter) *AbstractExporter {
func New(c, n string, o *options.Options, p conf.Exporter, params *conf.Poller) *AbstractExporter {
abc := AbstractExporter{
Class: c,
Name: n,
Expand All @@ -68,13 +68,16 @@ func New(c, n string, o *options.Options, p conf.Exporter) *AbstractExporter {
Logger: logging.Get().SubLogger("exporter", n),
Mutex: &sync.Mutex{},
countMux: &sync.Mutex{},
Metadata: matrix.New(n, "metadata_exporter", "metadata_exporter"),
}
if params != nil {
abc.Metadata.SetGlobalLabel("datacenter", params.Datacenter)
}
return &abc
}

// InitAbc() initializes AbstractExporter
// InitAbc initializes AbstractExporter
func (me *AbstractExporter) InitAbc() error {
me.Metadata = matrix.New(me.Name, "metadata_exporter", "metadata_exporter")
me.Metadata.SetGlobalLabel("hostname", me.Options.Hostname)
me.Metadata.SetGlobalLabel("version", me.Options.Version)
me.Metadata.SetGlobalLabel("poller", me.Options.Poller)
Expand Down
2 changes: 1 addition & 1 deletion cmd/poller/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ func (p *Poller) loadExporter(name string) exporter.Exporter {
return nil
}

absExp := exporter.New(class, name, p.options, params)
absExp := exporter.New(class, name, p.options, params, p.params)
switch class {
case "Prometheus":
exp = prometheus.New(absExp)
Expand Down

0 comments on commit 97cc98f

Please sign in to comment.