Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[WIP] Add query tags. #331

wants to merge 1 commit into from

Conversation

AlekSi
Copy link
Contributor

@AlekSi AlekSi commented Sep 5, 2018

Refs #241.

@SuperQ PTAL. Before I went too far – does it looks good?

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 {
Copy link
Member

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:], " ")
Copy link
Member

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)
Copy link
Member

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()
Copy link
Member

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. 😄

@ademidoff ademidoff deleted the tag-queries branch October 1, 2024 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants