Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

Flamegraph options #50

Merged
merged 6 commits into from
Nov 10, 2016
Merged

Flamegraph options #50

merged 6 commits into from
Nov 10, 2016

Conversation

tgrk
Copy link
Contributor

@tgrk tgrk commented Oct 30, 2016

Add few additional CLI argument to call FlameGraph tool.

Width int64 `long:"width" default:"1200" description:"Generated graph width"`
Hash bool `long:"hash" description:"Colors are keyed by function name hash"`
Colors string `long:"colors" default:"" description:"set color palette. choices are: hot (default), mem, io, wakeup, chain, java, js, perl, red, green, blue, aqua, yellow, purple, orange"`
ColorPalette bool `long:"cp" description:"Use consistent palette (palette.map)"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be ConsistentPalette instead of ColorPalette

}
}
if !isValidColors {
return fmt.Errorf("FlameGraph unknown colors '%s'", opts.OutputOpts.Colors)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this error message could include the list of valid options


--width= Generated graph width (default: 1200)
--hash Colors are keyed by function name hash
--colors= set color palette. choices are: hot (default), mem, io, wakeup, chain, java,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set color palette. Valid choices are:

return fmt.Errorf("FlameGraph title should not be empty")
}
if opts.OutputOpts.Width < 1200 {
return fmt.Errorf("FlameGraph miminal graph with is 1 200 pixels")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typos:

  • 1200, not 1 200
  • width, not with

Title string `long:"title" default:"Flame Graph" description:"Graph title to display in the output file"`
Width int64 `long:"width" default:"1200" description:"Generated graph width"`
Hash bool `long:"hash" description:"Colors are keyed by function name hash"`
Colors string `long:"colors" default:"" description:"set color palette. choices are: hot (default), mem, io, wakeup, chain, java, js, perl, red, green, blue, aqua, yellow, purple, orange"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this option would make more sense to me as ColorPalette or Palette instead of Colors.
it's awkward to use singular blue, red, etc. with the plural colors. the singular color doesn't really make sense because "wakeup" isn't a color.

that said, since the upstream vendor (FlameGraph) uses this as an argument, i could be convinced that matching the arguments is more important.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I think that consistency is way to go even that there is a better way/name etc.

}
}
if !isValidColors {
return fmt.Errorf("FlameGraph unknown colors '%s'", opts.OutputOpts.Colors)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use %q instead of %s to quote user input

js, perl, red, green, blue, aqua, yellow, purple, orange
--hash Graph colors are keyed by function name hash
--cp Graph use consistent palette (palette.map)
--inverted Graph icicle graph
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reword to avoid "graph" appearing twice. e.g. Generate an icicle graph

@coveralls
Copy link

coveralls commented Nov 2, 2016

Coverage Status

Coverage increased (+0.1%) to 94.62% when pulling bca3f67 on tgrk:flamegraph_options into 2ebde06 on uber:master.

Copy link
Contributor

@prashantv prashantv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @tgrk

Can you sign the Uber CLA as well?


// extra FlameGraph options
if opts.OutputOpts.Title == "" {
return fmt.Errorf("FlameGraph title should not be empty")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: errors should be lowercase,
https://github.com/golang/go/wiki/CodeReviewComments#error-strings

same for all errors added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK my idea here was to use name of the utility called. I am going to change all occurrences to lower-case flame graph.

return fmt.Errorf("FlameGraph miminal graph width is 1200 pixels")
}
if opts.OutputOpts.Colors != "" {
var validColors = []string{"hot", "mem", "io", "wakeup", "chain", "java", "js", "perl", "red",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this becomes a lot simpler with a switch, and as a bonus, it's also faster.

switch opts.OutputOpts.Colors {
case "hot", "mem", "io", [...]:
  // valid
default:
  // return error
}

if opts.OutputOpts.Title == "" {
return fmt.Errorf("FlameGraph title should not be empty")
}
if opts.OutputOpts.Width < 1200 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this enforced by the flame graph script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO, my bad... Thanks for pointing out.

@coveralls
Copy link

coveralls commented Nov 9, 2016

Coverage Status

Coverage increased (+0.3%) to 94.839% when pulling a325c5d on tgrk:flamegraph_options into 2ebde06 on uber:master.

Copy link
Contributor

@prashantv prashantv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all my comments, this looks good to me!

@prashantv prashantv merged commit 5decf9e into uber-archive:master Nov 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants