mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-05 17:27:51 +00:00
Fixing dependency in custom-provider
This commit is contained in:
parent
ed9eb31b3a
commit
8ef8c8a291
7 changed files with 27 additions and 22 deletions
|
|
@ -37,6 +37,7 @@ import (
|
|||
"k8s.io/metrics/pkg/apis/custom_metrics"
|
||||
|
||||
prom "github.com/directxman12/k8s-prometheus-adapter/pkg/client"
|
||||
"github.com/directxman12/k8s-prometheus-adapter/pkg/naming"
|
||||
)
|
||||
|
||||
// Runnable represents something that can be run until told to stop.
|
||||
|
|
@ -55,7 +56,7 @@ type prometheusProvider struct {
|
|||
SeriesRegistry
|
||||
}
|
||||
|
||||
func NewPrometheusProvider(mapper apimeta.RESTMapper, kubeClient dynamic.Interface, promClient prom.Client, namers []MetricNamer, updateInterval time.Duration, maxAge time.Duration) (provider.CustomMetricsProvider, Runnable) {
|
||||
func NewPrometheusProvider(mapper apimeta.RESTMapper, kubeClient dynamic.Interface, promClient prom.Client, namers []naming.MetricNamer, updateInterval time.Duration, maxAge time.Duration) (provider.CustomMetricsProvider, Runnable) {
|
||||
lister := &cachingMetricsLister{
|
||||
updateInterval: updateInterval,
|
||||
maxAge: maxAge,
|
||||
|
|
@ -193,7 +194,7 @@ type cachingMetricsLister struct {
|
|||
promClient prom.Client
|
||||
updateInterval time.Duration
|
||||
maxAge time.Duration
|
||||
namers []MetricNamer
|
||||
namers []naming.MetricNamer
|
||||
}
|
||||
|
||||
func (l *cachingMetricsLister) Run() {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import (
|
|||
config "github.com/directxman12/k8s-prometheus-adapter/cmd/config-gen/utils"
|
||||
prom "github.com/directxman12/k8s-prometheus-adapter/pkg/client"
|
||||
fakeprom "github.com/directxman12/k8s-prometheus-adapter/pkg/client/fake"
|
||||
"github.com/directxman12/k8s-prometheus-adapter/pkg/naming"
|
||||
pmodel "github.com/prometheus/common/model"
|
||||
)
|
||||
|
||||
|
|
@ -39,7 +40,7 @@ func setupPrometheusProvider() (provider.CustomMetricsProvider, *fakeprom.FakePr
|
|||
fakeKubeClient := &fakedyn.FakeDynamicClient{}
|
||||
|
||||
cfg := config.DefaultConfig(1*time.Minute, "")
|
||||
namers, err := NamersFromConfig(cfg, restMapper())
|
||||
namers, err := naming.NamersFromConfig(cfg, restMapper())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
prov, _ := NewPrometheusProvider(restMapper(), fakeKubeClient, fakeProm, namers, fakeProviderUpdateInterval, fakeProviderStartDuration)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import (
|
|||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
|
||||
prom "github.com/directxman12/k8s-prometheus-adapter/pkg/client"
|
||||
"github.com/directxman12/k8s-prometheus-adapter/pkg/naming"
|
||||
"github.com/golang/glog"
|
||||
pmodel "github.com/prometheus/common/model"
|
||||
)
|
||||
|
|
@ -45,7 +46,7 @@ const (
|
|||
type SeriesRegistry interface {
|
||||
// SetSeries replaces the known series in this registry.
|
||||
// Each slice in series should correspond to a MetricNamer in namers.
|
||||
SetSeries(series [][]prom.Series, namers []MetricNamer) error
|
||||
SetSeries(series [][]prom.Series, namers []naming.MetricNamer) error
|
||||
// ListAllMetrics lists all metrics known to this registry
|
||||
ListAllMetrics() []provider.CustomMetricInfo
|
||||
// SeriesForMetric looks up the minimum required series information to make a query for the given metric
|
||||
|
|
@ -60,7 +61,7 @@ type seriesInfo struct {
|
|||
seriesName string
|
||||
|
||||
// namer is the MetricNamer used to name this series
|
||||
namer MetricNamer
|
||||
namer naming.MetricNamer
|
||||
}
|
||||
|
||||
// overridableSeriesRegistry is a basic SeriesRegistry
|
||||
|
|
@ -75,7 +76,7 @@ type basicSeriesRegistry struct {
|
|||
mapper apimeta.RESTMapper
|
||||
}
|
||||
|
||||
func (r *basicSeriesRegistry) SetSeries(newSeriesSlices [][]prom.Series, namers []MetricNamer) error {
|
||||
func (r *basicSeriesRegistry) SetSeries(newSeriesSlices [][]prom.Series, namers []naming.MetricNamer) error {
|
||||
if len(newSeriesSlices) != len(namers) {
|
||||
return fmt.Errorf("need one set of series per namer")
|
||||
}
|
||||
|
|
@ -99,7 +100,7 @@ func (r *basicSeriesRegistry) SetSeries(newSeriesSlices [][]prom.Series, namers
|
|||
}
|
||||
|
||||
// namespace metrics aren't counted as namespaced
|
||||
if resource == nsGroupResource {
|
||||
if resource == naming.NsGroupResource {
|
||||
info.Namespaced = false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import (
|
|||
|
||||
config "github.com/directxman12/k8s-prometheus-adapter/cmd/config-gen/utils"
|
||||
prom "github.com/directxman12/k8s-prometheus-adapter/pkg/client"
|
||||
"github.com/directxman12/k8s-prometheus-adapter/pkg/naming"
|
||||
)
|
||||
|
||||
// restMapper creates a RESTMapper with just the types we need for
|
||||
|
|
@ -50,9 +51,9 @@ func restMapper() apimeta.RESTMapper {
|
|||
return mapper
|
||||
}
|
||||
|
||||
func setupMetricNamer() []MetricNamer {
|
||||
func setupMetricNamer() []naming.MetricNamer {
|
||||
cfg := config.DefaultConfig(1*time.Minute, "kube_")
|
||||
namers, err := NamersFromConfig(cfg, restMapper())
|
||||
namers, err := naming.NamersFromConfig(cfg, restMapper())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
return namers
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue