neo-go/pkg/services/metrics/prometheus.go

30 lines
695 B
Go
Raw Normal View History

package metrics
import (
"net/http"
"github.com/nspcc-dev/neo-go/pkg/config"
"github.com/prometheus/client_golang/prometheus/promhttp"
2019-12-30 07:43:05 +00:00
"go.uber.org/zap"
)
// PrometheusService https://prometheus.io/docs/guides/go-application.
type PrometheusService Service
// NewPrometheusService creates a new service for gathering prometheus metrics.
func NewPrometheusService(cfg config.BasicService, log *zap.Logger) *Service {
2019-12-30 07:43:05 +00:00
if log == nil {
return nil
}
return &Service{
2019-12-30 07:43:05 +00:00
Server: &http.Server{
Addr: cfg.Address + ":" + cfg.Port,
Handler: promhttp.Handler(),
2019-12-30 07:43:05 +00:00
},
config: cfg,
serviceType: "Prometheus",
log: log.With(zap.String("service", "Prometheus")),
}
}