2020-07-10 14:17:51 +00:00
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
2020-07-24 13:54:03 +00:00
|
|
|
metrics "github.com/nspcc-dev/neofs-node/pkg/network/transport/metrics/grpc"
|
|
|
|
metrics2 "github.com/nspcc-dev/neofs-node/pkg/services/metrics"
|
2020-07-10 14:17:51 +00:00
|
|
|
"github.com/spf13/viper"
|
|
|
|
"go.uber.org/atomic"
|
|
|
|
"go.uber.org/dig"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
metricsParams struct {
|
|
|
|
dig.In
|
|
|
|
|
|
|
|
Logger *zap.Logger
|
|
|
|
Options []string `name:"node_options"`
|
|
|
|
Viper *viper.Viper
|
2020-07-24 13:54:03 +00:00
|
|
|
Buckets Buckets
|
2020-07-10 14:17:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
metricsServiceParams struct {
|
|
|
|
dig.In
|
|
|
|
|
|
|
|
Logger *zap.Logger
|
2020-07-24 13:54:03 +00:00
|
|
|
Collector metrics2.Collector
|
2020-07-10 14:17:51 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func newObjectCounter() *atomic.Float64 { return atomic.NewFloat64(0) }
|
|
|
|
|
2020-07-24 13:54:03 +00:00
|
|
|
func newMetricsService(p metricsServiceParams) (metrics.Service, error) {
|
|
|
|
return metrics.New(metrics.Params{
|
2020-07-10 14:17:51 +00:00
|
|
|
Logger: p.Logger,
|
|
|
|
Collector: p.Collector,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:03 +00:00
|
|
|
func newMetricsCollector(p metricsParams) (metrics2.Collector, error) {
|
|
|
|
return metrics2.New(metrics2.Params{
|
2020-07-10 14:17:51 +00:00
|
|
|
Options: p.Options,
|
|
|
|
Logger: p.Logger,
|
|
|
|
Interval: p.Viper.GetDuration("metrics_collector.interval"),
|
2020-07-24 13:54:03 +00:00
|
|
|
MetricsStore: p.Buckets[fsBucket],
|
2020-07-10 14:17:51 +00:00
|
|
|
})
|
|
|
|
}
|