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

Make the history limit a configurable flag #308

Merged
merged 1 commit into from
Apr 13, 2018
Merged

Make the history limit a configurable flag #308

merged 1 commit into from
Apr 13, 2018

Conversation

sgmitchell
Copy link
Contributor

This change replaces the hardcoded limit on the number of elements stored in the log history with a configurable value that can be set as a runtime argument. The the old value of 100 elements will be use by default either when the argument is left off or the argument is out of range (less than 1).

The driving use case for this is when there are over 100 endpoints queried, some of them will be removed almost immediately from the logs.

main.go Outdated
@@ -50,6 +50,7 @@ var (
listenAddress = kingpin.Flag("web.listen-address", "The address to listen on for HTTP requests.").Default(":9115").String()
timeoutOffset = kingpin.Flag("timeout-offset", "Offset to subtract from timeout in seconds.").Default("0.5").Float64()
configCheck = kingpin.Flag("config.check", "If true validate the config file and then exit.").Default().Bool()
historyLimit = kingpin.Flag("historyLimit", "The maximum amount of items to keep in the history.").Default("100").Int()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not uint? This also needs a gofmt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with int because I thought it looked cleaner to avoid the having a cast on history.go:54 and negative values will be set to 100 by history.go:40. I have no problem changing it though.

Formatting issue was because I tried to use the github merge ui. Will fix with the uint commit.

history.go Outdated
}

// Add a result to the history.
func (rh *resultHistory) Add(moduleName, target, debugOutput string, success bool) {
rh.mu.Lock()
defer rh.mu.Unlock()

if rh.maxResults < 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this now.

main.go Outdated
@@ -50,6 +50,7 @@ var (
listenAddress = kingpin.Flag("web.listen-address", "The address to listen on for HTTP requests.").Default(":9115").String()
timeoutOffset = kingpin.Flag("timeout-offset", "Offset to subtract from timeout in seconds.").Default("0.5").Float64()
configCheck = kingpin.Flag("config.check", "If true validate the config file and then exit.").Default().Bool()
historyLimit = kingpin.Flag("historyLimit", "The maximum amount of items to keep in the history.").Default("100").Uint()
Copy link
Contributor

Choose a reason for hiding this comment

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

history.limit

@sgmitchell
Copy link
Contributor Author

@brian-brazil Any other changes you want to see?

@brian-brazil brian-brazil merged commit 0007554 into prometheus:master Apr 13, 2018
@brian-brazil
Copy link
Contributor

Thanks!

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