Skip to content

Commit

Permalink
Log only if metrics generator take a long time
Browse files Browse the repository at this point in the history
  • Loading branch information
mechairoi committed Jan 31, 2018
1 parent 8de7130 commit 240bfab
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion agent/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ func generateValues(generators []metrics.Generator) []*metrics.ValuesCustomIdent

startedAt := time.Now()
values, err := g.Generate()
logger.Debugf("%T.Generate() finished in %d ms", g, (time.Now().Sub(startedAt) / time.Millisecond))
if seconds := (time.Now().Sub(startedAt) / time.Second); seconds > 120 {
logger.Warningf("%T.Generate() take a long time (%d seconds)", g, (time.Now().Sub(startedAt) / time.Second))
}
if err != nil {
logger.Errorf("Failed to generate value in %T (skip this metric): %s", g, err.Error())
return
Expand Down

0 comments on commit 240bfab

Please sign in to comment.