Skip to content

Commit 91b00aa

Browse files
committed
More logger fixing
1 parent a1e0056 commit 91b00aa

File tree

7 files changed

+40
-40
lines changed

7 files changed

+40
-40
lines changed

cmd/postgres_exporter/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func main() {
160160
}
161161
landingPage, err := web.NewLandingPage(landingConfig)
162162
if err != nil {
163-
logger.Error("err", err)
163+
logger.Error("error intitializing landingpage", "err", err)
164164
os.Exit(1)
165165
}
166166
http.Handle("/", landingPage)

cmd/postgres_exporter/namespace.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,12 @@ func queryNamespaceMappings(ch chan<- prometheus.Metric, server *Server) map[str
232232
// Serious error - a namespace disappeared
233233
if err != nil {
234234
namespaceErrors[namespace] = err
235-
logger.Info("err", err)
235+
logger.Info("missing namespace when querying", "err", err)
236236
}
237237
// Non-serious errors - likely version or parsing problems.
238238
if len(nonFatalErrors) > 0 {
239239
for _, err := range nonFatalErrors {
240-
logger.Info("err", err)
240+
logger.Info("issue querying namespaces", "err", err)
241241
}
242242
}
243243

cmd/postgres_exporter/postgres_exporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
678678
if err := e.scrapeDSN(ch, dsn); err != nil {
679679
errorsCount++
680680

681-
logger.Error("err", err)
681+
logger.Error("error scraping DSN", "err", err)
682682

683683
if _, ok := err.(*ErrorConnectToServer); ok {
684684
connectionErrorsCount++

collector/pg_database_wraparound.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ func (c *PGDatabaseWraparoundCollector) Update(ctx context.Context, instance *in
8080
}
8181

8282
if !datname.Valid {
83-
c.log.Debug("msg", "Skipping database with NULL name")
83+
c.log.Debug("Skipping database with NULL name")
8484
continue
8585
}
8686
if !ageDatfrozenxid.Valid {
87-
c.log.Debug("msg", "Skipping stat emission with NULL age_datfrozenxid")
87+
c.log.Debug("Skipping stat emission with NULL age_datfrozenxid")
8888
continue
8989
}
9090
if !ageDatminmxid.Valid {
91-
c.log.Debug("msg", "Skipping stat emission with NULL age_datminmxid")
91+
c.log.Debug("Skipping stat emission with NULL age_datminmxid")
9292
continue
9393
}
9494

collector/pg_stat_database.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -298,85 +298,85 @@ func (c *PGStatDatabaseCollector) Update(ctx context.Context, instance *instance
298298
}
299299

300300
if !datid.Valid {
301-
c.log.Debug("msg", "Skipping collecting metric because it has no datid")
301+
c.log.Debug("Skipping collecting metric because it has no datid")
302302
continue
303303
}
304304
if !datname.Valid {
305-
c.log.Debug("msg", "Skipping collecting metric because it has no datname")
305+
c.log.Debug("Skipping collecting metric because it has no datname")
306306
continue
307307
}
308308
if !numBackends.Valid {
309-
c.log.Debug("msg", "Skipping collecting metric because it has no numbackends")
309+
c.log.Debug("Skipping collecting metric because it has no numbackends")
310310
continue
311311
}
312312
if !xactCommit.Valid {
313-
c.log.Debug("msg", "Skipping collecting metric because it has no xact_commit")
313+
c.log.Debug("Skipping collecting metric because it has no xact_commit")
314314
continue
315315
}
316316
if !xactRollback.Valid {
317-
c.log.Debug("msg", "Skipping collecting metric because it has no xact_rollback")
317+
c.log.Debug("Skipping collecting metric because it has no xact_rollback")
318318
continue
319319
}
320320
if !blksRead.Valid {
321-
c.log.Debug("msg", "Skipping collecting metric because it has no blks_read")
321+
c.log.Debug("Skipping collecting metric because it has no blks_read")
322322
continue
323323
}
324324
if !blksHit.Valid {
325-
c.log.Debug("msg", "Skipping collecting metric because it has no blks_hit")
325+
c.log.Debug("Skipping collecting metric because it has no blks_hit")
326326
continue
327327
}
328328
if !tupReturned.Valid {
329-
c.log.Debug("msg", "Skipping collecting metric because it has no tup_returned")
329+
c.log.Debug("Skipping collecting metric because it has no tup_returned")
330330
continue
331331
}
332332
if !tupFetched.Valid {
333-
c.log.Debug("msg", "Skipping collecting metric because it has no tup_fetched")
333+
c.log.Debug("Skipping collecting metric because it has no tup_fetched")
334334
continue
335335
}
336336
if !tupInserted.Valid {
337-
c.log.Debug("msg", "Skipping collecting metric because it has no tup_inserted")
337+
c.log.Debug("Skipping collecting metric because it has no tup_inserted")
338338
continue
339339
}
340340
if !tupUpdated.Valid {
341-
c.log.Debug("msg", "Skipping collecting metric because it has no tup_updated")
341+
c.log.Debug("Skipping collecting metric because it has no tup_updated")
342342
continue
343343
}
344344
if !tupDeleted.Valid {
345-
c.log.Debug("msg", "Skipping collecting metric because it has no tup_deleted")
345+
c.log.Debug("Skipping collecting metric because it has no tup_deleted")
346346
continue
347347
}
348348
if !conflicts.Valid {
349-
c.log.Debug("msg", "Skipping collecting metric because it has no conflicts")
349+
c.log.Debug("Skipping collecting metric because it has no conflicts")
350350
continue
351351
}
352352
if !tempFiles.Valid {
353-
c.log.Debug("msg", "Skipping collecting metric because it has no temp_files")
353+
c.log.Debug("Skipping collecting metric because it has no temp_files")
354354
continue
355355
}
356356
if !tempBytes.Valid {
357-
c.log.Debug("msg", "Skipping collecting metric because it has no temp_bytes")
357+
c.log.Debug("Skipping collecting metric because it has no temp_bytes")
358358
continue
359359
}
360360
if !deadlocks.Valid {
361-
c.log.Debug("msg", "Skipping collecting metric because it has no deadlocks")
361+
c.log.Debug("Skipping collecting metric because it has no deadlocks")
362362
continue
363363
}
364364
if !blkReadTime.Valid {
365-
c.log.Debug("msg", "Skipping collecting metric because it has no blk_read_time")
365+
c.log.Debug("Skipping collecting metric because it has no blk_read_time")
366366
continue
367367
}
368368
if !blkWriteTime.Valid {
369-
c.log.Debug("msg", "Skipping collecting metric because it has no blk_write_time")
369+
c.log.Debug("Skipping collecting metric because it has no blk_write_time")
370370
continue
371371
}
372372
if activeTimeAvail && !activeTime.Valid {
373-
c.log.Debug("msg", "Skipping collecting metric because it has no active_time")
373+
c.log.Debug("Skipping collecting metric because it has no active_time")
374374
continue
375375
}
376376

377377
statsResetMetric := 0.0
378378
if !statsReset.Valid {
379-
c.log.Debug("msg", "No metric for stats_reset, will collect 0 instead")
379+
c.log.Debug("No metric for stats_reset, will collect 0 instead")
380380
}
381381
if statsReset.Valid {
382382
statsResetMetric = float64(statsReset.Time.Unix())

collector/pg_stat_walreceiver.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,55 +156,55 @@ func (c *PGStatWalReceiverCollector) Update(ctx context.Context, instance *insta
156156
}
157157
}
158158
if !upstreamHost.Valid {
159-
c.log.Debug("msg", "Skipping wal receiver stats because upstream host is null")
159+
c.log.Debug("Skipping wal receiver stats because upstream host is null")
160160
continue
161161
}
162162

163163
if !slotName.Valid {
164-
c.log.Debug("msg", "Skipping wal receiver stats because slotname host is null")
164+
c.log.Debug("Skipping wal receiver stats because slotname host is null")
165165
continue
166166
}
167167

168168
if !status.Valid {
169-
c.log.Debug("msg", "Skipping wal receiver stats because status is null")
169+
c.log.Debug("Skipping wal receiver stats because status is null")
170170
continue
171171
}
172172
labels := []string{upstreamHost.String, slotName.String, status.String}
173173

174174
if !receiveStartLsn.Valid {
175-
c.log.Debug("msg", "Skipping wal receiver stats because receive_start_lsn is null")
175+
c.log.Debug("Skipping wal receiver stats because receive_start_lsn is null")
176176
continue
177177
}
178178
if !receiveStartTli.Valid {
179-
c.log.Debug("msg", "Skipping wal receiver stats because receive_start_tli is null")
179+
c.log.Debug("Skipping wal receiver stats because receive_start_tli is null")
180180
continue
181181
}
182182
if hasFlushedLSN && !flushedLsn.Valid {
183-
c.log.Debug("msg", "Skipping wal receiver stats because flushed_lsn is null")
183+
c.log.Debug("Skipping wal receiver stats because flushed_lsn is null")
184184
continue
185185
}
186186
if !receivedTli.Valid {
187-
c.log.Debug("msg", "Skipping wal receiver stats because received_tli is null")
187+
c.log.Debug("Skipping wal receiver stats because received_tli is null")
188188
continue
189189
}
190190
if !lastMsgSendTime.Valid {
191-
c.log.Debug("msg", "Skipping wal receiver stats because last_msg_send_time is null")
191+
c.log.Debug("Skipping wal receiver stats because last_msg_send_time is null")
192192
continue
193193
}
194194
if !lastMsgReceiptTime.Valid {
195-
c.log.Debug("msg", "Skipping wal receiver stats because last_msg_receipt_time is null")
195+
c.log.Debug("Skipping wal receiver stats because last_msg_receipt_time is null")
196196
continue
197197
}
198198
if !latestEndLsn.Valid {
199-
c.log.Debug("msg", "Skipping wal receiver stats because latest_end_lsn is null")
199+
c.log.Debug("Skipping wal receiver stats because latest_end_lsn is null")
200200
continue
201201
}
202202
if !latestEndTime.Valid {
203-
c.log.Debug("msg", "Skipping wal receiver stats because latest_end_time is null")
203+
c.log.Debug("Skipping wal receiver stats because latest_end_time is null")
204204
continue
205205
}
206206
if !upstreamNode.Valid {
207-
c.log.Debug("msg", "Skipping wal receiver stats because upstream_node is null")
207+
c.log.Debug("Skipping wal receiver stats because upstream_node is null")
208208
continue
209209
}
210210
ch <- prometheus.MustNewConstMetric(

collector/pg_xlog_location.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (c PGXlogLocationCollector) Update(ctx context.Context, instance *instance,
5858
// https://wiki.postgresql.org/wiki/New_in_postgres_10#Renaming_of_.22xlog.22_to_.22wal.22_Globally_.28and_location.2Flsn.29
5959
after10 := instance.version.Compare(semver.MustParse("10.0.0"))
6060
if after10 >= 0 {
61-
c.log.Warn("msg", "xlog_location collector is not available on PostgreSQL >= 10.0.0, skipping")
61+
c.log.Warn("xlog_location collector is not available on PostgreSQL >= 10.0.0, skipping")
6262
return nil
6363
}
6464

0 commit comments

Comments
 (0)