[#224] Refactor logger tag configuration #224
No reviewers
Labels
No labels
P0
P1
P2
P3
good first issue
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-http-gw#224
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "pogpp/frostfs-http-gw:feature/improve_logs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Signed-off-by: Pavel Pogodaev p.pogodaev@yadro.com
[] Refactor logger tag configurationto [#224] Refactor logger tag configuration71a9794222
to4cc2c3f9ba
4cc2c3f9ba
to6608423f74
@ -531,2 +531,3 @@
res[name] = lvl
for _, tagName := range strings.Split(tagNames, ",") {
res[tagName] = lvl
I think we should trim leading and trailing whitespace from all obtained tags because users may separate tags with commas and spaces, e.g.,
app, datapath
.We should also handle empty tags, like
tag1,,tag2
, possibly by simply skipping them6608423f74
to178cb19ea4
Actually such config:
Doesn't work as expected now. It won't print any message it their log level isn't fatal. But we want to print logs with
app
tag that have leveldebug
@ -32,3 +32,2 @@
tags:
- name: app
- name: datapath
- names: app,datapath
What about changing
config.env
HTTP_GW_LOGGER_TAGS_1_NAME=datapath
?
178cb19ea4
to38856cc81f
38856cc81f
to8583dffb7c
8583dffb7c
to65e0ac354a
65e0ac354a
to81e525d6df
81e525d6df
to06db52e53d
06db52e53d
to901bf4171d
@ -119,10 +119,15 @@ type (
logLevelConfig struct {
logLevel zap.AtomicLevel
maxLevel zap.AtomicLevel
Why do we need new field? Can we reuse existing one?
@ -149,3 +156,4 @@
}
}
func maxLogLevel(lvl zap.AtomicLevel, config *tagsConfig) zap.AtomicLevel {
I suppose we need min level. Otherwise this #224 (comment) still doesn't work
tested on devenv - fixed
@ -204,3 +226,3 @@
tagConfig := newTagsConfig(cfg.config(), logLevel.Level())
logConfig := newLogLevelConfig(logLevel, tagConfig)
log := pickLogger(cfg.config(), logConfig.logLevel, logSettings, tagConfig)
log := pickLogger(cfg.config(), *logConfig, logSettings, tagConfig)
Actually we can don't change this if
logConfig.lovLevel
be already computed min log level@ -200,3 +199,3 @@
```yaml
tags:
- name: "app"
- names: "app,datapath"
This change should be mentioned in CHANGELOG.md I suppose
@ -73,24 +79,21 @@ func (c *zapCoreTagFilterWrapper) Write(entry zapcore.Entry, fields []zapcore.Fi
func (c *zapCoreTagFilterWrapper) shouldSkip(entry zapcore.Entry, fields []zap.Field) bool {
Current
Write
implementation issue: if extra fields contain an app tag withinfo
level, while:fatal
info
the first
shouldSkip
call will return true, causing messages with tags that should be logged to be skipped.901bf4171d
toa833607526
a833607526
to0117adf231
0117adf231
toc9d2ad947c
c9d2ad947c
to5800d48112
5800d48112
toce12a389c9
@ -160,2 +174,4 @@
log.Warn(logs.TagsLogConfigWontBeUpdated, zap.Error(err), logs.TagField(logs.TagApp))
}
l.logLevel.SetLevel(minLogLevel(zap.NewAtomicLevelAt(lvl), l.tagsConfig).Level())
I suggest this
@ -162,3 +178,3 @@
}
func (t *tagsConfig) LevelEnabled(tag string, tgtLevel zapcore.Level) bool {
func (t *tagsConfig) LevelEnabled(tag string, tgtLevel zapcore.Level) (bool, bool) {
We can don't change signature. If we write
@ -171,0 +186,4 @@
return lvl.(zapcore.Level).Enabled(tgtLevel), true
}
func (t *tagsConfig) DefaultLevel() zap.AtomicLevel {
I would return not atomic, but just level
or don't return level but accept it (similart to
levelEnabled
)@ -194,6 +214,7 @@ func (t *tagsConfig) update(cfg *viper.Viper, ll zapcore.Level) error {
for k, v := range tags {
t.tagLogs.Store(k, v)
}
t.defaultLvl = zap.NewAtomicLevelAt(ll)
Should be
In such scenario we will have panic on integration test
@ -67,0 +71,4 @@
}
return c.core.Write(entry, fields)
}
shouldSkip, tagFound = c.shouldSkip(entry, c.extra)
Probably we can pass both (
fields
,c.extra
) toc.shouldSkip
ce12a389c9
tod94fa7add6
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.