@@ -125,6 +125,7 @@ type MetricMap struct {
125
125
126
126
// TODO: revisit cu with the semver system
127
127
func dumpMaps () {
128
+ // TODO: make this function part of the exporter
128
129
for name , cmap := range builtinMetricMaps {
129
130
query , ok := queryOverrides [name ]
130
131
if ! ok {
@@ -659,6 +660,10 @@ func dbToString(t interface{}) (string, bool) {
659
660
660
661
// Exporter collects Postgres metrics. It implements prometheus.Collector.
661
662
type Exporter struct {
663
+ // Holds a reference to the build in column mappings. Currently this is for testing purposes
664
+ // only, since it just points to the global.
665
+ builtinMetricMaps map [string ]map [string ]ColumnMapping
666
+
662
667
dsn string
663
668
userQueriesPath string
664
669
duration prometheus.Gauge
@@ -685,8 +690,9 @@ type Exporter struct {
685
690
// NewExporter returns a new PostgreSQL exporter for the provided DSN.
686
691
func NewExporter (dsn string , userQueriesPath string ) * Exporter {
687
692
return & Exporter {
688
- dsn : dsn ,
689
- userQueriesPath : userQueriesPath ,
693
+ builtinMetricMaps : builtinMetricMaps ,
694
+ dsn : dsn ,
695
+ userQueriesPath : userQueriesPath ,
690
696
duration : prometheus .NewGauge (prometheus.GaugeOpts {
691
697
Namespace : namespace ,
692
698
Subsystem : exporter ,
@@ -913,7 +919,7 @@ func (e *Exporter) checkMapVersions(ch chan<- prometheus.Metric, db *sql.DB) err
913
919
log .Infoln ("Semantic Version Changed:" , e .lastMapVersion .String (), "->" , semanticVersion .String ())
914
920
e .mappingMtx .Lock ()
915
921
916
- e .metricMap = makeDescMap (semanticVersion , builtinMetricMaps )
922
+ e .metricMap = makeDescMap (semanticVersion , e . builtinMetricMaps )
917
923
e .queryOverrides = makeQueryOverrideMap (semanticVersion , queryOverrides )
918
924
e .lastMapVersion = semanticVersion
919
925
0 commit comments