Skip to content

Commit 51e0a40

Browse files
committed
chore: fix a typo and use slices.Contains
Minor fixes as I was skimming through: - fix typo in `stat_statements` - drop custom `sliceContains` in `database`
1 parent f50aac6 commit 51e0a40

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

collector/pg_database.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"context"
1818
"database/sql"
1919
"log/slog"
20+
"slices"
2021

2122
"github.com/prometheus/client_golang/prometheus"
2223
)
@@ -102,7 +103,7 @@ func (c PGDatabaseCollector) Update(ctx context.Context, instance *instance, ch
102103
// Ignore excluded databases
103104
// Filtering is done here instead of in the query to avoid
104105
// a complicated NOT IN query with a variable number of parameters
105-
if sliceContains(c.excludedDatabases, database) {
106+
if slices.Contains(c.excludedDatabases, database) {
106107
continue
107108
}
108109

@@ -138,12 +139,3 @@ func (c PGDatabaseCollector) Update(ctx context.Context, instance *instance, ch
138139
}
139140
return rows.Err()
140141
}
141-
142-
func sliceContains(slice []string, s string) bool {
143-
for _, item := range slice {
144-
if item == s {
145-
return true
146-
}
147-
}
148-
return false
149-
}

collector/pg_stat_statements.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func NewPGStatStatementsCollector(config collectorConfig) (Collector, error) {
6464
}
6565

6666
var (
67-
statSTatementsCallsTotal = prometheus.NewDesc(
67+
statStatementsCallsTotal = prometheus.NewDesc(
6868
prometheus.BuildFQName(namespace, statStatementsSubsystem, "calls_total"),
6969
"Number of times executed",
7070
[]string{"user", "datname", "queryid"},
@@ -230,7 +230,7 @@ func (c PGStatStatementsCollector) Update(ctx context.Context, instance *instanc
230230
callsTotalMetric = float64(callsTotal.Int64)
231231
}
232232
ch <- prometheus.MustNewConstMetric(
233-
statSTatementsCallsTotal,
233+
statStatementsCallsTotal,
234234
prometheus.CounterValue,
235235
callsTotalMetric,
236236
userLabel, datnameLabel, queryidLabel,

0 commit comments

Comments
 (0)