@@ -32,9 +32,9 @@ func TestPGStateStatementsCollector(t *testing.T) {
32
32
33
33
inst := & instance {db : db , version : semver .MustParse ("12.0.0" )}
34
34
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" }
36
36
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 )
38
38
mock .ExpectQuery (sanitizeQuery (pgStatStatementsQuery )).WillReturnRows (rows )
39
39
40
40
ch := make (chan prometheus.Metric )
@@ -48,11 +48,11 @@ func TestPGStateStatementsCollector(t *testing.T) {
48
48
}()
49
49
50
50
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 },
56
56
}
57
57
58
58
convey .Convey ("Metrics comparison" , t , func () {
@@ -75,9 +75,9 @@ func TestPGStateStatementsCollectorNull(t *testing.T) {
75
75
76
76
inst := & instance {db : db , version : semver .MustParse ("13.3.7" )}
77
77
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" }
79
79
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 )
81
81
mock .ExpectQuery (sanitizeQuery (pgStatStatementsNewQuery )).WillReturnRows (rows )
82
82
83
83
ch := make (chan prometheus.Metric )
@@ -91,11 +91,11 @@ func TestPGStateStatementsCollectorNull(t *testing.T) {
91
91
}()
92
92
93
93
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 },
99
99
}
100
100
101
101
convey .Convey ("Metrics comparison" , t , func () {
@@ -118,9 +118,9 @@ func TestPGStateStatementsCollectorNewPG(t *testing.T) {
118
118
119
119
inst := & instance {db : db , version : semver .MustParse ("13.3.7" )}
120
120
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" }
122
122
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 )
124
124
mock .ExpectQuery (sanitizeQuery (pgStatStatementsNewQuery )).WillReturnRows (rows )
125
125
126
126
ch := make (chan prometheus.Metric )
@@ -134,11 +134,11 @@ func TestPGStateStatementsCollectorNewPG(t *testing.T) {
134
134
}()
135
135
136
136
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 },
142
142
}
143
143
144
144
convey .Convey ("Metrics comparison" , t , func () {
0 commit comments