diff --git a/collector/pg_process_idle.go b/collector/pg_process_idle.go index e61792200..df8704017 100644 --- a/collector/pg_process_idle.go +++ b/collector/pg_process_idle.go @@ -105,11 +105,11 @@ func (PGProcessIdleCollector) Update(ctx context.Context, inst *instance, ch cha applicationNameLabel = applicationName.String } - var secondsCountMetric uint64 + var secondsCountMetric uint64 = 0 if secondsCount.Valid { secondsCountMetric = uint64(secondsCount.Int64) } - var secondsSumMetric float64 + secondsSumMetric := 0.0 if secondsSum.Valid { secondsSumMetric = float64(secondsSum.Int64) } diff --git a/collector/pg_replication_slot.go b/collector/pg_replication_slot.go index 54ac08129..43eb8a9db 100644 --- a/collector/pg_replication_slot.go +++ b/collector/pg_replication_slot.go @@ -91,9 +91,9 @@ func (PGReplicationSlotCollector) Update(ctx context.Context, instance *instance return err } - isActiveValue := 0 + isActiveValue := 0.0 if isActive.Valid && isActive.Bool { - isActiveValue = 1 + isActiveValue = 1.0 } slotNameLabel := "unknown" if slotName.Valid { @@ -120,7 +120,7 @@ func (PGReplicationSlotCollector) Update(ctx context.Context, instance *instance } ch <- prometheus.MustNewConstMetric( pgReplicationSlotIsActiveDesc, - prometheus.GaugeValue, float64(isActiveValue), slotNameLabel, + prometheus.GaugeValue, isActiveValue, slotNameLabel, ) } if err := rows.Err(); err != nil { diff --git a/collector/pg_stat_bgwriter.go b/collector/pg_stat_bgwriter.go index 7129bc29f..ec446d58c 100644 --- a/collector/pg_stat_bgwriter.go +++ b/collector/pg_stat_bgwriter.go @@ -130,7 +130,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c return err } - var cptMetric float64 + cptMetric := 0.0 if cpt.Valid { cptMetric = float64(cpt.Int64) } @@ -139,7 +139,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c prometheus.CounterValue, cptMetric, ) - var cprMetric float64 + cprMetric := 0.0 if cpr.Valid { cprMetric = float64(cpr.Int64) } @@ -148,7 +148,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c prometheus.CounterValue, cprMetric, ) - var cpwtMetric float64 + cpwtMetric := 0.0 if cpwt.Valid { cpwtMetric = float64(cpwt.Float64) } @@ -157,7 +157,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c prometheus.CounterValue, cpwtMetric, ) - var cpstMetric float64 + cpstMetric := 0.0 if cpst.Valid { cpstMetric = float64(cpst.Float64) } @@ -166,7 +166,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c prometheus.CounterValue, cpstMetric, ) - var bcpMetric float64 + bcpMetric := 0.0 if bcp.Valid { bcpMetric = float64(bcp.Int64) } @@ -175,7 +175,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c prometheus.CounterValue, bcpMetric, ) - var bcMetric float64 + bcMetric := 0.0 if bc.Valid { bcMetric = float64(bc.Int64) } @@ -184,7 +184,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c prometheus.CounterValue, bcMetric, ) - var mwcMetric float64 + mwcMetric := 0.0 if mwc.Valid { mwcMetric = float64(mwc.Int64) } @@ -193,7 +193,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c prometheus.CounterValue, mwcMetric, ) - var bbMetric float64 + bbMetric := 0.0 if bb.Valid { bbMetric = float64(bb.Int64) } @@ -202,7 +202,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c prometheus.CounterValue, bbMetric, ) - var bbfMetric float64 + bbfMetric := 0.0 if bbf.Valid { bbfMetric = float64(bbf.Int64) } @@ -211,7 +211,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c prometheus.CounterValue, bbfMetric, ) - var baMetric float64 + baMetric := 0.0 if ba.Valid { baMetric = float64(ba.Int64) } @@ -220,7 +220,7 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c prometheus.CounterValue, baMetric, ) - var srMetric float64 + srMetric := 0.0 if sr.Valid { srMetric = float64(sr.Time.Unix()) } diff --git a/collector/pg_stat_database.go b/collector/pg_stat_database.go index 17d745df7..8a882f891 100644 --- a/collector/pg_stat_database.go +++ b/collector/pg_stat_database.go @@ -276,7 +276,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel = datname.String } - var numBackendsMetric float64 + numBackendsMetric := 0.0 if numBackends.Valid { numBackendsMetric = numBackends.Float64 } @@ -288,7 +288,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var xactCommitMetric float64 + xactCommitMetric := 0.0 if xactCommit.Valid { xactCommitMetric = xactCommit.Float64 } @@ -300,7 +300,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var xactRollbackMetric float64 + xactRollbackMetric := 0.0 if xactRollback.Valid { xactRollbackMetric = xactRollback.Float64 } @@ -312,7 +312,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var blksReadMetric float64 + blksReadMetric := 0.0 if blksRead.Valid { blksReadMetric = blksRead.Float64 } @@ -324,7 +324,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var blksHitMetric float64 + blksHitMetric := 0.0 if blksHit.Valid { blksHitMetric = blksHit.Float64 } @@ -336,7 +336,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var tupReturnedMetric float64 + tupReturnedMetric := 0.0 if tupReturned.Valid { tupReturnedMetric = tupReturned.Float64 } @@ -348,7 +348,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var tupFetchedMetric float64 + tupFetchedMetric := 0.0 if tupFetched.Valid { tupFetchedMetric = tupFetched.Float64 } @@ -360,7 +360,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var tupInsertedMetric float64 + tupInsertedMetric := 0.0 if tupInserted.Valid { tupInsertedMetric = tupInserted.Float64 } @@ -372,7 +372,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var tupUpdatedMetric float64 + tupUpdatedMetric := 0.0 if tupUpdated.Valid { tupUpdatedMetric = tupUpdated.Float64 } @@ -384,7 +384,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var tupDeletedMetric float64 + tupDeletedMetric := 0.0 if tupDeleted.Valid { tupDeletedMetric = tupDeleted.Float64 } @@ -396,7 +396,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var conflictsMetric float64 + conflictsMetric := 0.0 if conflicts.Valid { conflictsMetric = conflicts.Float64 } @@ -408,7 +408,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var tempFilesMetric float64 + tempFilesMetric := 0.0 if tempFiles.Valid { tempFilesMetric = tempFiles.Float64 } @@ -420,7 +420,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var tempBytesMetric float64 + tempBytesMetric := 0.0 if tempBytes.Valid { tempBytesMetric = tempBytes.Float64 } @@ -432,7 +432,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var deadlocksMetric float64 + deadlocksMetric := 0.0 if deadlocks.Valid { deadlocksMetric = deadlocks.Float64 } @@ -444,7 +444,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var blkReadTimeMetric float64 + blkReadTimeMetric := 0.0 if blkReadTime.Valid { blkReadTimeMetric = blkReadTime.Float64 } @@ -456,7 +456,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var blkWriteTimeMetric float64 + blkWriteTimeMetric := 0.0 if blkWriteTime.Valid { blkWriteTimeMetric = blkWriteTime.Float64 } @@ -468,7 +468,7 @@ func (PGStatDatabaseCollector) Update(ctx context.Context, instance *instance, c datnameLabel, ) - var statsResetMetric float64 + statsResetMetric := 0.0 if statsReset.Valid { statsResetMetric = float64(statsReset.Time.Unix()) } diff --git a/collector/pg_stat_statements.go b/collector/pg_stat_statements.go index afd53027f..bbfee1a2b 100644 --- a/collector/pg_stat_statements.go +++ b/collector/pg_stat_statements.go @@ -123,7 +123,7 @@ func (PGStatStatementsCollector) Update(ctx context.Context, instance *instance, queryidLabel = queryid.String } - var callsTotalMetric float64 + callsTotalMetric := 0.0 if callsTotal.Valid { callsTotalMetric = float64(callsTotal.Int64) } @@ -134,7 +134,7 @@ func (PGStatStatementsCollector) Update(ctx context.Context, instance *instance, userLabel, datnameLabel, queryidLabel, ) - var secondsTotalMetric float64 + secondsTotalMetric := 0.0 if secondsTotal.Valid { secondsTotalMetric = secondsTotal.Float64 } @@ -145,7 +145,7 @@ func (PGStatStatementsCollector) Update(ctx context.Context, instance *instance, userLabel, datnameLabel, queryidLabel, ) - var rowsTotalMetric float64 + rowsTotalMetric := 0.0 if rowsTotal.Valid { rowsTotalMetric = float64(rowsTotal.Int64) } @@ -156,7 +156,7 @@ func (PGStatStatementsCollector) Update(ctx context.Context, instance *instance, userLabel, datnameLabel, queryidLabel, ) - var blockReadSecondsTotalMetric float64 + blockReadSecondsTotalMetric := 0.0 if blockReadSecondsTotal.Valid { blockReadSecondsTotalMetric = blockReadSecondsTotal.Float64 } @@ -167,7 +167,7 @@ func (PGStatStatementsCollector) Update(ctx context.Context, instance *instance, userLabel, datnameLabel, queryidLabel, ) - var blockWriteSecondsTotalMetric float64 + blockWriteSecondsTotalMetric := 0.0 if blockWriteSecondsTotal.Valid { blockWriteSecondsTotalMetric = blockWriteSecondsTotal.Float64 } diff --git a/collector/pg_stat_user_tables.go b/collector/pg_stat_user_tables.go index 8e0374a9a..949a0ea2b 100644 --- a/collector/pg_stat_user_tables.go +++ b/collector/pg_stat_user_tables.go @@ -211,7 +211,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan relnameLabel = relname.String } - var seqScanMetric float64 + seqScanMetric := 0.0 if seqScan.Valid { seqScanMetric = float64(seqScan.Int64) } @@ -222,7 +222,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var seqTupReadMetric float64 + seqTupReadMetric := 0.0 if seqTupRead.Valid { seqTupReadMetric = float64(seqTupRead.Int64) } @@ -233,7 +233,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var idxScanMetric float64 + idxScanMetric := 0.0 if idxScan.Valid { idxScanMetric = float64(idxScan.Int64) } @@ -244,7 +244,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var idxTupFetchMetric float64 + idxTupFetchMetric := 0.0 if idxTupFetch.Valid { idxTupFetchMetric = float64(idxTupFetch.Int64) } @@ -255,7 +255,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var nTupInsMetric float64 + nTupInsMetric := 0.0 if nTupIns.Valid { nTupInsMetric = float64(nTupIns.Int64) } @@ -266,7 +266,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var nTupUpdMetric float64 + nTupUpdMetric := 0.0 if nTupUpd.Valid { nTupUpdMetric = float64(nTupUpd.Int64) } @@ -277,7 +277,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var nTupDelMetric float64 + nTupDelMetric := 0.0 if nTupDel.Valid { nTupDelMetric = float64(nTupDel.Int64) } @@ -288,7 +288,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var nTupHotUpdMetric float64 + nTupHotUpdMetric := 0.0 if nTupHotUpd.Valid { nTupHotUpdMetric = float64(nTupHotUpd.Int64) } @@ -299,7 +299,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var nLiveTupMetric float64 + nLiveTupMetric := 0.0 if nLiveTup.Valid { nLiveTupMetric = float64(nLiveTup.Int64) } @@ -310,7 +310,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var nDeadTupMetric float64 + nDeadTupMetric := 0.0 if nDeadTup.Valid { nDeadTupMetric = float64(nDeadTup.Int64) } @@ -321,7 +321,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var nModSinceAnalyzeMetric float64 + nModSinceAnalyzeMetric := 0.0 if nModSinceAnalyze.Valid { nModSinceAnalyzeMetric = float64(nModSinceAnalyze.Int64) } @@ -332,7 +332,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var lastVacuumMetric float64 + lastVacuumMetric := 0.0 if lastVacuum.Valid { lastVacuumMetric = float64(lastVacuum.Time.Unix()) } @@ -343,7 +343,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var lastAutovacuumMetric float64 + lastAutovacuumMetric := 0.0 if lastAutovacuum.Valid { lastAutovacuumMetric = float64(lastAutovacuum.Time.Unix()) } @@ -354,7 +354,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var lastAnalyzeMetric float64 + lastAnalyzeMetric := 0.0 if lastAnalyze.Valid { lastAnalyzeMetric = float64(lastAnalyze.Time.Unix()) } @@ -365,7 +365,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var lastAutoanalyzeMetric float64 + lastAutoanalyzeMetric := 0.0 if lastAutoanalyze.Valid { lastAutoanalyzeMetric = float64(lastAutoanalyze.Time.Unix()) } @@ -376,7 +376,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var vacuumCountMetric float64 + vacuumCountMetric := 0.0 if vacuumCount.Valid { vacuumCountMetric = float64(vacuumCount.Int64) } @@ -387,7 +387,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var autovacuumCountMetric float64 + autovacuumCountMetric := 0.0 if autovacuumCount.Valid { autovacuumCountMetric = float64(autovacuumCount.Int64) } @@ -398,7 +398,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var analyzeCountMetric float64 + analyzeCountMetric := 0.0 if analyzeCount.Valid { analyzeCountMetric = float64(analyzeCount.Int64) } @@ -409,7 +409,7 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan datnameLabel, schemanameLabel, relnameLabel, ) - var autoanalyzeCountMetric float64 + autoanalyzeCountMetric := 0.0 if autoanalyzeCount.Valid { autoanalyzeCountMetric = float64(autoanalyzeCount.Int64) } diff --git a/collector/pg_statio_user_tables.go b/collector/pg_statio_user_tables.go index 853a49f4e..89fdec532 100644 --- a/collector/pg_statio_user_tables.go +++ b/collector/pg_statio_user_tables.go @@ -130,7 +130,7 @@ func (PGStatIOUserTablesCollector) Update(ctx context.Context, instance *instanc relnameLabel = relname.String } - var heapBlksReadMetric float64 + heapBlksReadMetric := 0.0 if heapBlksRead.Valid { heapBlksReadMetric = float64(heapBlksRead.Int64) } @@ -141,7 +141,7 @@ func (PGStatIOUserTablesCollector) Update(ctx context.Context, instance *instanc datnameLabel, schemanameLabel, relnameLabel, ) - var heapBlksHitMetric float64 + heapBlksHitMetric := 0.0 if heapBlksHit.Valid { heapBlksHitMetric = float64(heapBlksHit.Int64) } @@ -152,7 +152,7 @@ func (PGStatIOUserTablesCollector) Update(ctx context.Context, instance *instanc datnameLabel, schemanameLabel, relnameLabel, ) - var idxBlksReadMetric float64 + idxBlksReadMetric := 0.0 if idxBlksRead.Valid { idxBlksReadMetric = float64(idxBlksRead.Int64) } @@ -163,7 +163,7 @@ func (PGStatIOUserTablesCollector) Update(ctx context.Context, instance *instanc datnameLabel, schemanameLabel, relnameLabel, ) - var idxBlksHitMetric float64 + idxBlksHitMetric := 0.0 if idxBlksHit.Valid { idxBlksHitMetric = float64(idxBlksHit.Int64) } @@ -174,7 +174,7 @@ func (PGStatIOUserTablesCollector) Update(ctx context.Context, instance *instanc datnameLabel, schemanameLabel, relnameLabel, ) - var toastBlksReadMetric float64 + toastBlksReadMetric := 0.0 if toastBlksRead.Valid { toastBlksReadMetric = float64(toastBlksRead.Int64) } @@ -185,7 +185,7 @@ func (PGStatIOUserTablesCollector) Update(ctx context.Context, instance *instanc datnameLabel, schemanameLabel, relnameLabel, ) - var toastBlksHitMetric float64 + toastBlksHitMetric := 0.0 if toastBlksHit.Valid { toastBlksHitMetric = float64(toastBlksHit.Int64) } @@ -196,7 +196,7 @@ func (PGStatIOUserTablesCollector) Update(ctx context.Context, instance *instanc datnameLabel, schemanameLabel, relnameLabel, ) - var tidxBlksReadMetric float64 + tidxBlksReadMetric := 0.0 if tidxBlksRead.Valid { tidxBlksReadMetric = float64(tidxBlksRead.Int64) } @@ -207,7 +207,7 @@ func (PGStatIOUserTablesCollector) Update(ctx context.Context, instance *instanc datnameLabel, schemanameLabel, relnameLabel, ) - var tidxBlksHitMetric float64 + tidxBlksHitMetric := 0.0 if tidxBlksHit.Valid { tidxBlksHitMetric = float64(tidxBlksHit.Int64) }