Skip to content

Commit

Permalink
(config, log): use 'log.stats_time' if defined
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Aug 19, 2024
1 parent 9dcbfad commit 053ce11
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmn/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ func (c *LogConf) Validate() error {
return fmt.Errorf("invalid log.flush_time=%s (expected range [0, 1h)", c.FlushTime)
}
if c.StatsTime.D() > 10*time.Minute {
return fmt.Errorf("invalid log.stats_time=%s (expected range [log.stats_time, 10m])", c.StatsTime)
return fmt.Errorf("invalid log.stats_time=%s (expected range [periodic.stats_time, 10m])", c.StatsTime)
}
return nil
}
Expand Down
8 changes: 8 additions & 0 deletions stats/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ func (r *runner) nodeStateFlags() cos.NodeStateFlags {
return cos.NodeStateFlags(val)
}

func (r *runner) _next(config *cmn.Config, now int64) {
if config.Log.StatsTime >= config.Periodic.StatsTime {
r.next = now + int64(config.Log.StatsTime)
} else {
r.next = now + maxStatsLogInterval // default
}
}

func (r *runner) _run(logger statsLogger) error {
var (
i, j, k time.Duration
Expand Down
4 changes: 2 additions & 2 deletions stats/proxy_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *Prunner) Init(p core.Node) *atomic.Bool {
// statsLogger interface impl
//

func (r *Prunner) log(now int64, uptime time.Duration, _ *cmn.Config) {
func (r *Prunner) log(now int64, uptime time.Duration, config *cmn.Config) {
s := r.core
s.updateUptime(uptime)
s.promLock()
Expand All @@ -79,7 +79,7 @@ func (r *Prunner) log(now int64, uptime time.Duration, _ *cmn.Config) {
}
}
if idle {
r.next = now + maxStatsLogInterval
r._next(config, now)
}
}

Expand Down
3 changes: 2 additions & 1 deletion stats/target_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,9 @@ func (r *Trunner) log(now int64, uptime time.Duration, config *cmn.Config) {
// 7. separately, memory w/ set/clr flags cumulative
r._mem(r.t.PageMM(), set, clr)

// idle
if now > r.next {
r.next = now + maxStatsLogInterval
r._next(config, now)
}
}

Expand Down

0 comments on commit 053ce11

Please sign in to comment.