You've already forked postgres_exporter
mirror of
https://github.com/prometheus-community/postgres_exporter.git
synced 2025-08-09 15:42:47 +03:00
chore: fix a typo and use slices.Contains
(#1176)
Minor fixes as I was skimming through: - fix typo in `stat_statements` - drop custom `sliceContains` in `database` Signed-off-by: Cristian Greco <cristian@regolo.cc>
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
@@ -102,7 +103,7 @@ func (c PGDatabaseCollector) Update(ctx context.Context, instance *instance, ch
|
|||||||
// Ignore excluded databases
|
// Ignore excluded databases
|
||||||
// Filtering is done here instead of in the query to avoid
|
// Filtering is done here instead of in the query to avoid
|
||||||
// a complicated NOT IN query with a variable number of parameters
|
// a complicated NOT IN query with a variable number of parameters
|
||||||
if sliceContains(c.excludedDatabases, database) {
|
if slices.Contains(c.excludedDatabases, database) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,12 +139,3 @@ func (c PGDatabaseCollector) Update(ctx context.Context, instance *instance, ch
|
|||||||
}
|
}
|
||||||
return rows.Err()
|
return rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func sliceContains(slice []string, s string) bool {
|
|
||||||
for _, item := range slice {
|
|
||||||
if item == s {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
@@ -64,7 +64,7 @@ func NewPGStatStatementsCollector(config collectorConfig) (Collector, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
statSTatementsCallsTotal = prometheus.NewDesc(
|
statStatementsCallsTotal = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(namespace, statStatementsSubsystem, "calls_total"),
|
prometheus.BuildFQName(namespace, statStatementsSubsystem, "calls_total"),
|
||||||
"Number of times executed",
|
"Number of times executed",
|
||||||
[]string{"user", "datname", "queryid"},
|
[]string{"user", "datname", "queryid"},
|
||||||
@@ -230,7 +230,7 @@ func (c PGStatStatementsCollector) Update(ctx context.Context, instance *instanc
|
|||||||
callsTotalMetric = float64(callsTotal.Int64)
|
callsTotalMetric = float64(callsTotal.Int64)
|
||||||
}
|
}
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
statSTatementsCallsTotal,
|
statStatementsCallsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
callsTotalMetric,
|
callsTotalMetric,
|
||||||
userLabel, datnameLabel, queryidLabel,
|
userLabel, datnameLabel, queryidLabel,
|
||||||
|
Reference in New Issue
Block a user