Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions internal/driver/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type source struct {
Symbolize string
HTTPHostport string
HTTPDisableBrowser bool
Comment string
Comments []string
AllFrames bool
}

Expand All @@ -52,7 +52,7 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
flagSymbolize := flag.String("symbolize", "", "Options for profile symbolization")
flagBuildID := flag.String("buildid", "", "Override build id for first mapping")
flagTimeout := flag.Int("timeout", -1, "Timeout in seconds for fetching a profile")
flagAddComment := flag.String("add_comment", "", "Free-form annotation to add to the profile")
flagAddComment := flag.StringList("add_comment", "", "Free-form annotation to add to the profile")
flagAllFrames := flag.Bool("all_frames", false, "Ignore drop_frames and keep_frames regexps")
// CPU profile options
flagSeconds := flag.Int("seconds", -1, "Length of time for dynamic profiles")
Expand Down Expand Up @@ -146,7 +146,7 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
Symbolize: *flagSymbolize,
HTTPHostport: *flagHTTP,
HTTPDisableBrowser: *flagNoBrowser,
Comment: *flagAddComment,
Comments: dropEmpty(*flagAddComment),
AllFrames: *flagAllFrames,
}

Expand Down
9 changes: 9 additions & 0 deletions internal/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func TestParse(t *testing.T) {
{"dot,addresses,flat,ignore=[X3]002,focus=[X1]000", "contention"},
{"dot,files,cum", "contention"},
{"comments,add_comment=some-comment", "cpu"},
{"comments,add_comment=comment1,add_comment=comment2", "cpu"},
{"comments", "heap"},
{"tags", "cpu"},
{"tags,tagignore=tag[13],tagfocus=key[12]", "cpu"},
Expand Down Expand Up @@ -251,6 +252,11 @@ func addFlags(f *testFlags, flags []string) {
f.ints[fields[0]] = i
} else {
f.strings[fields[0]] = fields[1]
// Add support for string lists
if f.stringLists == nil {
f.stringLists = make(map[string][]string)
}
f.stringLists[fields[0]] = append(f.stringLists[fields[0]], fields[1])
}
}
}
Expand Down Expand Up @@ -285,6 +291,9 @@ func solutionFilename(source string, f *testFlags) string {
if f.strings["unit"] != "minimum" {
name = addString(name, f, []string{"unit"})
}
if len(f.stringLists["add_comment"]) > 1 {
name = append(name, "multiple_comments")
}
return strings.Join(name, ".")
}

Expand Down
4 changes: 2 additions & 2 deletions internal/driver/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func fetchProfiles(s *source, o *plugin.Options) (*profile.Profile, error) {
p.RemoveUninteresting()
unsourceMappings(p)

if s.Comment != "" {
p.Comments = append(p.Comments, s.Comment)
if len(s.Comments) > 0 {
p.Comments = append(p.Comments, s.Comments...)
}

// Save a copy of the merged profile if there is at least one remote source.
Expand Down
2 changes: 2 additions & 0 deletions internal/driver/testdata/pprof.cpu.comments.multiple_comments
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
comment1
comment2
Loading