Skip to content

Commit

Permalink
feat: agent
Browse files Browse the repository at this point in the history
  • Loading branch information
zenghur committed Jun 10, 2021
1 parent 922388b commit ffc0072
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,14 @@ func (a *Agent) collectAndSend(ctx context.Context, buf *bytes.Buffer, r *ring.R
return nil
}

func (a *Agent) prepareNextRound(t *time.Timer, buf *bytes.Buffer, r *ring.Ring) {
func (a *Agent) prepareNextRound(t *time.Timer, buf *bytes.Buffer, r *ring.Ring) *ring.Ring {
buf.Reset()
r = r.Next()
if r.Value.(profile.Type) == profile.TypeCPU {
t.Reset(adjust(a.o.BreakPeriod))
}
t.Reset(adjust(0))
return r
}

func (a *Agent) onSchedule(ctx context.Context) {
Expand Down Expand Up @@ -231,7 +232,7 @@ func (a *Agent) onSchedule(ctx context.Context) {
if err := a.collectAndSend(ctx, &buf, r); err != nil {
a.logger.Warn(fmt.Sprintf("fail to collect and send: %v", r.Value), zap.Error(err))
}
a.prepareNextRound(ti, &buf, r)
r = a.prepareNextRound(ti, &buf, r)
}

}
Expand Down

0 comments on commit ffc0072

Please sign in to comment.