mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-06 09:47:54 +00:00
Cleaning up.
* Wiped out a ton of warnings about comments. * Created consts for `MetricType` values. * `externalInfoMap` can now track multiple series with the same name/namespace and different labels. * `namespace` parameter of external metrics queries is now respected (albeit very rudimentarily) * Metric converter values for external metrics are now converted the same way as for custom metrics (probably still some opportunity for consolidation). * Lots of TODOs actually done. * Deleted a lot of commented out code.
This commit is contained in:
parent
9641e70005
commit
a94494337e
18 changed files with 155 additions and 188 deletions
|
|
@ -15,16 +15,7 @@ import (
|
|||
conv "github.com/directxman12/k8s-prometheus-adapter/pkg/custom-provider/metric-converter"
|
||||
)
|
||||
|
||||
//TODO: Make sure everything has the proper licensing disclosure at the top.
|
||||
//TODO: I'd like to move these files into another directory, but the compiler was giving me
|
||||
//some static around unexported types. I'm going to leave things as-is for now, but it
|
||||
//might be worthwhile to, once the shared components are discovered, move some things around.
|
||||
|
||||
//TODO: Some of these members may not be necessary.
|
||||
//Some of them are definitely duplicated between the
|
||||
//external and custom providers. They should probably share
|
||||
//the same instances of these objects (especially the SeriesRegistry)
|
||||
//to cut down on unnecessary chatter/bookkeeping.
|
||||
//TODO: AC - Make sure everything has the proper licensing disclosure at the top.
|
||||
type externalPrometheusProvider struct {
|
||||
promClient prom.Client
|
||||
metricConverter conv.MetricConverter
|
||||
|
|
@ -32,13 +23,7 @@ type externalPrometheusProvider struct {
|
|||
seriesRegistry ExternalSeriesRegistry
|
||||
}
|
||||
|
||||
//TODO: It probably makes more sense to, once this is functional and complete, roll the
|
||||
//prometheusProvider and externalPrometheusProvider up into a single type
|
||||
//that implements both interfaces or provide a thin wrapper that composes them.
|
||||
//Just glancing at start.go looks like it would be much more straightforward
|
||||
//to do one of those two things instead of trying to run the two providers
|
||||
//independently.
|
||||
|
||||
//NewExternalPrometheusProvider creates an ExternalMetricsProvider capable of responding to Kubernetes requests for external metric data.
|
||||
func NewExternalPrometheusProvider(seriesRegistry ExternalSeriesRegistry, promClient prom.Client, converter conv.MetricConverter) provider.ExternalMetricsProvider {
|
||||
return &externalPrometheusProvider{
|
||||
promClient: promClient,
|
||||
|
|
@ -48,21 +33,17 @@ func NewExternalPrometheusProvider(seriesRegistry ExternalSeriesRegistry, promCl
|
|||
}
|
||||
|
||||
func (p *externalPrometheusProvider) GetExternalMetric(namespace string, metricName string, metricSelector labels.Selector) (*external_metrics.ExternalMetricValueList, error) {
|
||||
selector, found := p.seriesRegistry.QueryForMetric(metricName, metricSelector)
|
||||
selector, found := p.seriesRegistry.QueryForMetric(namespace, metricName, metricSelector)
|
||||
|
||||
if !found {
|
||||
return &external_metrics.ExternalMetricValueList{
|
||||
Items: []external_metrics.ExternalMetricValue{},
|
||||
}, nil
|
||||
}
|
||||
// query := p.queryBuilder.BuildPrometheusQuery(namespace, metricName, metricSelector, queryMetadata)
|
||||
|
||||
//TODO: I don't yet know what a context is, but apparently I should use a real one.
|
||||
queryResults, err := p.promClient.Query(context.TODO(), pmodel.Now(), selector)
|
||||
|
||||
if err != nil {
|
||||
//TODO: Is this how folks normally deal w/ errors? Just propagate them upwards?
|
||||
//I should go look at what the customProvider does.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue