@@ -18,6 +18,7 @@ import (
1818 "database/sql"
1919
2020 "github.com/go-kit/log"
21+ "github.com/lib/pq"
2122 "github.com/prometheus/client_golang/prometheus"
2223)
2324
@@ -82,22 +83,22 @@ func (PGProcessIdleCollector) Update(ctx context.Context, inst *instance, ch cha
8283 GROUP BY 1, 2, 3;` )
8384
8485 var applicationName sql.NullString
85- var secondsSum sql.NullInt64
86+ var secondsSum sql.NullFloat64
8687 var secondsCount sql.NullInt64
87- var seconds []uint64
88- var secondsBucket []uint64
88+ var seconds []float64
89+ var secondsBucket []int64
8990
90- err := row .Scan (& applicationName , & secondsSum , & secondsCount , & seconds , & secondsBucket )
91+ err := row .Scan (& applicationName , & secondsSum , & secondsCount , pq .Array (& seconds ), pq .Array (& secondsBucket ))
92+ if err != nil {
93+ return err
94+ }
9195
9296 var buckets = make (map [float64 ]uint64 , len (seconds ))
9397 for i , second := range seconds {
9498 if i >= len (secondsBucket ) {
9599 break
96100 }
97- buckets [float64 (second )] = secondsBucket [i ]
98- }
99- if err != nil {
100- return err
101+ buckets [second ] = uint64 (secondsBucket [i ])
101102 }
102103
103104 applicationNameLabel := "unknown"
@@ -111,7 +112,7 @@ func (PGProcessIdleCollector) Update(ctx context.Context, inst *instance, ch cha
111112 }
112113 secondsSumMetric := 0.0
113114 if secondsSum .Valid {
114- secondsSumMetric = float64 ( secondsSum .Int64 )
115+ secondsSumMetric = secondsSum .Float64
115116 }
116117 ch <- prometheus .MustNewConstHistogram (
117118 pgProcessIdleSeconds ,
0 commit comments