Skip to content

Commit 7297390

Browse files
committed
Use native DB.Ping() instead of self-written implementation.
1 parent 4d7577b commit 7297390

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

collector/exporter.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ const (
2525
// See: https://github.com/go-sql-driver/mysql#system-variables
2626
sessionSettingsParam = `log_slow_filter=%27tmp_table_on_disk,filesort_on_disk%27`
2727
timeoutParam = `lock_wait_timeout=%d`
28-
29-
upQuery = `SELECT 1`
3028
)
3129

3230
// Tunable flags.
@@ -117,14 +115,12 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
117115
// Set max lifetime for a connection.
118116
db.SetConnMaxLifetime(1 * time.Minute)
119117

120-
isUpRows, err := db.Query(upQuery)
121-
if err != nil {
118+
if err := db.Ping(); err != nil {
122119
log.Errorln("Error pinging mysqld:", err)
123120
e.metrics.MySQLUp.Set(0)
124121
e.metrics.Error.Set(1)
125122
return
126123
}
127-
isUpRows.Close()
128124

129125
e.metrics.MySQLUp.Set(1)
130126

0 commit comments

Comments
 (0)