frostfs-node/pkg/util/logger/metrics.go
Alejandro Lopez 344d6b2ae1
All checks were successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/push/pre-commit Pipeline was successful
[#xx] Fix invalid log metric namespace identifier
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
2023-06-13 15:36:34 +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()
}