-
Notifications
You must be signed in to change notification settings - Fork 10
/
tr.go
39 lines (29 loc) · 900 Bytes
/
tr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2022 Block, Inc.
package prom
import (
"sync"
"github.com/prometheus/client_golang/prometheus"
"github.com/cashapp/blip"
"github.com/cashapp/blip/prom/tr"
)
type DomainTranslator interface {
Translate(values []blip.MetricValue, ch chan<- prometheus.Metric)
Names() (prefix, domain, shortDomin string)
}
func Register(blipDomain string, tr DomainTranslator) error {
trMux.Lock()
defer trMux.Unlock()
trRepo[blipDomain] = tr
return nil
}
func Translator(domain string) DomainTranslator {
trMux.Lock()
defer trMux.Unlock()
return trRepo[domain]
}
var trMux = &sync.Mutex{}
var trRepo = map[string]DomainTranslator{
"status.global": tr.StatusGlobal{Domain: "global_status", ShortDomain: "status"},
"var.global": tr.Generic{Domain: "global_variables", ShortDomain: "var"},
"innodb": tr.InnoDBMetrics{Domain: "info_schema_innodb", ShortDomain: "innodb"},
}