Better error message for debugging connection failures

This commit is contained in:
Jim Tilander 2017-02-14 23:01:46 -08:00 committed by Will Rouesnel
parent f5f7d836f5
commit 8ded56a7da

View File

@ -974,6 +974,10 @@ func getDB(conn string) (*sql.DB, error) {
if err != nil {
return nil, err
}
err = d.Ping()
if err != nil {
return nil, err
}
d.SetMaxOpenConns(1)
d.SetMaxIdleConns(1)
db = d
@ -992,7 +996,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
db, err := getDB(e.dsn)
if err != nil {
log.Infoln("Error opening connection to database:", err)
log.Infof("Error opening connection to database (%s): %s", e.dsn, err)
e.error.Set(1)
return
}