diff --git a/internal/collector/collector_common.go b/internal/collector/collector_common.go index 1cb78db..3171ff9 100644 --- a/internal/collector/collector_common.go +++ b/internal/collector/collector_common.go @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/internal/collector/collector_common_test.go b/internal/collector/collector_common_test.go index 5777fc3..f94e1c1 100644 --- a/internal/collector/collector_common_test.go +++ b/internal/collector/collector_common_test.go @@ -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{ @@ -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() }() @@ -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() @@ -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() }() diff --git a/internal/collector/postgres_archiver.go b/internal/collector/postgres_archiver.go index 82a579c..96e28e1 100644 --- a/internal/collector/postgres_archiver.go +++ b/internal/collector/postgres_archiver.go @@ -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 } diff --git a/internal/collector/postgres_custom.go b/internal/collector/postgres_custom.go index 8487b80..8790f64 100644 --- a/internal/collector/postgres_custom.go +++ b/internal/collector/postgres_custom.go @@ -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) }