-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
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() |
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.
Why not uint? This also needs a gofmt.
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 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 { |
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.
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() |
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.
history.limit
@brian-brazil Any other changes you want to see? |
Thanks! |
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.