Skip to content

Commit 09a9980

Browse files
committed
update to use common/log
1 parent 9cdd620 commit 09a9980

File tree

11 files changed

+465
-230
lines changed

11 files changed

+465
-230
lines changed

postgres_exporter.go

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
package main
22

33
import (
4-
//"bytes"
54
"database/sql"
65
"flag"
76
"fmt"
7+
"math"
88
"net/http"
99
"os"
10-
//"regexp"
11-
//"strconv"
12-
//"strings"
13-
"math"
1410
"time"
1511

12+
"strconv"
13+
1614
_ "github.com/lib/pq"
1715
"github.com/prometheus/client_golang/prometheus"
18-
"github.com/prometheus/log"
19-
"strconv"
16+
"github.com/prometheus/common/log"
2017
)
2118

2219
var Version string = "0.0.1"
@@ -330,7 +327,7 @@ func dbToFloat64(t interface{}) (float64, bool) {
330327
case string:
331328
result, err := strconv.ParseFloat(v, 64)
332329
if err != nil {
333-
log.Println("Could not parse string:", err)
330+
log.Infoln("Could not parse string:", err)
334331
return math.NaN(), false
335332
}
336333
return result, true
@@ -452,7 +449,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
452449

453450
db, err := sql.Open("postgres", e.dsn)
454451
if err != nil {
455-
log.Println("Error opening connection to database:", err)
452+
log.Infoln("Error opening connection to database:", err)
456453
e.error.Set(1)
457454
return
458455
}
@@ -498,7 +495,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
498495
// Don't fail on a bad scrape of one metric
499496
rows, err := db.Query(query)
500497
if err != nil {
501-
log.Println("Error running query on database: ", namespace, err)
498+
log.Infoln("Error running query on database: ", namespace, err)
502499
e.error.Set(1)
503500
return
504501
}
@@ -507,7 +504,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
507504
var columnNames []string
508505
columnNames, err = rows.Columns()
509506
if err != nil {
510-
log.Println("Error retrieving column list for: ", namespace, err)
507+
log.Infoln("Error retrieving column list for: ", namespace, err)
511508
e.error.Set(1)
512509
return
513510
}
@@ -527,7 +524,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
527524
for rows.Next() {
528525
err = rows.Scan(scanArgs...)
529526
if err != nil {
530-
log.Println("Error retrieving rows:", namespace, err)
527+
log.Infoln("Error retrieving rows:", namespace, err)
531528
e.error.Set(1)
532529
return
533530
}

vendor/github.com/prometheus/common/NOTICE

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)