1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-08-13 20:04:49 +02:00

Do not expose unnecessary Prometheus functions

This commit is contained in:
Ralph Slooten
2025-07-25 19:43:34 +12:00
parent 2a7aa33a0a
commit fbc1dc6118

View File

@@ -32,7 +32,7 @@ var (
) )
// InitMetrics initializes all Prometheus metrics // InitMetrics initializes all Prometheus metrics
func InitMetrics() { func initMetrics() {
// Create metrics // Create metrics
totalMessages = prometheus.NewGauge(prometheus.GaugeOpts{ totalMessages = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "mailpit_messages", Name: "mailpit_messages",
@@ -107,7 +107,7 @@ func InitMetrics() {
} }
// UpdateMetrics updates all metrics with current values // UpdateMetrics updates all metrics with current values
func UpdateMetrics() { func updateMetrics() {
info := stats.Load(false) info := stats.Load(false)
totalMessages.Set(float64(info.Messages)) totalMessages.Set(float64(info.Messages))
@@ -130,7 +130,7 @@ func UpdateMetrics() {
} }
} }
// Returns the Prometheus handler & disables double compression in middleware // GetHandler returns the Prometheus handler & disables double compression in middleware
func GetHandler() http.Handler { func GetHandler() http.Handler {
return promhttp.HandlerFor(Registry, promhttp.HandlerOpts{ return promhttp.HandlerFor(Registry, promhttp.HandlerOpts{
DisableCompression: true, DisableCompression: true,
@@ -139,8 +139,8 @@ func GetHandler() http.Handler {
// StartUpdater starts the periodic metrics update routine // StartUpdater starts the periodic metrics update routine
func StartUpdater() { func StartUpdater() {
InitMetrics() initMetrics()
UpdateMetrics() updateMetrics()
// Start periodic updates // Start periodic updates
go func() { go func() {
@@ -148,7 +148,7 @@ func StartUpdater() {
defer ticker.Stop() defer ticker.Stop()
for range ticker.C { for range ticker.C {
UpdateMetrics() updateMetrics()
} }
}() }()
} }