Skip to content

Commit

Permalink
follow up to #283
Browse files Browse the repository at this point in the history
  • Loading branch information
petethepig committed Jul 19, 2021
1 parent 2e3e342 commit e0f799a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/agent/gospy/gospy.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ func startCPUProfile(w io.Writer, hz uint32) error {
return custom_pprof.StartCPUProfile(w, hz)
}

func stopCPUProfile(hz uint32) {
// idea here is that for most people we're starting the default profiler
// but if you want to use a different sampling rate we use our experimental profiler
if hz == 100 {
pprof.StopCPUProfile()
return
}
custom_pprof.StopCPUProfile()
}

func Start(profileType spy.ProfileType, sampleRate uint32, disableGCRuns bool) (spy.Spy, error) {
s := &GoSpy{
stopCh: make(chan struct{}),
Expand Down Expand Up @@ -106,8 +116,7 @@ func (s *GoSpy) Snapshot(cb func([]byte, uint64, error)) {

if s.profileType == spy.ProfileCPU {
// stop the previous cycle of sample collection
pprof.StopCPUProfile()
custom_pprof.StopCPUProfile()
stopCPUProfile(s.sampleRate)
defer func() {
// start a new cycle of sample collection
if err := startCPUProfile(s.buf, s.sampleRate); err != nil {
Expand Down

0 comments on commit e0f799a

Please sign in to comment.