[#1673] logger: Add sampling for journald logger
All checks were successful
DCO action / DCO (pull_request) Successful in 40s
Vulncheck / Vulncheck (pull_request) Successful in 1m2s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m26s
Build / Build Components (pull_request) Successful in 1m28s
Tests and linters / Run gofumpt (pull_request) Successful in 2m36s
Tests and linters / Lint (pull_request) Successful in 3m14s
Tests and linters / Staticcheck (pull_request) Successful in 3m13s
Tests and linters / Tests (pull_request) Successful in 3m44s
Tests and linters / Tests with -race (pull_request) Successful in 3m43s
Tests and linters / gopls check (pull_request) Successful in 3m51s
All checks were successful
DCO action / DCO (pull_request) Successful in 40s
Vulncheck / Vulncheck (pull_request) Successful in 1m2s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m26s
Build / Build Components (pull_request) Successful in 1m28s
Tests and linters / Run gofumpt (pull_request) Successful in 2m36s
Tests and linters / Lint (pull_request) Successful in 3m14s
Tests and linters / Staticcheck (pull_request) Successful in 3m13s
Tests and linters / Tests (pull_request) Successful in 3m44s
Tests and linters / Tests with -race (pull_request) Successful in 3m43s
Tests and linters / gopls check (pull_request) Successful in 3m51s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
c95b09d76b
commit
3f149a0a0a
1 changed files with 13 additions and 1 deletions
|
@ -2,6 +2,7 @@ package logger
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/zapjournald"
|
||||
"github.com/ssgreg/journald"
|
||||
|
@ -166,7 +167,18 @@ func newJournaldLogger(prm *Prm) (*Logger, error) {
|
|||
zapjournald.SyslogPid(),
|
||||
})
|
||||
|
||||
lZap := zap.New(coreWithContext, zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)), zap.AddCallerSkip(1))
|
||||
var samplerOpts []zapcore.SamplerOption
|
||||
if c.Sampling.Hook != nil {
|
||||
samplerOpts = append(samplerOpts, zapcore.SamplerHook(c.Sampling.Hook))
|
||||
}
|
||||
samplingCore := zapcore.NewSamplerWithOptions(
|
||||
coreWithContext,
|
||||
time.Second,
|
||||
c.Sampling.Initial,
|
||||
c.Sampling.Thereafter,
|
||||
samplerOpts...,
|
||||
)
|
||||
lZap := zap.New(samplingCore, zap.AddStacktrace(zap.NewAtomicLevelAt(zap.FatalLevel)), zap.AddCallerSkip(1))
|
||||
|
||||
l := &Logger{z: lZap, lvl: lvl}
|
||||
prm._log = l
|
||||
|
|
Loading…
Add table
Reference in a new issue