You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sampledLogger.Info().Msgf("WatchOutbound: outbound observation is disabled for chain %d", chainID)
I thought that we could introduce some simple wrapper that would implement throttling behaviour
logger:= zerolog.New(...)
// creates a new logger wrapper that allows 1 unique log per 5 secondstlog:= throttlelog.New(5*time.Second)
variintfor {
key:=fmt.Sprintf("is_even:%t", i%2==0)
i++tlog(key, logger.Info().Str("hello", "world").Int("iteration", i)).Msg("Tick")
time.Sleep(time.Second)
}
// Tick hello=world iteration=0// Tick hello=world iteration=1// ... sleep for 5s// Tick hello=world iteration=10// Tick hello=world iteration=11// ...
The possible drawback of this approach is that we need to invoke some mutex & timestamp checker on each invocation and introduce additional allocations. But practically, we use sampled loggers only in edge cases when something is broken or disabled, so it should not hurt the performance but reduce unnecessary logs volume and avoid reimplementing sync.Once-like behavior for logs.
The text was updated successfully, but these errors were encountered:
We use zerolog's sampled logger for reducing the noise that might be produced with repeated checks/tasks.
node/zetaclient/chains/solana/observer/outbound.go
Line 53 in cfcf706
I thought that we could introduce some simple wrapper that would implement throttling behaviour
The possible drawback of this approach is that we need to invoke some mutex & timestamp checker on each invocation and introduce additional allocations. But practically, we use sampled loggers only in edge cases when something is broken or disabled, so it should not hurt the performance but reduce unnecessary logs volume and avoid reimplementing
sync.Once
-like behavior for logs.The text was updated successfully, but these errors were encountered: