1
0
mirror of https://github.com/prometheus-community/postgres_exporter.git synced 2025-07-30 09:43:10 +03:00

Record table only size bytes as well in addition to the total size bytes (#1149)

* Record table only size bytes as well in addition to the total size bytes

Signed-off-by: Felix Yuan <felix.yuan@reddit.com>

* Update collector/pg_stat_user_tables.go

Co-authored-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Felix Yuan <felix.yuan@reddit.com>

* Update collector/pg_stat_user_tables.go

Co-authored-by: Ben Kochie <superq@gmail.com>
Signed-off-by: Felix Yuan <felix.yuan@reddit.com>

* Finish renaming elements to index and table size

Signed-off-by: Felix Yuan <felix.yuan@reddit.com>

---------

Signed-off-by: Felix Yuan <felix.yuan@reddit.com>
Co-authored-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Felix Yuan
2025-04-18 07:14:25 -07:00
committed by GitHub
parent f8b7139174
commit 5edc331876
2 changed files with 40 additions and 14 deletions

View File

@ -72,7 +72,8 @@ func TestPGStatUserTablesCollector(t *testing.T) {
"autovacuum_count",
"analyze_count",
"autoanalyze_count",
"total_size"}
"index_size",
"table_size"}
rows := sqlmock.NewRows(columns).
AddRow("postgres",
"public",
@ -96,7 +97,8 @@ func TestPGStatUserTablesCollector(t *testing.T) {
12,
13,
14,
15)
15,
16)
mock.ExpectQuery(sanitizeQuery(statUserTablesQuery)).WillReturnRows(rows)
ch := make(chan prometheus.Metric)
go func() {
@ -128,6 +130,8 @@ func TestPGStatUserTablesCollector(t *testing.T) {
{labels: labelMap{"datname": "postgres", "schemaname": "public", "relname": "a_table"}, metricType: dto.MetricType_COUNTER, value: 12},
{labels: labelMap{"datname": "postgres", "schemaname": "public", "relname": "a_table"}, metricType: dto.MetricType_COUNTER, value: 13},
{labels: labelMap{"datname": "postgres", "schemaname": "public", "relname": "a_table"}, metricType: dto.MetricType_COUNTER, value: 14},
{labels: labelMap{"datname": "postgres", "schemaname": "public", "relname": "a_table"}, metricType: dto.MetricType_GAUGE, value: 15},
{labels: labelMap{"datname": "postgres", "schemaname": "public", "relname": "a_table"}, metricType: dto.MetricType_GAUGE, value: 16},
}
convey.Convey("Metrics comparison", t, func() {
@ -173,7 +177,8 @@ func TestPGStatUserTablesCollectorNullValues(t *testing.T) {
"autovacuum_count",
"analyze_count",
"autoanalyze_count",
"total_size"}
"index_size",
"table_size"}
rows := sqlmock.NewRows(columns).
AddRow("postgres",
nil,
@ -197,6 +202,7 @@ func TestPGStatUserTablesCollectorNullValues(t *testing.T) {
nil,
nil,
nil,
nil,
nil)
mock.ExpectQuery(sanitizeQuery(statUserTablesQuery)).WillReturnRows(rows)
ch := make(chan prometheus.Metric)
@ -229,6 +235,8 @@ func TestPGStatUserTablesCollectorNullValues(t *testing.T) {
{labels: labelMap{"datname": "postgres", "schemaname": "unknown", "relname": "unknown"}, metricType: dto.MetricType_COUNTER, value: 0},
{labels: labelMap{"datname": "postgres", "schemaname": "unknown", "relname": "unknown"}, metricType: dto.MetricType_COUNTER, value: 0},
{labels: labelMap{"datname": "postgres", "schemaname": "unknown", "relname": "unknown"}, metricType: dto.MetricType_COUNTER, value: 0},
{labels: labelMap{"datname": "postgres", "schemaname": "unknown", "relname": "unknown"}, metricType: dto.MetricType_GAUGE, value: 0},
{labels: labelMap{"datname": "postgres", "schemaname": "unknown", "relname": "unknown"}, metricType: dto.MetricType_GAUGE, value: 0},
}
convey.Convey("Metrics comparison", t, func() {