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

Function fetchProfiles

internal/driver/fetch.go:41–127  ·  view source on GitHub ↗

fetchProfiles fetches and symbolizes the profiles specified by s. It will merge all the profiles it is able to retrieve, even if there are some failures. It will return an error if it is unable to fetch any profiles.

(s *source, o *plugin.Options)

Source from the content-addressed store, hash-verified

39// there are some failures. It will return an error if it is unable to
40// fetch any profiles.
41func fetchProfiles(s *source, o *plugin.Options) (*profile.Profile, error) {
42 sources := make([]profileSource, 0, len(s.Sources))
43 for _, src := range s.Sources {
44 sources = append(sources, profileSource{
45 addr: src,
46 source: s,
47 })
48 }
49
50 bases := make([]profileSource, 0, len(s.Base))
51 for _, src := range s.Base {
52 bases = append(bases, profileSource{
53 addr: src,
54 source: s,
55 })
56 }
57
58 p, pbase, m, mbase, save, err := grabSourcesAndBases(sources, bases, o.Fetch, o.Obj, o.UI, o.HTTPTransport)
59 if err != nil {
60 return nil, err
61 }
62
63 if pbase != nil {
64 if s.DiffBase {
65 pbase.SetLabel("pprof::base", []string{"true"})
66 }
67 if s.Normalize {
68 err := p.Normalize(pbase)
69 if err != nil {
70 return nil, err
71 }
72 }
73 pbase.Scale(-1)
74 p, m, err = combineProfiles([]*profile.Profile{p, pbase}, []plugin.MappingSources{m, mbase})
75 if err != nil {
76 return nil, err
77 }
78 }
79
80 if s.AllFrames {
81 p.DropFrames = ""
82 p.KeepFrames = ""
83 }
84
85 // Symbolize the merged profile.
86 if err := o.Sym.Symbolize(s.Symbolize, m, p); err != nil {
87 return nil, err
88 }
89 p.RemoveUninteresting()
90 unsourceMappings(p)
91
92 if s.Comment != "" {
93 p.Comments = append(p.Comments, s.Comment)
94 }
95
96 // Save a copy of the merged profile if there is at least one remote source.
97 if save {
98 dir, err := setTmpDir(o.UI)

Callers 5

TestFetchWithBaseFunction · 0.85
TestHTTPSInsecureFunction · 0.85
PProfFunction · 0.85
TestSymbolzAfterMergeFunction · 0.85

Calls 14

grabSourcesAndBasesFunction · 0.85
combineProfilesFunction · 0.85
unsourceMappingsFunction · 0.85
setTmpDirFunction · 0.85
newTempFileFunction · 0.85
SetLabelMethod · 0.80
NormalizeMethod · 0.80
ScaleMethod · 0.80
RemoveUninterestingMethod · 0.80
WriteMethod · 0.80
CheckValidMethod · 0.80
SymbolizeMethod · 0.65

Tested by 4

TestFetchWithBaseFunction · 0.68
TestHTTPSInsecureFunction · 0.68
TestSymbolzAfterMergeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…