Skip to content

Commit

Permalink
profiler: make delta profile check logic more clean
Browse files Browse the repository at this point in the history
Removed a redundant condition (deltaProfile is documented to return nil
if delta profiles are disabled) and changed the order of conditions to
match the default configuration (detla profiles first).
  • Loading branch information
nsrip-dd committed Mar 1, 2022
1 parent 70354df commit fd3d644
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions profiler/profile.go
Expand Up @@ -223,18 +223,17 @@ func (p *profiler) runProfile(pt ProfileType) ([]*profile, error) {
end := now()
tags := append(p.cfg.tags, pt.Tag())
var profs []*profile
if !p.cfg.deltaProfiles || deltaProf == nil {
if deltaProf != nil {
profs = append(profs, deltaProf)
p.cfg.statsd.Timing("datadog.profiler.go.delta_time", end.Sub(deltaStart), tags, 1)
} else {
// If the user has disabled delta profiles, or the profile type
// doesn't support delta profiles (like the CPU profile) then
// send the original profile unchanged.
profs = append(profs, &profile{
name: t.Filename,
data: data,
})
} else {
// If the user has enabled delta profiles, then the delta
// profile is all we need for the backend and we can save
// significant storage and bandwidth by not including the full,
// non-delta profile.
profs = append(profs, deltaProf)
p.cfg.statsd.Timing("datadog.profiler.go.delta_time", end.Sub(deltaStart), tags, 1)
}
p.cfg.statsd.Timing("datadog.profiler.go.collect_time", end.Sub(start), tags, 1)
return profs, nil
Expand Down

0 comments on commit fd3d644

Please sign in to comment.