-
Notifications
You must be signed in to change notification settings - Fork 548
feature: add MetricsUpdateIntervalSeconds args option in trimaran plugins #905
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ import ( | |
) | ||
|
||
const ( | ||
metricsUpdateIntervalSeconds = 30 | ||
defaultMetricsUpdateIntervalSeconds = 30 | ||
) | ||
|
||
// Collector : get data from load watcher, encapsulating the load watcher and its operations | ||
|
@@ -69,6 +69,11 @@ func NewCollector(logger klog.Logger, trimaranSpec *pluginConfig.TrimaranSpec) ( | |
client, _ = loadwatcherapi.NewLibraryClient(opts) | ||
} | ||
|
||
metricsUpdateIntervalSeconds := trimaranSpec.MetricsUpdateIntervalSeconds | ||
if metricsUpdateIntervalSeconds == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
metricsUpdateIntervalSeconds = defaultMetricsUpdateIntervalSeconds | ||
} | ||
|
||
collector := &Collector{ | ||
client: client, | ||
} | ||
|
@@ -80,7 +85,7 @@ func NewCollector(logger klog.Logger, trimaranSpec *pluginConfig.TrimaranSpec) ( | |
} | ||
// start periodic updates | ||
go func() { | ||
metricsUpdaterTicker := time.NewTicker(time.Second * metricsUpdateIntervalSeconds) | ||
metricsUpdaterTicker := time.NewTicker(time.Second * time.Duration(metricsUpdateIntervalSeconds)) | ||
for range metricsUpdaterTicker.C { | ||
err = collector.updateMetrics(logger) | ||
if err != nil { | ||
|
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.
usually optional values are pointers to let disambiguate between "value not set" and "value explicitely set to zero". In this case, does the zero value make sense? do we have the possible ambiguity? if not we can probably use the value (vs the pointer) but the API side will need more consideration.