Use labels for mapping metric types to metrics (#219)

* Use labels for mapping metric types to metrics

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>

* Log warning when old format is used

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>

* Test NewCollector logic for external metrics

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
This commit is contained in:
Mikkel Oscar Lyderik Larsen
2020-11-04 20:40:53 +01:00
committed by GitHub
parent bb107b678c
commit df0ed1fca4
14 changed files with 227 additions and 81 deletions

View File

@ -15,7 +15,7 @@ const (
)
type AnnotationConfigs struct {
CollectorName string
CollectorType string
Configs map[string]string
PerReplica bool
Interval time.Duration
@ -64,14 +64,14 @@ func (m AnnotationConfigMap) Parse(annotations map[string]string) error {
config, ok := m[key]
if !ok {
config = &AnnotationConfigs{
CollectorName: metricCollector,
CollectorType: metricCollector,
Configs: map[string]string{},
}
m[key] = config
}
// TODO: fail if collector name doesn't match
if config.CollectorName != metricCollector {
if config.CollectorType != metricCollector {
continue
}