Register the collector

This commit is contained in:
Neil Alexander 2022-10-04 13:37:32 +01:00
parent 7c4e01e5c4
commit 685fecb033
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -6,6 +6,7 @@ import (
"regexp"
"github.com/matrix-org/dendrite/setup/config"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/sirupsen/logrus"
)
@ -48,6 +49,7 @@ func Open(dbProperties *config.DatabaseOptions, writer Writer) (*sql.DB, error)
db.SetMaxIdleConns(dbProperties.MaxIdleConns())
db.SetConnMaxLifetime(dbProperties.ConnMaxLifetime())
}
collectors.NewDBStatsCollector(db, fmt.Sprintf("dendrite_%s", dbProperties.Name))
collector := collectors.NewDBStatsCollector(db, fmt.Sprintf("dendrite_%s", dbProperties.Name))
prometheus.MustRegister(collector)
return db, nil
}