Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Commit a9effb8

Browse files
committed
fix jobs channel size
new unit - 'B'
1 parent 52972a6 commit a9effb8

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

configs/pgsettings.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pg_settings:
44
select
55
replace(case
66
when unit in ('ms', 's', 'min', 'h', 'd') then name || '_seconds'
7-
when unit in ('kB', 'MB', 'GB', 'TB', '8kB', '16kB', '32kB', '16MB', '32MB', '64MB') then name || '_bytes'
7+
when unit in ('B', 'kB', 'MB', 'GB', 'TB', '8kB', '16kB', '32kB', '16MB', '32MB', '64MB') then name || '_bytes'
88
else
99
name
1010
end, '.', '_') as name,
@@ -15,6 +15,7 @@ pg_settings:
1515
when 'h' then setting::numeric * 3600
1616
when 'd' then setting::numeric * 86400
1717
18+
when 'B' then setting::numeric
1819
when 'kB' then setting::numeric * 1024
1920
when 'MB' then setting::numeric * 1048576
2021
when 'GB' then setting::numeric * 1073741824
@@ -38,7 +39,7 @@ pg_settings:
3839
select
3940
replace(case
4041
when unit in ('ms', 's', 'min', 'h', 'd') then name || '_seconds'
41-
when unit in ('kB', 'MB', 'GB', 'TB', '8kB', '16kB', '32kB', '16MB', '32MB', '64MB') then name || '_bytes'
42+
when unit in ('B', 'kB', 'MB', 'GB', 'TB', '8kB', '16kB', '32kB', '16MB', '32MB', '64MB') then name || '_bytes'
4243
else
4344
name
4445
end, '.', '_') as name,
@@ -49,6 +50,7 @@ pg_settings:
4950
when 'h' then setting::numeric * 3600
5051
when 'd' then setting::numeric * 86400
5152
53+
when 'B' then setting::numeric
5254
when 'kB' then setting::numeric * 1024
5355
when 'MB' then setting::numeric * 1048576
5456
when 'GB' then setting::numeric * 1073741824

pkg/db/db.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ func ToFloat64(t interface{}) (float64, error) {
162162
var res float64
163163
switch v := t.(type) {
164164
case *pgtype.Numeric:
165-
v.AssignTo(&res)
166-
return res, nil
165+
err := v.AssignTo(&res)
166+
return res, err
167167
case int8:
168168
return float64(v), nil
169169
case int32:

pkg/pgcollector/pgcollector.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ func createMetric(job *workerJob, name string, constLabels prometheus.Labels, ra
8585
}
8686

8787
func (p *PgCollector) worker(conn db.DbInterface, jobs chan *workerJob, res chan<- prometheus.Metric, wg *sync.WaitGroup) {
88-
defer func() {
89-
wg.Done()
90-
}()
88+
defer wg.Done()
9189

9290
jobs:
9391
for job := range jobs {
@@ -231,7 +229,7 @@ func (p *PgCollector) Collect(metricsCh chan<- prometheus.Metric) {
231229

232230
dbPool[dbName] = append(dbPool[dbName], conn)
233231
}
234-
dbJobs[dbName] = make(chan *workerJob, len(dbPool))
232+
dbJobs[dbName] = make(chan *workerJob, len(dbPool[dbName]))
235233

236234
for _, conn := range dbPool[dbName] {
237235
wg.Add(1)

0 commit comments

Comments
 (0)