MCPcopy Create free account
hub / github.com/google/pprof / fetch

Function fetch

internal/driver/fetch.go:496–522  ·  view source on GitHub ↗

fetch fetches a profile from source, within the timeout specified, producing messages through the ui. It returns the profile and the url of the actual source of the profile for remote profiles.

(source string, duration, timeout time.Duration, ui plugin.UI, tr http.RoundTripper)

Source from the content-addressed store, hash-verified

494// producing messages through the ui. It returns the profile and the
495// url of the actual source of the profile for remote profiles.
496func fetch(source string, duration, timeout time.Duration, ui plugin.UI, tr http.RoundTripper) (p *profile.Profile, src string, err error) {
497 var f io.ReadCloser
498
499 // First determine whether the source is a file, if not, it will be treated as a URL.
500 if _, err = os.Stat(source); err == nil {
501 if isPerfFile(source) {
502 f, err = convertPerfData(source, ui)
503 } else {
504 f, err = os.Open(source)
505 }
506 } else {
507 sourceURL, timeout := adjustURL(source, duration, timeout)
508 if sourceURL != "" {
509 ui.Print("Fetching profile over HTTP from " + sourceURL)
510 if duration > 0 {
511 ui.Print(fmt.Sprintf("Please wait... (%v)", duration))
512 }
513 f, err = fetchURL(sourceURL, timeout, tr)
514 src = sourceURL
515 }
516 }
517 if err == nil {
518 defer f.Close()
519 p, err = profile.Parse(f)
520 }
521 return
522}
523
524// fetchURL fetches a profile from a URL using HTTP.
525func fetchURL(source string, timeout time.Duration, tr http.RoundTripper) (io.ReadCloser, error) {

Callers 2

grabProfileFunction · 0.85
sendURLFunction · 0.85

Calls 8

ParseFunction · 0.92
isPerfFileFunction · 0.85
convertPerfDataFunction · 0.85
adjustURLFunction · 0.85
fetchURLFunction · 0.85
OpenMethod · 0.65
PrintMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…