@@ -32,9 +32,9 @@ func TestPGStateStatementsCollector(t *testing.T) {
3232
3333 inst := & instance {db : db , version : semver .MustParse ("12.0.0" )}
3434
35- columns := []string {"user" , "datname" , "queryid" , "query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
35+ columns := []string {"user" , "datname" , "queryid" , "query" , "stmt_type" , " calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
3636 rows := sqlmock .NewRows (columns ).
37- AddRow ("postgres" , "postgres" , 1500 , "SELECT" , 5 , 0.4 , 100 , 0.1 , 0.2 )
37+ AddRow ("postgres" , "postgres" , 1500 , "SELECT" , "SELECT" , 5 , 0.4 , 100 , 0.1 , 0.2 )
3838 mock .ExpectQuery (sanitizeQuery (pgStatStatementsQuery )).WillReturnRows (rows )
3939
4040 ch := make (chan prometheus.Metric )
@@ -48,11 +48,11 @@ func TestPGStateStatementsCollector(t *testing.T) {
4848 }()
4949
5050 expected := []MetricResult {
51- {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 5 },
52- {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.4 },
53- {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 100 },
54- {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.1 },
55- {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.2 },
51+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "stmt_type" : "SELECT" , " queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 5 },
52+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "stmt_type" : "SELECT" , " queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.4 },
53+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "stmt_type" : "SELECT" , " queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 100 },
54+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "stmt_type" : "SELECT" , " queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.1 },
55+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "stmt_type" : "SELECT" , " queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.2 },
5656 }
5757
5858 convey .Convey ("Metrics comparison" , t , func () {
@@ -75,9 +75,9 @@ func TestPGStateStatementsCollectorNull(t *testing.T) {
7575
7676 inst := & instance {db : db , version : semver .MustParse ("13.3.7" )}
7777
78- columns := []string {"user" , "datname" , "queryid" , "query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
78+ columns := []string {"user" , "datname" , "queryid" , "query" , "stmt_type" , " calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
7979 rows := sqlmock .NewRows (columns ).
80- AddRow (nil , nil , nil , nil , nil , nil , nil , nil , nil )
80+ AddRow (nil , nil , nil , nil , nil , nil , nil , nil , nil , nil )
8181 mock .ExpectQuery (sanitizeQuery (pgStatStatementsNewQuery )).WillReturnRows (rows )
8282
8383 ch := make (chan prometheus.Metric )
@@ -91,11 +91,11 @@ func TestPGStateStatementsCollectorNull(t *testing.T) {
9191 }()
9292
9393 expected := []MetricResult {
94- {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "query" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
95- {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "query" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
96- {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "query" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
97- {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "query" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
98- {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "query" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
94+ {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "query" : "unknown" , "stmt_type" : "unknown" , " queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
95+ {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "query" : "unknown" , "stmt_type" : "unknown" , " queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
96+ {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "query" : "unknown" , "stmt_type" : "unknown" , " queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
97+ {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "query" : "unknown" , "stmt_type" : "unknown" , " queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
98+ {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "query" : "unknown" , "stmt_type" : "unknown" , " queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
9999 }
100100
101101 convey .Convey ("Metrics comparison" , t , func () {
@@ -118,9 +118,9 @@ func TestPGStateStatementsCollectorNewPG(t *testing.T) {
118118
119119 inst := & instance {db : db , version : semver .MustParse ("13.3.7" )}
120120
121- columns := []string {"user" , "datname" , "queryid" , "query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
121+ columns := []string {"user" , "datname" , "queryid" , "query" , "stmt_type" , " calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
122122 rows := sqlmock .NewRows (columns ).
123- AddRow ("postgres" , "postgres" , 1500 , "SELECT" , 5 , 0.4 , 100 , 0.1 , 0.2 )
123+ AddRow ("postgres" , "postgres" , 1500 , "SELECT" , "SELECT" , 5 , 0.4 , 100 , 0.1 , 0.2 )
124124 mock .ExpectQuery (sanitizeQuery (pgStatStatementsNewQuery )).WillReturnRows (rows )
125125
126126 ch := make (chan prometheus.Metric )
@@ -134,11 +134,11 @@ func TestPGStateStatementsCollectorNewPG(t *testing.T) {
134134 }()
135135
136136 expected := []MetricResult {
137- {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 5 },
138- {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.4 },
139- {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 100 },
140- {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.1 },
141- {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.2 },
137+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "stmt_type" : "SELECT" , " queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 5 },
138+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "stmt_type" : "SELECT" , " queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.4 },
139+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "stmt_type" : "SELECT" , " queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 100 },
140+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "stmt_type" : "SELECT" , " queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.1 },
141+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "query" : "SELECT" , "stmt_type" : "SELECT" , " queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.2 },
142142 }
143143
144144 convey .Convey ("Metrics comparison" , t , func () {
0 commit comments