2020-07-06 09:18:16 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-07-26 13:29:07 +00:00
|
|
|
"net/http"
|
|
|
|
|
2020-07-06 09:18:16 +00:00
|
|
|
"github.com/spf13/viper"
|
2020-07-12 23:00:47 +00:00
|
|
|
"go.uber.org/zap"
|
2020-07-06 09:18:16 +00:00
|
|
|
)
|
|
|
|
|
2022-07-26 13:29:07 +00:00
|
|
|
// NewPrometheusService creates a new service for gathering prometheus metrics.
|
2023-02-09 08:59:31 +00:00
|
|
|
func NewPrometheusService(v *viper.Viper, log *zap.Logger, handler http.Handler) *Service {
|
2022-07-26 13:29:07 +00:00
|
|
|
if log == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Service{
|
|
|
|
Server: &http.Server{
|
|
|
|
Addr: v.GetString(cfgPrometheusAddress),
|
2023-02-09 08:59:31 +00:00
|
|
|
Handler: handler,
|
2022-07-26 13:29:07 +00:00
|
|
|
},
|
|
|
|
enabled: v.GetBool(cfgPrometheusEnabled),
|
|
|
|
serviceType: "Prometheus",
|
|
|
|
log: log.With(zap.String("service", "Prometheus")),
|
|
|
|
}
|
2020-07-06 09:18:16 +00:00
|
|
|
}
|