Skip to content

Commit fe39c1c

Browse files
committed
fix: rename pgbouncer stats columns to reflect stats_total command
Signed-off-by: Sverre Boschman <[email protected]>
1 parent d4e484f commit fe39c1c

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

collector.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ var (
4545
"disabled": {GAUGE, "disabled", 1, "1 if this database is currently disabled, else 0"},
4646
},
4747
"stats_totals": {
48-
"database": {LABEL, "N/A", 1, "N/A"},
49-
"total_query_count": {COUNTER, "queries_pooled_total", 1, "Total number of SQL queries pooled"},
50-
"total_query_time": {COUNTER, "queries_duration_seconds_total", 1e-6, "Total number of seconds spent by pgbouncer when actively connected to PostgreSQL, executing queries"},
51-
"total_received": {COUNTER, "received_bytes_total", 1, "Total volume in bytes of network traffic received by pgbouncer, shown as bytes"},
52-
"total_requests": {COUNTER, "queries_total", 1, "Total number of SQL requests pooled by pgbouncer, shown as requests"},
53-
"total_sent": {COUNTER, "sent_bytes_total", 1, "Total volume in bytes of network traffic sent by pgbouncer, shown as bytes"},
54-
"total_wait_time": {COUNTER, "client_wait_seconds_total", 1e-6, "Time spent by clients waiting for a server in seconds"},
55-
"total_xact_count": {COUNTER, "sql_transactions_pooled_total", 1, "Total number of SQL transactions pooled"},
56-
"total_xact_time": {COUNTER, "server_in_transaction_seconds_total", 1e-6, "Total number of seconds spent by pgbouncer when connected to PostgreSQL in a transaction, either idle in transaction or executing queries"},
57-
"total_client_parse_count": {COUNTER, "client_parses_total", 1, "Total number of prepared statement Parse messages received from clients"},
58-
"total_server_parse_count": {COUNTER, "server_parses_total", 1, "Total number of prepared statement Parse messages sent by pgbouncer to PostgreSQL"},
59-
"total_bind_count": {COUNTER, "binds_total", 1, "Total number of prepared statements readied for execution with a Bind message"},
48+
"database": {LABEL, "N/A", 1, "N/A"},
49+
"query_count": {COUNTER, "queries_pooled_total", 1, "Total number of SQL queries pooled"},
50+
"query_time": {COUNTER, "queries_duration_seconds_total", 1e-6, "Total number of seconds spent by pgbouncer when actively connected to PostgreSQL, executing queries"},
51+
"bytes_received": {COUNTER, "received_bytes_total", 1, "Total volume in bytes of network traffic received by pgbouncer, shown as bytes"},
52+
"requests": {COUNTER, "queries_total", 1, "Total number of SQL requests pooled by pgbouncer, shown as requests"},
53+
"bytes_sent": {COUNTER, "sent_bytes_total", 1, "Total volume in bytes of network traffic sent by pgbouncer, shown as bytes"},
54+
"wait_time": {COUNTER, "client_wait_seconds_total", 1e-6, "Time spent by clients waiting for a server in seconds"},
55+
"xact_count": {COUNTER, "sql_transactions_pooled_total", 1, "Total number of SQL transactions pooled"},
56+
"xact_time": {COUNTER, "server_in_transaction_seconds_total", 1e-6, "Total number of seconds spent by pgbouncer when connected to PostgreSQL in a transaction, either idle in transaction or executing queries"},
57+
"client_parse_count": {COUNTER, "client_parses_total", 1, "Total number of prepared statement Parse messages received from clients"},
58+
"server_parse_count": {COUNTER, "server_parses_total", 1, "Total number of prepared statement Parse messages sent by pgbouncer to PostgreSQL"},
59+
"bind_count": {COUNTER, "binds_total", 1, "Total number of prepared statements readied for execution with a Bind message"},
6060
},
6161
"pools": {
6262
"database": {LABEL, "N/A", 1, "N/A"},

collector_test.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,23 @@ func TestQueryShowDatabases(t *testing.T) {
144144
func TestQueryShowStats(t *testing.T) {
145145
// columns are listed in the order PgBouncers exposes them, a value of -1 means pgbouncer_exporter does not expose this value as a metric
146146
rows := sqlmock.NewRows([]string{"database",
147-
"total_xact_count", "total_query_count", "total_server_assignment_count", "total_received", "total_sent",
148-
"total_xact_time", "total_query_time", "total_wait_time", "total_client_parse_count", "total_server_parse_count", "total_bind_count"}).
149-
AddRow("pg0", 10, 40, -1, 220, 460, 6, 8, 9, 5, 55, 555)
147+
"server_assignment_count",
148+
"xact_count", "query_count", "bytes_received", "bytes_sent",
149+
"xact_time", "query_time", "wait_time", "client_parse_count", "server_parse_count", "bind_count"}).
150+
AddRow("pg0", -1, 10, 40, 220, 460, 6, 8, 9, 5, 55, 555)
150151

151152
// expected metrics are returned in the same order as the colums
152153
expected := []MetricResult{
153-
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 10}, // total_xact_count
154-
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 40}, // total_query_count
155-
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 220}, // total_received
156-
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 460}, // total_sent
157-
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 6e-6}, // total_xact_time
158-
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 8e-6}, // total_query_time
159-
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 9e-6}, // total_wait_time
160-
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 5}, // total_client_parse_count
161-
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 55}, // total_server_parse_count
162-
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 555}, // total_bind_count
154+
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 10}, // xact_count
155+
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 40}, // query_count
156+
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 220}, // bytes_received
157+
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 460}, // bytes_sent
158+
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 6e-6}, // xact_time
159+
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 8e-6}, // query_time
160+
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 9e-6}, // wait_time
161+
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 5}, // client_parse_count
162+
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 55}, // server_parse_count
163+
{labels: labelMap{"database": "pg0"}, metricType: dto.MetricType_COUNTER, value: 555}, // bind_count
163164
}
164165

165166
testQueryNamespaceMapping(t, "stats_totals", rows, expected)

0 commit comments

Comments
 (0)