mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-01-21 05:40:43 +00:00
Merge pull request #807 from prometheus-community/superq/linting
Update linting
This commit is contained in:
commit
5d5fae151b
@ -1,4 +1,8 @@
|
||||
---
|
||||
linters:
|
||||
enable:
|
||||
- revive
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: _test.go
|
||||
@ -7,4 +11,6 @@ issues:
|
||||
|
||||
linters-settings:
|
||||
errcheck:
|
||||
exclude: scripts/errcheck_excludes.txt
|
||||
exclude-functions:
|
||||
# Never check for logger errors.
|
||||
- (github.com/go-kit/log.Logger).Log
|
||||
|
@ -34,7 +34,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
c = config.ConfigHandler{
|
||||
c = config.Handler{
|
||||
Config: &config.Config{},
|
||||
}
|
||||
|
||||
|
@ -66,27 +66,27 @@ func (PGReplicationSlotCollector) Update(ctx context.Context, db *sql.DB, ch cha
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var slot_name string
|
||||
var wal_lsn int64
|
||||
var flush_lsn int64
|
||||
var is_active bool
|
||||
if err := rows.Scan(&slot_name, &wal_lsn, &flush_lsn, &is_active); err != nil {
|
||||
var slotName string
|
||||
var walLSN int64
|
||||
var flusLSN int64
|
||||
var isActive bool
|
||||
if err := rows.Scan(&slotName, &walLSN, &flusLSN, &isActive); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
pgReplicationSlotCurrentWalDesc,
|
||||
prometheus.GaugeValue, float64(wal_lsn), slot_name,
|
||||
prometheus.GaugeValue, float64(walLSN), slotName,
|
||||
)
|
||||
if is_active {
|
||||
if isActive {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
pgReplicationSlotCurrentFlushDesc,
|
||||
prometheus.GaugeValue, float64(flush_lsn), slot_name,
|
||||
prometheus.GaugeValue, float64(flusLSN), slotName,
|
||||
)
|
||||
}
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
pgReplicationSlotIsActiveDesc,
|
||||
prometheus.GaugeValue, float64(flush_lsn), slot_name,
|
||||
prometheus.GaugeValue, float64(flusLSN), slotName,
|
||||
)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
|
@ -54,18 +54,18 @@ type UserPass struct {
|
||||
Password string `yaml:"password"`
|
||||
}
|
||||
|
||||
type ConfigHandler struct {
|
||||
type Handler struct {
|
||||
sync.RWMutex
|
||||
Config *Config
|
||||
}
|
||||
|
||||
func (ch *ConfigHandler) GetConfig() *Config {
|
||||
func (ch *Handler) GetConfig() *Config {
|
||||
ch.RLock()
|
||||
defer ch.RUnlock()
|
||||
return ch.Config
|
||||
}
|
||||
|
||||
func (ch *ConfigHandler) ReloadConfig(f string, logger log.Logger) error {
|
||||
func (ch *Handler) ReloadConfig(f string, logger log.Logger) error {
|
||||
config := &Config{}
|
||||
var err error
|
||||
defer func() {
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
)
|
||||
|
||||
func TestLoadConfig(t *testing.T) {
|
||||
ch := &ConfigHandler{
|
||||
ch := &Handler{
|
||||
Config: &Config{},
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ func TestLoadConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadBadConfigs(t *testing.T) {
|
||||
ch := &ConfigHandler{
|
||||
ch := &Handler{
|
||||
Config: &Config{},
|
||||
}
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
// Never check for logger errors.
|
||||
(github.com/go-kit/log.Logger).Log
|
Loading…
Reference in New Issue
Block a user