mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
6b4dd5703e
There are no changes visible from the user side (at least for those users who doesn't put Prometheus's or pprof's port in quotes), just internal refactoring. From now and on, BasicService configuration is used by RPC server config, TLS for RPC server, pprof and Prometheus.
29 lines
686 B
Go
29 lines
686 B
Go
package metrics
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
"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 {
|
|
if log == nil {
|
|
return nil
|
|
}
|
|
|
|
return &Service{
|
|
Server: &http.Server{
|
|
Addr: cfg.FormatAddress(),
|
|
Handler: promhttp.Handler(),
|
|
},
|
|
config: cfg,
|
|
serviceType: "Prometheus",
|
|
log: log.With(zap.String("service", "Prometheus")),
|
|
}
|
|
}
|