Skip to content

Commit

Permalink
Change logic for determining minimum polling frequency.
Browse files Browse the repository at this point in the history
Since polling is tied to housekeeping, minimum supported polling
frequency is 1s.

Users can specify polling frequency higher than 1s. The polling loop
will be called at the minimum frequency specified in config as long as
its higher than the minimum supported frequency.
  • Loading branch information
rjnagal committed Jul 20, 2015
1 parent f693397 commit df4d8b1
Showing 1 changed file with 12 additions and 9 deletions.
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
if minPollFrequency < minSupportedFrequency {
minPollFrequency = minSupportedFrequency
}

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

0 comments on commit df4d8b1

Please sign in to comment.