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

Add the option to ignore starting some of the timers #28

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

Conversation

rbarry82
Copy link

In case only some of the interval timers are desired, add an option to conditionally ignore starting some of them.

Closes #27

In case only some of the interval timers are desired, add an option
to conditionally ignore starting some of them.
@rbarry82
Copy link
Author

@csmarchbanks are you still maintaining this?

@csmarchbanks
Copy link
Contributor

Hi @rbarry82, I apologize for the slow response. I have had very little time to maintain this repo anymore, and there is a discussion going on to transfer it to prometheus-community: prometheus-community/community#39, depending on how that goes I will try to find some time to review this soon.

func IgnoredIntervals(s kingpin.Settings) (target map[string]bool) {
target = make(map[string]bool)
s.SetValue((ignoredIntervals)(target))
return
Copy link
Member

Choose a reason for hiding this comment

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

the function signature shows a return type of map[string]bool but it does not seem like we are returning anything?

@@ -70,8 +70,18 @@ func cycleValues(labelKeys []string, labelValues []string, seriesCount int, seri
}
}

func maybeStartTicker(interval int, dontStart bool) (*time.Ticker, error) {
Copy link
Member

Choose a reason for hiding this comment

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

in both cases if dontStart is true or false the return value for error is nil. Why even return an error if it can only ever be nil?

return nil
}

func (i ignoredIntervals) 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 unused function is just to allow ignoreIntervals to be used as an input to kingpin.Settings.SetValue?

metricTick := time.NewTicker(time.Duration(metricInterval) * time.Second)

valueTick, err := maybeStartTicker(valueInterval, ignoredIntervals["value"])
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

these nil checks become unnecessary if maybeStartTicker doesn't return an error

@@ -23,6 +44,7 @@ var (
valueInterval = kingpin.Flag("value-interval", "Change series values every {interval} seconds.").Default("30").Int()
labelInterval = kingpin.Flag("series-interval", "Change series_id label values every {interval} seconds.").Default("60").Int()
metricInterval = kingpin.Flag("metric-interval", "Change __name__ label values every {interval} seconds.").Default("120").Int()
ignoredTimers = IgnoredIntervals(kingpin.Flag("ignored-intervals", "Comma-separated list of intervals which should not be run"))
Copy link
Member

Choose a reason for hiding this comment

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

The flexibility of toggling specific intervals on/off is appreciated, but seems a little confusing how this should be used based on the help message. Thoughts on using a single bool flag to toggle both label and metric changing off? That seems more what the initial request in #27 is.

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.

add option to run avalanche without refreshing values (e.g. let intervals take a value of zero)
3 participants