frostfs-node/cmd/neofs-node/modules/node/metrics.go

47 lines
1,018 B
Go
Raw Normal View History

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"
"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
}
metricsServiceParams struct {
dig.In
Logger *zap.Logger
2020-07-24 13:54:03 +00:00
Collector metrics2.Collector
}
)
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{
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{
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],
})
}