[#680] metrics: Export log and morph with script

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2023-10-04 10:03:37 +03:00
parent aca11d7474
commit 994f48f8bb
7 changed files with 24 additions and 14 deletions

View file

@ -9,7 +9,6 @@ import (
morphconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/morph"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/event"
@ -42,13 +41,13 @@ func initMorphComponents(ctx context.Context, c *cfg) {
c.key,
client.WithDialTimeout(morphconfig.DialTimeout(c.appCfg)),
client.WithLogger(c.log),
client.WithMetrics(metrics.NewMorphClientMetrics()),
client.WithMetrics(c.metricsCollector.MorphClientMetrics()),
client.WithEndpoints(addresses...),
client.WithConnLostCallback(func() {
c.internalErr <- errors.New("morph connection has been lost")
}),
client.WithSwitchInterval(morphconfig.SwitchInterval(c.appCfg)),
client.WithMorphCacheMetrics(metrics.NewNodeMorphCacheMetrics()),
client.WithMorphCacheMetrics(c.metricsCollector.MorphCacheMetrics()),
)
if err != nil {
c.log.Info(logs.FrostFSNodeFailedToCreateNeoRPCClient,

View file

@ -4,7 +4,6 @@ import (
"strconv"
"time"
morphmetrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/metrics"
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
"github.com/prometheus/client_golang/prometheus"
)
@ -16,7 +15,7 @@ type morphClientMetrics struct {
invokeDuration *prometheus.HistogramVec
}
func NewMorphClientMetrics() morphmetrics.Register {
func newMorphClientMetrics() *morphClientMetrics {
return &morphClientMetrics{
switchCount: metrics.NewCounter(prometheus.CounterOpts{
Namespace: namespace,

View file

@ -18,10 +18,6 @@ type morphCacheMetrics struct {
var _ MorphCacheMetrics = (*morphCacheMetrics)(nil)
func NewNodeMorphCacheMetrics() MorphCacheMetrics {
return newMorphCacheMetrics(namespace)
}
func newMorphCacheMetrics(ns string) *morphCacheMetrics {
return &morphCacheMetrics{
methodDuration: metrics.NewHistogramVec(prometheus.HistogramOpts{

View file

@ -1,6 +1,7 @@
package metrics
import (
morphmetrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/metrics"
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
"github.com/prometheus/client_golang/prometheus"
)
@ -19,6 +20,8 @@ type NodeMetrics struct {
pilorama *piloramaMetrics
grpc *grpcServerMetrics
policer *policerMetrics
morphClient *morphClientMetrics
morphCache *morphCacheMetrics
}
func NewNodeMetrics() *NodeMetrics {
@ -41,6 +44,8 @@ func NewNodeMetrics() *NodeMetrics {
pilorama: newPiloramaMetrics(),
grpc: newGrpcServerMetrics(),
policer: newPolicerMetrics(),
morphClient: newMorphClientMetrics(),
morphCache: newMorphCacheMetrics(namespace),
}
}
@ -96,3 +101,11 @@ func (m *NodeMetrics) GrpcServerMetrics() GrpcServerMetrics {
func (m *NodeMetrics) PolicerMetrics() PolicerMetrics {
return m.policer
}
func (m *NodeMetrics) MorphClientMetrics() morphmetrics.Register {
return m.morphClient
}
func (m *NodeMetrics) MorphCacheMetrics() MorphCacheMetrics {
return m.morphCache
}

View file

@ -82,7 +82,7 @@ func NewLogger(prm *Prm) (*Logger, error) {
lvl := zap.NewAtomicLevelAt(prm.level)
m := newLogMetrics(prm.MetricsNamespace)
m := NewLogMetrics(prm.MetricsNamespace)
c := zap.NewProductionConfig()
c.Level = lvl

View file

@ -14,12 +14,12 @@ const (
logDroppedLabel = "dropped"
)
type logMetrics struct {
type LogMetrics struct {
logCount *prometheus.CounterVec
}
func newLogMetrics(namespace string) *logMetrics {
return &logMetrics{
func NewLogMetrics(namespace string) *LogMetrics {
return &LogMetrics{
logCount: metrics.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: logSubsystem,
@ -29,7 +29,7 @@ func newLogMetrics(namespace string) *logMetrics {
}
}
func (m *logMetrics) Inc(level zapcore.Level, dropped bool) {
func (m *LogMetrics) Inc(level zapcore.Level, dropped bool) {
m.logCount.With(prometheus.Labels{
logLevelLabel: level.String(),
logDroppedLabel: strconv.FormatBool(dropped),

View file

@ -7,6 +7,7 @@ import (
"os"
local_metrics "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/metrics"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
)
@ -27,9 +28,11 @@ func main() {
switch {
case *node != "":
_ = local_metrics.NewNodeMetrics()
_ = logger.NewLogMetrics("frostfs_node")
filename = *node
case *ir != "":
_ = local_metrics.NewInnerRingMetrics()
_ = logger.NewLogMetrics("frostfs_ir")
filename = *ir
default: