Skip to content

Change logic for determining minimum polling frequency. #823

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

Merged
merged 1 commit into from
Jul 20, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions collector/generic_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,15 @@ func NewCollector(collectorName string, configfile string) (*GenericCollector, e
return nil, fmt.Errorf("No metrics provided in config")
}

minPollFrequency := configInJSON.MetricsConfig[0].PollingFrequency

//set minPollFrequency to housekeepingInterval if config returns minpollFrequency=0
if minPollFrequency == 0 {
minPollFrequency = 1 * time.Second
}

minPollFrequency := time.Duration(0)
regexprs := make([]*regexp.Regexp, len(configInJSON.MetricsConfig))

for ind, metricConfig := range configInJSON.MetricsConfig {
if metricConfig.PollingFrequency < minPollFrequency && metricConfig.PollingFrequency != 0 {
minPollFrequency = metricConfig.PollingFrequency
// Find the minimum specified polling frequency in metric config.
if metricConfig.PollingFrequency != 0 {
if minPollFrequency == 0 || metricConfig.PollingFrequency < minPollFrequency {
minPollFrequency = metricConfig.PollingFrequency
}
}

regexprs[ind], err = regexp.Compile(metricConfig.Regex)
Expand All @@ -85,6 +82,12 @@ func NewCollector(collectorName string, configfile string) (*GenericCollector, e
}
}

// Minimum supported polling frequency is 1s.
minSupportedFrequency := 1 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

In theory it should be the value of minHousekeeping flag :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, but importing HousekeepingInterval adds a cyclic dependency between manager and collector. I'll clean that up next.

if minPollFrequency < minSupportedFrequency {
minPollFrequency = minSupportedFrequency
}

return &GenericCollector{
name: collectorName,
configFile: configInJSON,
Expand Down