-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apply additional command overrides based on report format #381
Changes from 1 commit
71e482e
5aacbbb
34449cc
28beb40
210573d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,13 @@ func generateRawReport(p *profile.Profile, cmd []string, vars variables, o *plug | |
// Identify units of numeric tags in profile. | ||
numLabelUnits := identifyNumLabelUnits(p, o.UI) | ||
|
||
vars = applyCommandOverrides(cmd, vars) | ||
// Get report output format | ||
c := pprofCommands[cmd[0]] | ||
if c == nil { | ||
panic("unexpected nil command") | ||
} | ||
|
||
vars = applyCommandOverrides(cmd, c.format, vars) | ||
|
||
// Delay focus after configuring report to get percentages on all samples. | ||
relative := vars["relative_percentages"].boolValue() | ||
|
@@ -78,10 +84,6 @@ func generateRawReport(p *profile.Profile, cmd []string, vars variables, o *plug | |
if err != nil { | ||
return nil, nil, err | ||
} | ||
c := pprofCommands[cmd[0]] | ||
if c == nil { | ||
panic("unexpected nil command") | ||
} | ||
ropt.OutputFormat = c.format | ||
if len(cmd) == 2 { | ||
s, err := regexp.Compile(cmd[1]) | ||
|
@@ -149,7 +151,7 @@ func generateReport(p *profile.Profile, cmd []string, vars variables, o *plugin. | |
return out.Close() | ||
} | ||
|
||
func applyCommandOverrides(cmd []string, v variables) variables { | ||
func applyCommandOverrides(cmd []string, outputFormat int, v variables) variables { | ||
trim, tagfilter, filter := v["trim"].boolValue(), true, true | ||
|
||
switch cmd[0] { | ||
|
@@ -176,6 +178,12 @@ func applyCommandOverrides(cmd []string, v variables) variables { | |
v.set("nodecount", "80") | ||
} | ||
} | ||
|
||
if outputFormat == report.Proto { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you keep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's now redundant. Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Side question: why does "peek" case resets the filter but not not the tagfilter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does seem odd. My best guess is that tagfilter was added later, and this is an oversight, but I'll look into the commit history to see if there's evidence for that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we should fix it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tag filtering was added after the peek command, (in this PR), which suggests to me this is an oversight. I've changed it in this PR. Let me know if you think it ought to be a separate PR. |
||
trim, tagfilter, filter = false, false, false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps for future unless there is an easy way to do it: it would be good to have a way to generate reports in the proto format keeping the filter. E.g. using the internal -flame command with a -tagfocus filter to upload a subset of the profile. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming that this could be done just by not setting Will experiment, then look into changing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be done later. |
||
v.set("addresses", "t") | ||
} | ||
|
||
if !trim { | ||
v.set("nodecount", "0") | ||
v.set("nodefraction", "0") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing the first argument to be just "cmd string"? It doesn't seem to be necessary to pass the array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.