Add a flag metrics-start-duration

This commit is contained in:
Nail Islamov 2018-11-28 12:13:07 +11:00
parent 3bd75f5c3a
commit 3f1b120eda
No known key found for this signature in database
GPG key ID: 36245154B2536826
3 changed files with 12 additions and 4 deletions

View file

@ -55,9 +55,10 @@ type prometheusProvider struct {
SeriesRegistry
}
func NewPrometheusProvider(mapper apimeta.RESTMapper, kubeClient dynamic.Interface, promClient prom.Client, namers []MetricNamer, updateInterval time.Duration) (provider.CustomMetricsProvider, Runnable) {
func NewPrometheusProvider(mapper apimeta.RESTMapper, kubeClient dynamic.Interface, promClient prom.Client, namers []MetricNamer, updateInterval time.Duration, maxAge time.Duration) (provider.CustomMetricsProvider, Runnable) {
lister := &cachingMetricsLister{
updateInterval: updateInterval,
maxAge: maxAge,
promClient: promClient,
namers: namers,
@ -191,6 +192,7 @@ type cachingMetricsLister struct {
promClient prom.Client
updateInterval time.Duration
maxAge time.Duration
namers []MetricNamer
}
@ -212,7 +214,7 @@ type selectorSeries struct {
}
func (l *cachingMetricsLister) updateMetrics() error {
startTime := pmodel.Now().Add(-1 * l.updateInterval)
startTime := pmodel.Now().Add(-1 * l.maxAge)
// don't do duplicate queries when it's just the matchers that change
seriesCacheByQuery := make(map[prom.Selector][]prom.Series)