frostfs-node/pkg/util/logger/metrics.go
Anton Nikiforov 994f48f8bb [#680] metrics: Export log and morph with script
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
2023-10-11 17:08:03 +03:00

37 lines
867 B
Go

package logger
import (
"strconv"
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap/zapcore"
)
const (
logSubsystem = "logger"
logLevelLabel = "level"
logDroppedLabel = "dropped"
)
type LogMetrics struct {
logCount *prometheus.CounterVec
}
func NewLogMetrics(namespace string) *LogMetrics {
return &LogMetrics{
logCount: metrics.NewCounterVec(prometheus.CounterOpts{
Namespace: namespace,
Subsystem: logSubsystem,
Name: "entry_count",
Help: "Total log entries emitted or dropped by severity level",
}, []string{logLevelLabel, logDroppedLabel}),
}
}
func (m *LogMetrics) Inc(level zapcore.Level, dropped bool) {
m.logCount.With(prometheus.Labels{
logLevelLabel: level.String(),
logDroppedLabel: strconv.FormatBool(dropped),
}).Inc()
}