Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions internal/agent/profiler/go_pprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,17 @@ func (p *GoPprofProfiler) Invoke(job *job.ProfilingJob) (error, time.Duration) {
func (p *goPprofManager) heapProfile(job *job.ProfilingJob, port string, fileName string) error {
var out bytes.Buffer
var stderr bytes.Buffer
targetURL := fmt.Sprintf(
"http://127.0.0.1:%s/debug/pprof/%s?seconds=%d",
port, "heap", int(job.Interval.Seconds()),
)
// A heap profile is a snapshot of what the process is holding right now, so
// it takes no duration. Passing ?seconds= makes Go return a DELTA over that
// window instead — it samples, waits, samples again and subtracts — which
// nets to nothing whenever the heap is steady. That is how a 30s "heap
// profile" of a healthy service arrives as `Total samples = 0` with an
// empty flamegraph.
//
// ?gc=1 runs a collection first so the snapshot describes live memory
// rather than whatever the last GC cycle happened to leave behind; without
// it a process that has not GC'd yet reports nothing at all.
Comment thread
blue4209211 marked this conversation as resolved.
targetURL := fmt.Sprintf("http://127.0.0.1:%s/debug/pprof/heap?gc=1", port)
// for local testing
// cmd := exec.Command(
// "curl", targetURL, "-o", fileName,
Expand Down
Loading