Skip to content

Commit 075ac6e

Browse files
committed
PMM-14431 Lint (unused error).
1 parent 6f6c101 commit 075ac6e

File tree

5 files changed

+6
-26
lines changed

5 files changed

+6
-26
lines changed

exporter/collstats_collector.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ func (d *collstatsCollector) collect(ch chan<- prometheus.Metric) {
8585
}
8686
}
8787

88-
reservedNames, err := GetAllIndexesForCollections(d.ctx, client, collections)
89-
if err != nil {
90-
logger.Error("cannot get all indexes for collections", "error", err.Error())
91-
return
92-
}
93-
88+
reservedNames := GetAllIndexesForCollections(d.ctx, client, collections)
9489
for _, dbCollection := range collections {
9590
parts := strings.Split(dbCollection, ".")
9691
if len(parts) < 2 { //nolint:gomnd

exporter/indexstats_collector.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ func (d *indexstatsCollector) collect(ch chan<- prometheus.Metric) {
8585
}
8686
}
8787

88-
reservedNames, err := GetAllIndexesForCollections(d.ctx, client, collections)
89-
if err != nil {
90-
logger.Error("cannot get all indexes for collections", "error", err.Error())
91-
return
92-
}
93-
88+
reservedNames := GetAllIndexesForCollections(d.ctx, client, collections)
9489
for _, dbCollection := range collections {
9590
parts := strings.Split(dbCollection, ".")
9691
if len(parts) < 2 { //nolint:gomnd

exporter/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func metricHelp(prefix, name string) string {
307307
}
308308

309309
// GetAllIndexesForCollections returns all index names for the given list of "db.collection" strings.
310-
func GetAllIndexesForCollections(ctx context.Context, client *mongo.Client, collections []string) ([]string, error) {
310+
func GetAllIndexesForCollections(ctx context.Context, client *mongo.Client, collections []string) []string {
311311
var indexNames []string
312312
for _, dbCollection := range collections {
313313
parts := strings.SplitN(dbCollection, ".", 2) //nolint:mnd
@@ -335,7 +335,7 @@ func GetAllIndexesForCollections(ctx context.Context, client *mongo.Client, coll
335335
cursor.Close(ctx) //nolint:errcheck
336336
}
337337

338-
return indexNames, nil
338+
return indexNames
339339
}
340340

341341
func makeMetrics(reservedNames []string, prefix string, m bson.M, labels map[string]string, compatibleMode bool) []prometheus.Metric {

exporter/shards_collector.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,7 @@ func (d *shardsCollector) collect(ch chan<- prometheus.Metric) {
9393
}
9494
}
9595
}
96-
reservedNames, err := GetAllIndexesForCollections(d.ctx, client, collections)
97-
if err != nil {
98-
logger.Error("cannot get all indexes for collections", "error", err.Error())
99-
return
100-
}
101-
96+
reservedNames := GetAllIndexesForCollections(d.ctx, client, collections)
10297
for _, database := range databaseNames {
10398
collections := d.getCollectionsForDBName(database)
10499
for _, row := range collections {

exporter/top_collector.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,7 @@ func (d *topCollector) collect(ch chan<- prometheus.Metric) {
144144
_, coll := splitNamespace(namespace)
145145
collections = append(collections, coll)
146146
}
147-
reservedNames, err := GetAllIndexesForCollections(d.ctx, client, collections)
148-
if err != nil {
149-
logger.Error("cannot get all indexes for collections", "error", err.Error())
150-
return
151-
}
152-
147+
reservedNames := GetAllIndexesForCollections(d.ctx, client, collections)
153148
for namespace, metrics := range totals {
154149
labels := d.topologyInfo.baseLabels()
155150
db, coll := splitNamespace(namespace)

0 commit comments

Comments
 (0)