mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-08 06:33:56 +00:00
Intermediate progress.
Working through some of the result conversions. I want to use this code in a harness project to exercise some of it, but there are some versioning issues around my modified code vs. the current version of the real project. The easiest way to work around them at the moment is to push this.
This commit is contained in:
parent
a69a5cbbcc
commit
d90012439c
6 changed files with 68 additions and 37 deletions
|
|
@ -11,7 +11,7 @@ import (
|
|||
//MetricConverter provides a unified interface for converting the results of
|
||||
//Prometheus queries into external metric types.
|
||||
type MetricConverter interface {
|
||||
Convert(queryResult prom.QueryResult) (*external_metrics.ExternalMetricValueList, error)
|
||||
Convert(metadata QueryMetadata, queryResult prom.QueryResult) (*external_metrics.ExternalMetricValueList, error)
|
||||
}
|
||||
|
||||
type metricConverter struct {
|
||||
|
|
@ -30,17 +30,17 @@ func NewMetricConverter(scalar MetricConverter, vector MetricConverter, matrix M
|
|||
}
|
||||
}
|
||||
|
||||
func (c *metricConverter) Convert(queryResult prom.QueryResult) (*external_metrics.ExternalMetricValueList, error) {
|
||||
func (c *metricConverter) Convert(metadata QueryMetadata, queryResult prom.QueryResult) (*external_metrics.ExternalMetricValueList, error) {
|
||||
if queryResult.Type == model.ValScalar {
|
||||
return c.scalarConverter.Convert(queryResult)
|
||||
return c.scalarConverter.Convert(metadata, queryResult)
|
||||
}
|
||||
|
||||
if queryResult.Type == model.ValVector {
|
||||
return c.vectorConverter.Convert(queryResult)
|
||||
return c.vectorConverter.Convert(metadata, queryResult)
|
||||
}
|
||||
|
||||
if queryResult.Type == model.ValMatrix {
|
||||
return c.matrixConverter.Convert(queryResult)
|
||||
return c.matrixConverter.Convert(metadata, queryResult)
|
||||
}
|
||||
|
||||
return nil, errors.New("encountered an unexpected query result type")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue