Skip to content

Commit

Permalink
Clean up autoDiscoverDatabases in the new collector
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Adams <github@joeadams.io>
Signed-off-by: Angus Dippenaar <angusdippenaar@gmail.com>
  • Loading branch information
sysadmind authored and angaz committed Mar 3, 2022
1 parent cf3feda commit c803dcc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
1 change: 0 additions & 1 deletion cmd/postgres_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func main() {
logger,
dsn,
[]string{},
collector.WithAutoDiscoverDatabases(*autoDiscoverDatabases),
)
if err != nil {
level.Error(logger).Log("msg", "Failed to create PostgresCollector", "err", err.Error())
Expand Down
17 changes: 0 additions & 17 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ type PostgresCollector struct {
logger log.Logger

servers map[string]*server

// autoDiscoverDatabases will cause the collector to query the database
// to find other servers and also scrape them.
autoDiscoverDatabases bool
}

type Option func(*PostgresCollector) error
Expand Down Expand Up @@ -146,12 +142,6 @@ func NewPostgresCollector(logger log.Logger, dsns []string, filters []string, op
if err != nil {
return nil, err
}
// Manually provided servers are always classified as "primary"
s.isPrimary = true

// TODO(@sysadmind): We need to discover the downstream servers and add them here.
// if p.autoDiscoverDatabases {
// }

servers[dsn] = s
}
Expand All @@ -161,13 +151,6 @@ func NewPostgresCollector(logger log.Logger, dsns []string, filters []string, op
return p, nil
}

func WithAutoDiscoverDatabases(discover bool) Option {
return func(p *PostgresCollector) error {
p.autoDiscoverDatabases = discover
return nil
}
}

// Describe implements the prometheus.Collector interface.
func (p PostgresCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- scrapeDurationDesc
Expand Down
7 changes: 3 additions & 4 deletions collector/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ import (
)

type server struct {
dsn string
name string
db *sql.DB
isPrimary bool // Certain queries are only run on the primary server
dsn string
name string
db *sql.DB
}

func makeServer(dsn string) (*server, error) {
Expand Down

0 comments on commit c803dcc

Please sign in to comment.