Skip to content

Commit 27388e7

Browse files
committed
Finish renaming elements to index and table size
1 parent b950538 commit 27388e7

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

collector/pg_stat_user_tables.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ var (
150150
[]string{"datname", "schemaname", "relname"},
151151
prometheus.Labels{},
152152
)
153-
statUserTablesTotalSize = prometheus.NewDesc(
154-
prometheus.BuildFQName(namespace, userTableSubsystem, "size_bytes"),
155-
"Total disk space used by this table, in bytes, including all indexes and TOAST data",
153+
statUserIndexSize = prometheus.NewDesc(
154+
prometheus.BuildFQName(namespace, userTableSubsystem, "index_size_bytes"),
155+
"Total disk space used by this index, in bytes",
156156
[]string{"datname", "schemaname", "relname"},
157157
prometheus.Labels{},
158158
)
159-
statUserTablesOnlySize = prometheus.NewDesc(
159+
statUserTableSize = prometheus.NewDesc(
160160
prometheus.BuildFQName(namespace, userTableSubsystem, "table_size_bytes"),
161-
"Total disk space used by only this table, in bytes",
161+
"Total disk space used by this table, in bytes",
162162
[]string{"datname", "schemaname", "relname"},
163163
prometheus.Labels{},
164164
)
@@ -205,10 +205,10 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan
205205
for rows.Next() {
206206
var datname, schemaname, relname sql.NullString
207207
var seqScan, seqTupRead, idxScan, idxTupFetch, nTupIns, nTupUpd, nTupDel, nTupHotUpd, nLiveTup, nDeadTup,
208-
nModSinceAnalyze, vacuumCount, autovacuumCount, analyzeCount, autoanalyzeCount, totalSize, tableOnlySize sql.NullInt64
208+
nModSinceAnalyze, vacuumCount, autovacuumCount, analyzeCount, autoanalyzeCount, indexSize, tableSize sql.NullInt64
209209
var lastVacuum, lastAutovacuum, lastAnalyze, lastAutoanalyze sql.NullTime
210210

211-
if err := rows.Scan(&datname, &schemaname, &relname, &seqScan, &seqTupRead, &idxScan, &idxTupFetch, &nTupIns, &nTupUpd, &nTupDel, &nTupHotUpd, &nLiveTup, &nDeadTup, &nModSinceAnalyze, &lastVacuum, &lastAutovacuum, &lastAnalyze, &lastAutoanalyze, &vacuumCount, &autovacuumCount, &analyzeCount, &autoanalyzeCount, &totalSize, &tableOnlySize); err != nil {
211+
if err := rows.Scan(&datname, &schemaname, &relname, &seqScan, &seqTupRead, &idxScan, &idxTupFetch, &nTupIns, &nTupUpd, &nTupDel, &nTupHotUpd, &nLiveTup, &nDeadTup, &nModSinceAnalyze, &lastVacuum, &lastAutovacuum, &lastAnalyze, &lastAutoanalyze, &vacuumCount, &autovacuumCount, &analyzeCount, &autoanalyzeCount, &indexSize, &tableSize); err != nil {
212212
return err
213213
}
214214

@@ -434,25 +434,25 @@ func (c *PGStatUserTablesCollector) Update(ctx context.Context, instance *instan
434434
datnameLabel, schemanameLabel, relnameLabel,
435435
)
436436

437-
totalSizeMetric := 0.0
438-
if totalSize.Valid {
439-
totalSizeMetric = float64(totalSize.Int64)
437+
indexSizeMetric := 0.0
438+
if indexSize.Valid {
439+
indexSizeMetric = float64(indexSize.Int64)
440440
}
441441
ch <- prometheus.MustNewConstMetric(
442-
statUserTablesTotalSize,
442+
statUserIndexSize,
443443
prometheus.GaugeValue,
444-
totalSizeMetric,
444+
indexSizeMetric,
445445
datnameLabel, schemanameLabel, relnameLabel,
446446
)
447447

448-
tableOnlySizeMetric := 0.0
449-
if tableOnlySize.Valid {
450-
tableOnlySizeMetric = float64(tableOnlySize.Int64)
448+
tableSizeMetric := 0.0
449+
if tableSize.Valid {
450+
tableSizeMetric = float64(tableSize.Int64)
451451
}
452452
ch <- prometheus.MustNewConstMetric(
453-
statUserTablesOnlySize,
453+
statUserTableSize,
454454
prometheus.GaugeValue,
455-
tableOnlySizeMetric,
455+
tableSizeMetric,
456456
datnameLabel, schemanameLabel, relnameLabel,
457457
)
458458
}

collector/pg_stat_user_tables_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ func TestPGStatUserTablesCollector(t *testing.T) {
7272
"autovacuum_count",
7373
"analyze_count",
7474
"autoanalyze_count",
75-
"total_size",
76-
"table_only_size"}
75+
"index_size",
76+
"table_size"}
7777
rows := sqlmock.NewRows(columns).
7878
AddRow("postgres",
7979
"public",
@@ -177,8 +177,8 @@ func TestPGStatUserTablesCollectorNullValues(t *testing.T) {
177177
"autovacuum_count",
178178
"analyze_count",
179179
"autoanalyze_count",
180-
"total_size",
181-
"table_only_size"}
180+
"index_size",
181+
"table_size"}
182182
rows := sqlmock.NewRows(columns).
183183
AddRow("postgres",
184184
nil,

0 commit comments

Comments
 (0)