Skip to content

Commit 3ec6941

Browse files
committed
feature: add MetricsUpdateIntervalSeconds args option in trimaran plugins
1 parent f071739 commit 3ec6941

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

apis/config/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ type TrimaranSpec struct {
8888
MetricProvider MetricProviderSpec
8989
// Address of load watcher service
9090
WatcherAddress string
91+
// Interval in seconds for periodic metrics updates. Default is 30 seconds if not set.
92+
MetricsUpdateIntervalSeconds int32
9193
}
9294

9395
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

apis/config/v1/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ type TrimaranSpec struct {
8888
MetricProvider MetricProviderSpec `json:"metricProvider,omitempty"`
8989
// Address of load watcher service
9090
WatcherAddress *string `json:"watcherAddress,omitempty"`
91+
// Interval in seconds for periodic metrics updates. Default is 30 seconds if not set.
92+
MetricsUpdateIntervalSeconds *int32 `json:"metricsUpdateIntervalSeconds,omitempty"`
9193
}
9294

9395
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

apis/config/v1/zz_generated.conversion.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/config/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/trimaran/collector.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
const (
33-
metricsUpdateIntervalSeconds = 30
33+
defaultMetricsUpdateIntervalSeconds = 30
3434
)
3535

3636
// 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) (
6969
client, _ = loadwatcherapi.NewLibraryClient(opts)
7070
}
7171

72+
metricsUpdateIntervalSeconds := trimaranSpec.MetricsUpdateIntervalSeconds
73+
if metricsUpdateIntervalSeconds == 0 {
74+
metricsUpdateIntervalSeconds = defaultMetricsUpdateIntervalSeconds
75+
}
76+
7277
collector := &Collector{
7378
client: client,
7479
}
@@ -80,7 +85,7 @@ func NewCollector(logger klog.Logger, trimaranSpec *pluginConfig.TrimaranSpec) (
8085
}
8186
// start periodic updates
8287
go func() {
83-
metricsUpdaterTicker := time.NewTicker(time.Second * metricsUpdateIntervalSeconds)
88+
metricsUpdaterTicker := time.NewTicker(time.Second * time.Duration(metricsUpdateIntervalSeconds))
8489
for range metricsUpdaterTicker.C {
8590
err = collector.updateMetrics(logger)
8691
if err != nil {

0 commit comments

Comments
 (0)