forked from TrueCloudLab/frostfs-node
[#375] Add log metrics
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
83d600ed77
commit
0c40d98f7a
4 changed files with 48 additions and 0 deletions
|
@ -31,6 +31,9 @@ type Prm struct {
|
|||
// support runtime rereading
|
||||
level zapcore.Level
|
||||
|
||||
// MetricsNamespace is the namespace string used for log counter metrics
|
||||
MetricsNamespace string
|
||||
|
||||
// do not support runtime rereading
|
||||
}
|
||||
|
||||
|
@ -79,10 +82,15 @@ func NewLogger(prm *Prm) (*Logger, error) {
|
|||
|
||||
lvl := zap.NewAtomicLevelAt(prm.level)
|
||||
|
||||
m := newLogMetrics(prm.MetricsNamespace)
|
||||
|
||||
c := zap.NewProductionConfig()
|
||||
c.Level = lvl
|
||||
c.Encoding = "console"
|
||||
c.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
c.Sampling.Hook = func(e zapcore.Entry, sd zapcore.SamplingDecision) {
|
||||
m.Inc(e.Level, sd == zapcore.LogDropped)
|
||||
}
|
||||
|
||||
lZap, err := c.Build(
|
||||
zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue