mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 17:57:51 +00:00
Merge 44d755ae38 into af9f11c817
This commit is contained in:
commit
2a77bfb1f9
2 changed files with 9 additions and 2 deletions
|
|
@ -334,7 +334,7 @@ func (n *metricNamer) makeLabelForResource(resource schema.GroupResource) (pmode
|
||||||
|
|
||||||
singularRes, err := n.mapper.ResourceSingularizer(resource.Resource)
|
singularRes, err := n.mapper.ResourceSingularizer(resource.Resource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("unable to singularize resource %s: %v", resource.String, err)
|
return "", fmt.Errorf("unable to singularize resource %s: %v", resource.String(), err)
|
||||||
}
|
}
|
||||||
convResource := schema.GroupResource{
|
convResource := schema.GroupResource{
|
||||||
Group: groupNameSanitizer.Replace(resource.Group),
|
Group: groupNameSanitizer.Replace(resource.Group),
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,11 @@ package provider
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/glog"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
|
|
||||||
"github.com/kubernetes-incubator/custom-metrics-apiserver/pkg/provider"
|
"github.com/kubernetes-incubator/custom-metrics-apiserver/pkg/provider"
|
||||||
pmodel "github.com/prometheus/common/model"
|
pmodel "github.com/prometheus/common/model"
|
||||||
apierr "k8s.io/apimachinery/pkg/api/errors"
|
apierr "k8s.io/apimachinery/pkg/api/errors"
|
||||||
|
|
@ -287,6 +289,7 @@ func (l *cachingMetricsLister) updateMetrics() error {
|
||||||
|
|
||||||
// don't do duplicate queries when it's just the matchers that change
|
// don't do duplicate queries when it's just the matchers that change
|
||||||
seriesCacheByQuery := make(map[prom.Selector][]prom.Series)
|
seriesCacheByQuery := make(map[prom.Selector][]prom.Series)
|
||||||
|
seriesCacheByQueryLock := sync.RWMutex{}
|
||||||
|
|
||||||
// these can take a while on large clusters, so launch in parallel
|
// these can take a while on large clusters, so launch in parallel
|
||||||
// and don't duplicate
|
// and don't duplicate
|
||||||
|
|
@ -298,7 +301,9 @@ func (l *cachingMetricsLister) updateMetrics() error {
|
||||||
errs <- nil
|
errs <- nil
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
seriesCacheByQueryLock.Lock()
|
||||||
selectors[sel] = struct{}{}
|
selectors[sel] = struct{}{}
|
||||||
|
seriesCacheByQueryLock.Unlock()
|
||||||
go func() {
|
go func() {
|
||||||
series, err := l.promClient.Series(context.TODO(), pmodel.Interval{startTime, 0}, sel)
|
series, err := l.promClient.Series(context.TODO(), pmodel.Interval{startTime, 0}, sel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -306,7 +311,9 @@ func (l *cachingMetricsLister) updateMetrics() error {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
errs <- nil
|
errs <- nil
|
||||||
|
seriesCacheByQueryLock.Lock()
|
||||||
seriesCacheByQuery[sel] = series
|
seriesCacheByQuery[sel] = series
|
||||||
|
seriesCacheByQueryLock.Unlock()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue