Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Rename UpdateDescSet and updateDescSet.
Browse files Browse the repository at this point in the history
  • Loading branch information
lesovsky committed May 10, 2021
1 parent bcd0091 commit ed1a28d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions internal/collector/collector_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ func newDeskSetsFromSubsystems(namespace string, subsystems model.Subsystems, co
return sets
}

// UpdateDescSet collect metrics for specified desc set.
func UpdateDescSet(config Config, descSets []typedDescSet, ch chan<- prometheus.Metric) error {
// updateAllDescSets collect metrics for specified desc set.
func updateAllDescSets(config Config, descSets []typedDescSet, ch chan<- prometheus.Metric) error {

// Get de-duplicated list of databases should be visited.
databases := listDeskSetDatabases(descSets)
Expand Down Expand Up @@ -145,7 +145,7 @@ func updateFromSingleDatabase(config Config, descSets []typedDescSet, ch chan<-
continue
}

err = updateDescSet(conn, s, ch)
err = updateSingleDescSet(conn, s, ch)
if err != nil {
log.Errorf("collect failed: %s; skip", err)
continue
Expand Down Expand Up @@ -199,7 +199,7 @@ func updateFromMultipleDatabases(config Config, descSets []typedDescSet, userDat
s.variableLabels = append([]string{"database"}, s.variableLabels...)
}

err = updateDescSet(conn, s, ch)
err = updateSingleDescSet(conn, s, ch)
if err != nil {
log.Errorf("collect failed: %s; skip", err)
continue
Expand All @@ -213,8 +213,8 @@ func updateFromMultipleDatabases(config Config, descSets []typedDescSet, userDat
return nil
}

// updateDescSet using passed connection collects metrics for specified descSet and receives it to metric channel.
func updateDescSet(conn *store.DB, set typedDescSet, ch chan<- prometheus.Metric) error {
// updateSingleDescSet using passed connection collects metrics for specified descSet and receives it to metric channel.
func updateSingleDescSet(conn *store.DB, set typedDescSet, ch chan<- prometheus.Metric) error {
res, err := conn.Query(set.query)
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions internal/collector/collector_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func Test_newDeskSetsFromSubsystems(t *testing.T) {
}
}

func Test_UpdateDescSet(t *testing.T) {
func Test_updateAllDescSets(t *testing.T) {
config := Config{ConnString: store.TestPostgresConnStr}

subsystems := map[string]model.MetricsSubsystem{
Expand Down Expand Up @@ -141,7 +141,7 @@ func Test_UpdateDescSet(t *testing.T) {
var wg sync.WaitGroup
wg.Add(1)
go func() {
assert.NoError(t, UpdateDescSet(config, desksets, ch))
assert.NoError(t, updateAllDescSets(config, desksets, ch))
close(ch)
wg.Done()
}()
Expand Down Expand Up @@ -261,7 +261,7 @@ func Test_updateFromMultipleDatabases(t *testing.T) {
wg.Wait()
}

func Test_updateDescSet(t *testing.T) {
func Test_updateSingleDescSet(t *testing.T) {
conn := store.NewTest(t)
defer conn.Close()

Expand Down Expand Up @@ -309,7 +309,7 @@ func Test_updateDescSet(t *testing.T) {
var wg sync.WaitGroup
wg.Add(1)
go func() {
assert.NoError(t, updateDescSet(conn, tc.set, ch))
assert.NoError(t, updateSingleDescSet(conn, tc.set, ch))
close(ch)
wg.Done()
}()
Expand Down
4 changes: 2 additions & 2 deletions internal/collector/postgres_archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ func (c *postgresWalArchivingCollector) Update(config Config, ch chan<- promethe
}

// Update builtin metrics.
err := UpdateDescSet(config, c.builtin, ch)
err := updateAllDescSets(config, c.builtin, ch)
if err != nil {
return err
}

// Update user-defined metrics.
err = UpdateDescSet(config, c.custom, ch)
err = updateAllDescSets(config, c.custom, ch)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/collector/postgres_custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ func NewPostgresCustomCollector(constLabels prometheus.Labels, settings model.Co

// Update method collects statistics, parse it and produces metrics that are sent to Prometheus.
func (c *postgresCustomCollector) Update(config Config, ch chan<- prometheus.Metric) error {
return UpdateDescSet(config, c.descSets, ch)
return updateAllDescSets(config, c.descSets, ch)
}

0 comments on commit ed1a28d

Please sign in to comment.