@@ -34,74 +34,74 @@ func NewPGStatBGWriterCollector(collectorConfig) (Collector, error) {
34
34
35
35
const bgWriterSubsystem = "stat_bgwriter"
36
36
37
- var statBGWriter = map [ string ] * prometheus. Desc {
38
- "checkpoints_timed" : prometheus .NewDesc (
37
+ var (
38
+ statBGWriterCheckpointsTimedDesc = prometheus .NewDesc (
39
39
prometheus .BuildFQName (namespace , bgWriterSubsystem , "checkpoints_timed_total" ),
40
40
"Number of scheduled checkpoints that have been performed" ,
41
41
[]string {},
42
42
prometheus.Labels {},
43
- ),
44
- "checkpoints_req" : prometheus .NewDesc (
43
+ )
44
+ statBGWriterCheckpointsReqDesc = prometheus .NewDesc (
45
45
prometheus .BuildFQName (namespace , bgWriterSubsystem , "checkpoints_req_total" ),
46
46
"Number of requested checkpoints that have been performed" ,
47
47
[]string {},
48
48
prometheus.Labels {},
49
- ),
50
- "checkpoint_write_time" : prometheus .NewDesc (
49
+ )
50
+ statBGWriterCheckpointsReqTimeDesc = prometheus .NewDesc (
51
51
prometheus .BuildFQName (namespace , bgWriterSubsystem , "checkpoint_write_time_total" ),
52
52
"Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds" ,
53
53
[]string {},
54
54
prometheus.Labels {},
55
- ),
56
- "checkpoint_sync_time" : prometheus .NewDesc (
55
+ )
56
+ statBGWriterCheckpointsSyncTimeDesc = prometheus .NewDesc (
57
57
prometheus .BuildFQName (namespace , bgWriterSubsystem , "checkpoint_sync_time_total" ),
58
58
"Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk, in milliseconds" ,
59
59
[]string {},
60
60
prometheus.Labels {},
61
- ),
62
- "buffers_checkpoint" : prometheus .NewDesc (
61
+ )
62
+ statBGWriterBuffersCheckpointDesc = prometheus .NewDesc (
63
63
prometheus .BuildFQName (namespace , bgWriterSubsystem , "buffers_checkpoint_total" ),
64
64
"Number of buffers written during checkpoints" ,
65
65
[]string {},
66
66
prometheus.Labels {},
67
- ),
68
- "buffers_clean" : prometheus .NewDesc (
67
+ )
68
+ statBGWriterBuffersCleanDesc = prometheus .NewDesc (
69
69
prometheus .BuildFQName (namespace , bgWriterSubsystem , "buffers_clean_total" ),
70
70
"Number of buffers written by the background writer" ,
71
71
[]string {},
72
72
prometheus.Labels {},
73
- ),
74
- "maxwritten_clean" : prometheus .NewDesc (
73
+ )
74
+ statBGWriterMaxwrittenCleanDesc = prometheus .NewDesc (
75
75
prometheus .BuildFQName (namespace , bgWriterSubsystem , "maxwritten_clean_total" ),
76
76
"Number of times the background writer stopped a cleaning scan because it had written too many buffers" ,
77
77
[]string {},
78
78
prometheus.Labels {},
79
- ),
80
- "buffers_backend" : prometheus .NewDesc (
79
+ )
80
+ statBGWriterBuffersBackendDesc = prometheus .NewDesc (
81
81
prometheus .BuildFQName (namespace , bgWriterSubsystem , "buffers_backend_total" ),
82
82
"Number of buffers written directly by a backend" ,
83
83
[]string {},
84
84
prometheus.Labels {},
85
- ),
86
- "buffers_backend_fsync" : prometheus .NewDesc (
85
+ )
86
+ statBGWriterBuffersBackendFsyncDesc = prometheus .NewDesc (
87
87
prometheus .BuildFQName (namespace , bgWriterSubsystem , "buffers_backend_fsync_total" ),
88
88
"Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write)" ,
89
89
[]string {},
90
90
prometheus.Labels {},
91
- ),
92
- "buffers_alloc" : prometheus .NewDesc (
91
+ )
92
+ statBGWriterBuffersAllocDesc = prometheus .NewDesc (
93
93
prometheus .BuildFQName (namespace , bgWriterSubsystem , "buffers_alloc_total" ),
94
94
"Number of buffers allocated" ,
95
95
[]string {},
96
96
prometheus.Labels {},
97
- ),
98
- "stats_reset" : prometheus .NewDesc (
97
+ )
98
+ statBGWriterStatsResetDesc = prometheus .NewDesc (
99
99
prometheus .BuildFQName (namespace , bgWriterSubsystem , "stats_reset_total" ),
100
100
"Time at which these statistics were last reset" ,
101
101
[]string {},
102
102
prometheus.Labels {},
103
- ),
104
- }
103
+ )
104
+ )
105
105
106
106
func (PGStatBGWriterCollector ) Update (ctx context.Context , db * sql.DB , ch chan <- prometheus.Metric ) error {
107
107
row := db .QueryRowContext (ctx ,
@@ -137,57 +137,57 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, db *sql.DB, ch chan<-
137
137
}
138
138
139
139
ch <- prometheus .MustNewConstMetric (
140
- statBGWriter [ "checkpoints_timed" ] ,
140
+ statBGWriterCheckpointsTimedDesc ,
141
141
prometheus .CounterValue ,
142
142
float64 (cpt ),
143
143
)
144
144
ch <- prometheus .MustNewConstMetric (
145
- statBGWriter [ "checkpoints_req" ] ,
145
+ statBGWriterCheckpointsReqDesc ,
146
146
prometheus .CounterValue ,
147
147
float64 (cpr ),
148
148
)
149
149
ch <- prometheus .MustNewConstMetric (
150
- statBGWriter [ "checkpoint_write_time" ] ,
150
+ statBGWriterCheckpointsReqTimeDesc ,
151
151
prometheus .CounterValue ,
152
152
float64 (cpwt ),
153
153
)
154
154
ch <- prometheus .MustNewConstMetric (
155
- statBGWriter [ "checkpoint_sync_time" ] ,
155
+ statBGWriterCheckpointsSyncTimeDesc ,
156
156
prometheus .CounterValue ,
157
157
float64 (cpst ),
158
158
)
159
159
ch <- prometheus .MustNewConstMetric (
160
- statBGWriter [ "buffers_checkpoint" ] ,
160
+ statBGWriterBuffersCheckpointDesc ,
161
161
prometheus .CounterValue ,
162
162
float64 (bcp ),
163
163
)
164
164
ch <- prometheus .MustNewConstMetric (
165
- statBGWriter [ "buffers_clean" ] ,
165
+ statBGWriterBuffersCleanDesc ,
166
166
prometheus .CounterValue ,
167
167
float64 (bc ),
168
168
)
169
169
ch <- prometheus .MustNewConstMetric (
170
- statBGWriter [ "maxwritten_clean" ] ,
170
+ statBGWriterMaxwrittenCleanDesc ,
171
171
prometheus .CounterValue ,
172
172
float64 (mwc ),
173
173
)
174
174
ch <- prometheus .MustNewConstMetric (
175
- statBGWriter [ "buffers_backend" ] ,
175
+ statBGWriterBuffersBackendDesc ,
176
176
prometheus .CounterValue ,
177
177
float64 (bb ),
178
178
)
179
179
ch <- prometheus .MustNewConstMetric (
180
- statBGWriter [ "buffers_backend_fsync" ] ,
180
+ statBGWriterBuffersBackendFsyncDesc ,
181
181
prometheus .CounterValue ,
182
182
float64 (bbf ),
183
183
)
184
184
ch <- prometheus .MustNewConstMetric (
185
- statBGWriter [ "buffers_alloc" ] ,
185
+ statBGWriterBuffersAllocDesc ,
186
186
prometheus .CounterValue ,
187
187
float64 (ba ),
188
188
)
189
189
ch <- prometheus .MustNewConstMetric (
190
- statBGWriter [ "stats_reset" ] ,
190
+ statBGWriterStatsResetDesc ,
191
191
prometheus .CounterValue ,
192
192
float64 (sr .Unix ()),
193
193
)
0 commit comments