Skip to content

Commit

Permalink
profiler: randomize wait duration before retrying upload (#1396)
Browse files Browse the repository at this point in the history
PR #827 introduced a randomized wait duration before retrying a failed
profile upload. This was done to reduce the likelihood of flooding the
backend with uploads. The wait was done to be an average of half the
profiling perdio. However, PR #961 lost this behavior when introducing
interruptible sleeps. This commit restores the lost behavior.

Fixes #1395
  • Loading branch information
nsrip-dd authored and Kyle-Verhoog committed Jul 21, 2022
1 parent 07ea744 commit d665d9f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions profiler/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ func (p *profiler) upload(bat batch) error {
err = p.doRequest(bat)
if rerr, ok := err.(*retriableError); ok {
statsd.Count("datadog.profiling.go.upload_retry", 1, nil, 1)
wait := time.Duration(rand.Int63n(p.cfg.period.Nanoseconds()))
wait := time.Duration(rand.Int63n(p.cfg.period.Nanoseconds())) * time.Nanosecond
log.Error("Uploading profile failed: %v. Trying again in %s...", rerr, wait)
p.interruptibleSleep(time.Second)
p.interruptibleSleep(wait)
continue
}
if err != nil {
Expand Down

0 comments on commit d665d9f

Please sign in to comment.