@@ -33,9 +33,9 @@ func TestPGStateStatementsCollector(t *testing.T) {
3333
3434inst := & instance {db : db , version : semver .MustParse ("12.0.0" )}
3535
36- columns := []string {"user" , "datname" , "queryid" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
36+ columns := []string {"user" , "datname" , "queryid" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" , "max_seconds" , "mean_seconds" , "stddev_seconds" }
3737rows := sqlmock .NewRows (columns ).
38- AddRow ("postgres" , "postgres" , 1500 , 5 , 0.4 , 100 , 0.1 , 0.2 )
38+ AddRow ("postgres" , "postgres" , 1500 , 5 , 0.4 , 100 , 0.1 , 0.2 , 0.8 , 0.08 , 0.05 )
3939mock .ExpectQuery (sanitizeQuery (fmt .Sprintf (pgStatStatementsQuery , "" ))).WillReturnRows (rows )
4040
4141ch := make (chan prometheus.Metric )
@@ -76,9 +76,9 @@ func TestPGStateStatementsCollectorWithStatement(t *testing.T) {
7676
7777inst := & instance {db : db , version : semver .MustParse ("12.0.0" )}
7878
79- columns := []string {"user" , "datname" , "queryid" , "LEFT(pg_stat_statements.query, 100) as query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
79+ columns := []string {"user" , "datname" , "queryid" , "LEFT(pg_stat_statements.query, 100) as query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" , "max_seconds" , "mean_seconds" , "stddev_seconds" }
8080rows := sqlmock .NewRows (columns ).
81- AddRow ("postgres" , "postgres" , 1500 , "select 1 from foo" , 5 , 0.4 , 100 , 0.1 , 0.2 )
81+ AddRow ("postgres" , "postgres" , 1500 , "select 1 from foo" , 5 , 0.4 , 100 , 0.1 , 0.2 , 0.8 , 0.08 , 0.05 )
8282mock .ExpectQuery (sanitizeQuery (fmt .Sprintf (pgStatStatementsQuery , fmt .Sprintf (pgStatStatementQuerySelect , 100 )))).WillReturnRows (rows )
8383
8484ch := make (chan prometheus.Metric )
@@ -97,6 +97,9 @@ func TestPGStateStatementsCollectorWithStatement(t *testing.T) {
9797{labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 100 },
9898{labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.1 },
9999{labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.2 },
100+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_GAUGE , value : 0.8 },
101+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_GAUGE , value : 0.08 },
102+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_GAUGE , value : 0.05 },
100103{labels : labelMap {"queryid" : "1500" , "query" : "select 1 from foo" }, metricType : dto .MetricType_COUNTER , value : 1 },
101104}
102105
@@ -120,9 +123,9 @@ func TestPGStateStatementsCollectorNull(t *testing.T) {
120123
121124inst := & instance {db : db , version : semver .MustParse ("13.3.7" )}
122125
123- columns := []string {"user" , "datname" , "queryid" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
126+ columns := []string {"user" , "datname" , "queryid" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" , "max_seconds" , "mean_seconds" , "stddev_seconds" }
124127rows := sqlmock .NewRows (columns ).
125- AddRow (nil , nil , nil , nil , nil , nil , nil , nil )
128+ AddRow (nil , nil , nil , nil , nil , nil , nil , nil , nil , nil , nil )
126129mock .ExpectQuery (sanitizeQuery (fmt .Sprintf (pgStatStatementsNewQuery , "" ))).WillReturnRows (rows )
127130
128131ch := make (chan prometheus.Metric )
@@ -163,9 +166,9 @@ func TestPGStateStatementsCollectorNullWithStatement(t *testing.T) {
163166
164167inst := & instance {db : db , version : semver .MustParse ("13.3.7" )}
165168
166- columns := []string {"user" , "datname" , "queryid" , "LEFT(pg_stat_statements.query, 200) as query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
169+ columns := []string {"user" , "datname" , "queryid" , "LEFT(pg_stat_statements.query, 200) as query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" , "max_seconds" , "mean_seconds" , "stddev_seconds" }
167170rows := sqlmock .NewRows (columns ).
168- AddRow (nil , nil , nil , nil , nil , nil , nil , nil , nil )
171+ AddRow (nil , nil , nil , nil , nil , nil , nil , nil , nil , nil , nil , nil )
169172mock .ExpectQuery (sanitizeQuery (fmt .Sprintf (pgStatStatementsNewQuery , fmt .Sprintf (pgStatStatementQuerySelect , 200 )))).WillReturnRows (rows )
170173
171174ch := make (chan prometheus.Metric )
@@ -184,6 +187,9 @@ func TestPGStateStatementsCollectorNullWithStatement(t *testing.T) {
184187{labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
185188{labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
186189{labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 0 },
190+ {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_GAUGE , value : 0 },
191+ {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_GAUGE , value : 0 },
192+ {labels : labelMap {"user" : "unknown" , "datname" : "unknown" , "queryid" : "unknown" }, metricType : dto .MetricType_GAUGE , value : 0 },
187193{labels : labelMap {"queryid" : "unknown" , "query" : "unknown" }, metricType : dto .MetricType_COUNTER , value : 1 },
188194}
189195
@@ -207,9 +213,9 @@ func TestPGStateStatementsCollectorNewPG(t *testing.T) {
207213
208214inst := & instance {db : db , version : semver .MustParse ("13.3.7" )}
209215
210- columns := []string {"user" , "datname" , "queryid" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
216+ columns := []string {"user" , "datname" , "queryid" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" , "max_seconds" , "mean_seconds" , "stddev_seconds" }
211217rows := sqlmock .NewRows (columns ).
212- AddRow ("postgres" , "postgres" , 1500 , 5 , 0.4 , 100 , 0.1 , 0.2 )
218+ AddRow ("postgres" , "postgres" , 1500 , 5 , 0.4 , 100 , 0.1 , 0.2 , 0.8 , 0.08 , 0.05 )
213219mock .ExpectQuery (sanitizeQuery (fmt .Sprintf (pgStatStatementsNewQuery , "" ))).WillReturnRows (rows )
214220
215221ch := make (chan prometheus.Metric )
@@ -250,9 +256,9 @@ func TestPGStateStatementsCollectorNewPGWithStatement(t *testing.T) {
250256
251257inst := & instance {db : db , version : semver .MustParse ("13.3.7" )}
252258
253- columns := []string {"user" , "datname" , "queryid" , "LEFT(pg_stat_statements.query, 300) as query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
259+ columns := []string {"user" , "datname" , "queryid" , "LEFT(pg_stat_statements.query, 300) as query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" , "max_seconds" , "mean_seconds" , "stddev_seconds" }
254260rows := sqlmock .NewRows (columns ).
255- AddRow ("postgres" , "postgres" , 1500 , "select 1 from foo" , 5 , 0.4 , 100 , 0.1 , 0.2 )
261+ AddRow ("postgres" , "postgres" , 1500 , "select 1 from foo" , 5 , 0.4 , 100 , 0.1 , 0.2 , 0.8 , 0.08 , 0.05 )
256262mock .ExpectQuery (sanitizeQuery (fmt .Sprintf (pgStatStatementsNewQuery , fmt .Sprintf (pgStatStatementQuerySelect , 300 )))).WillReturnRows (rows )
257263
258264ch := make (chan prometheus.Metric )
@@ -271,6 +277,9 @@ func TestPGStateStatementsCollectorNewPGWithStatement(t *testing.T) {
271277{labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 100 },
272278{labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.1 },
273279{labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.2 },
280+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_GAUGE , value : 0.8 },
281+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_GAUGE , value : 0.08 },
282+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_GAUGE , value : 0.05 },
274283{labels : labelMap {"queryid" : "1500" , "query" : "select 1 from foo" }, metricType : dto .MetricType_COUNTER , value : 1 },
275284}
276285
@@ -294,9 +303,9 @@ func TestPGStateStatementsCollector_PG17(t *testing.T) {
294303
295304inst := & instance {db : db , version : semver .MustParse ("17.0.0" )}
296305
297- columns := []string {"user" , "datname" , "queryid" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
306+ columns := []string {"user" , "datname" , "queryid" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" , "max_seconds" , "mean_seconds" , "stddev_seconds" }
298307rows := sqlmock .NewRows (columns ).
299- AddRow ("postgres" , "postgres" , 1500 , 5 , 0.4 , 100 , 0.1 , 0.2 )
308+ AddRow ("postgres" , "postgres" , 1500 , 5 , 0.4 , 100 , 0.1 , 0.2 , 0.8 , 0.08 , 0.05 )
300309mock .ExpectQuery (sanitizeQuery (fmt .Sprintf (pgStatStatementsQuery_PG17 , "" ))).WillReturnRows (rows )
301310
302311ch := make (chan prometheus.Metric )
@@ -337,9 +346,9 @@ func TestPGStateStatementsCollector_PG17_WithStatement(t *testing.T) {
337346
338347inst := & instance {db : db , version : semver .MustParse ("17.0.0" )}
339348
340- columns := []string {"user" , "datname" , "queryid" , "LEFT(pg_stat_statements.query, 300) as query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" }
349+ columns := []string {"user" , "datname" , "queryid" , "LEFT(pg_stat_statements.query, 300) as query" , "calls_total" , "seconds_total" , "rows_total" , "block_read_seconds_total" , "block_write_seconds_total" , "max_seconds" , "mean_seconds" , "stddev_seconds" }
341350rows := sqlmock .NewRows (columns ).
342- AddRow ("postgres" , "postgres" , 1500 , "select 1 from foo" , 5 , 0.4 , 100 , 0.1 , 0.2 )
351+ AddRow ("postgres" , "postgres" , 1500 , "select 1 from foo" , 5 , 0.4 , 100 , 0.1 , 0.2 , 0.8 , 0.08 , 0.05 )
343352mock .ExpectQuery (sanitizeQuery (fmt .Sprintf (pgStatStatementsQuery_PG17 , fmt .Sprintf (pgStatStatementQuerySelect , 300 )))).WillReturnRows (rows )
344353
345354ch := make (chan prometheus.Metric )
@@ -358,6 +367,9 @@ func TestPGStateStatementsCollector_PG17_WithStatement(t *testing.T) {
358367{labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 100 },
359368{labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.1 },
360369{labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_COUNTER , value : 0.2 },
370+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_GAUGE , value : 0.8 },
371+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_GAUGE , value : 0.08 },
372+ {labels : labelMap {"user" : "postgres" , "datname" : "postgres" , "queryid" : "1500" }, metricType : dto .MetricType_GAUGE , value : 0.05 },
361373{labels : labelMap {"queryid" : "1500" , "query" : "select 1 from foo" }, metricType : dto .MetricType_COUNTER , value : 1 },
362374}
363375
0 commit comments