diff --git a/internal/writers/spread_writer.go b/internal/writers/spread_writer.go index 97e928ea6..42af812d7 100644 --- a/internal/writers/spread_writer.go +++ b/internal/writers/spread_writer.go @@ -29,6 +29,14 @@ func (s *SpreadWriter) Write(p []byte) (int, error) { } func (s *SpreadWriter) Flush() { + if len(s.buf) == 0 { + // nothing to write, just wait + select { + case <-time.After(s.interval): + case <-s.exitCh: + } + return + } sleep := s.interval / time.Duration(len(s.buf)) ticker := time.NewTicker(sleep) for _, b := range s.buf {