diff --git a/collector/exporter.go b/collector/exporter.go index f56d799b8..565115866 100644 --- a/collector/exporter.go +++ b/collector/exporter.go @@ -32,11 +32,11 @@ const ( var ( exporterLockTimeout = kingpin.Flag( "exporter.lock_wait_timeout", - "Set the MySQL session lock_wait_timeout to avoid stuck metadata locks", + "Set a lock_wait_timeout on the connection to avoid long metadata locking.", ).Default("2").Int() slowLogFilter = kingpin.Flag( "exporter.log_slow_filter", - "Add a log_slow_filter to avoid exessive MySQL slow logging. NOTE: Not supported by Oracle MySQL.", + "Add a log_slow_filter to avoid slow query logging of scrapes. NOTE: Not supported by Oracle MySQL.", ).Default("false").Bool() scrapeDurationDesc = prometheus.NewDesc( @@ -88,17 +88,18 @@ type Exporter struct { // New returns a new MySQL exporter for the provided DSN. func New(dsn string, collect Collect) *Exporter { // Setup extra params for the DSN, default to having a lock timeout. - dsnParams := []string{fmt.Sprintf(timeoutParam, exporterLockTimeout)} + dsnParams := []string{fmt.Sprintf(timeoutParam, *exporterLockTimeout)} if *slowLogFilter { dsnParams = append(dsnParams, sessionSettingsParam) } if strings.Contains(dsn, "?") { - dsn = dsn + "&" + strings.Join(dsnParams, "&") + dsn = dsn + "&" } else { - dsn = dsn + "?" + strings.Join(dsnParams, "&") + dsn = dsn + "?" } + dsn += strings.Join(dsnParams, "&") return &Exporter{ dsn: dsn,