mirror of
https://github.com/foomo/keel.git
synced 2025-10-16 12:35:34 +00:00
36 lines
754 B
Go
36 lines
754 B
Go
package service
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
var (
|
|
DefaultHTTPPrometheusName = "prometheus"
|
|
DefaultHTTPPrometheusAddr = ":9200"
|
|
DefaultHTTPPrometheusPath = "/metrics"
|
|
)
|
|
|
|
func NewHTTPPrometheus(l *zap.Logger, name, addr, path string) *HTTP {
|
|
handler := http.NewServeMux()
|
|
handler.Handle(path, promhttp.HandlerFor(
|
|
prometheus.DefaultGatherer,
|
|
promhttp.HandlerOpts{
|
|
EnableOpenMetrics: true,
|
|
},
|
|
))
|
|
return NewHTTP(l, name, addr, handler)
|
|
}
|
|
|
|
func NewDefaultHTTPPrometheus(l *zap.Logger) *HTTP {
|
|
return NewHTTPPrometheus(
|
|
l,
|
|
DefaultHTTPPrometheusName,
|
|
DefaultHTTPPrometheusAddr,
|
|
DefaultHTTPPrometheusPath,
|
|
)
|
|
}
|