Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions collector/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make it in sync with what's in README.

).Default("false").Bool()

scrapeDurationDesc = prometheus.NewDesc(
Expand Down Expand Up @@ -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)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual fix, pass value with * instead of address.


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, "&")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to drop logic dupe.


return &Exporter{
dsn: dsn,
Expand Down