Skip to content

Commit

Permalink
make JSON output logging less noisy
Browse files Browse the repository at this point in the history
Increase time interval between log message to 200 milliseconds
Remove Writing JSON metrics message
Add if statement output log based on no of count
  • Loading branch information
michiboo authored and imiric committed Jun 9, 2020
1 parent d932446 commit 0839be8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions stats/json/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ func (c *Collector) Init() error {
func (c *Collector) SetRunStatus(status lib.RunStatus) {}

func (c *Collector) Run(ctx context.Context) {
const timeout = 200
logrus.Debug("JSON output: Running!")
ticker := time.NewTicker(time.Millisecond * 100)
ticker := time.NewTicker(time.Millisecond * timeout)
defer func() {
_ = c.closeFn()
}()
Expand Down Expand Up @@ -142,7 +143,6 @@ func (c *Collector) commit() {
samples := c.buffer
c.buffer = nil
c.bufferLock.Unlock()
logrus.WithField("filename", c.fname).Debug("JSON: Writing JSON metrics")
var start = time.Now()
var count int
for _, sc := range samples {
Expand All @@ -160,8 +160,10 @@ func (c *Collector) commit() {
}
}
}
logrus.WithField("filename", c.fname).WithField("t", time.Since(start)).
WithField("count", count).Debug("JSON: Wrote JSON metrics")
if count > 0 {
logrus.WithField("filename", c.fname).WithField("t", time.Since(start)).
WithField("count", count).Debug("JSON: Wrote JSON metrics")
}
}

func (c *Collector) Link() string {
Expand Down

0 comments on commit 0839be8

Please sign in to comment.