-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add query tags. #331
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Alexey Palazhchenko <[email protected]>
@@ -144,6 +148,15 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) { | |||
} | |||
} | |||
|
|||
func queryTag(query, name string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be func tagQuery(query string, name string) string {
.
} | ||
|
||
parts := strings.Split(query, " ") | ||
return parts[0] + " /* mysqld_exporter:" + name + " */ " + strings.Join(parts[1:], " ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this:
p := strings.SplitN(query, " ", 2)
return fmt.Sprintf("%s /* mysqld_exporter:%s */ %s", p[0], name, p[1])
var logBin uint8 | ||
err := db.QueryRow(logbinQuery).Scan(&logBin) | ||
err := db.QueryRow(queryTag(`SELECT @@log_bin`, s.Name())).Scan(&logBin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep the const
definition of the query. This shouldn't cause any type problems.
tagQueries = kingpin.Flag( | ||
"exporter.tag-queries", | ||
"TODO", | ||
).Default("false").Bool() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a flag for this, let's just add the feature so it's always on. 😄
Refs #241.
@SuperQ PTAL. Before I went too far – does it looks good?