Skip to content
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

CLI option to specify what stats to report for trend metrics #462

Merged
merged 5 commits into from Jan 17, 2018
Merged

CLI option to specify what stats to report for trend metrics #462

merged 5 commits into from Jan 17, 2018

Conversation

antekresic
Copy link
Contributor

Add CLI option to specify what stats to report for trend metrics to stdout summary

Closes #450 & #408

@codecov-io
Copy link

codecov-io commented Jan 15, 2018

Codecov Report

Merging #462 into master will increase coverage by 0.08%.
The diff coverage is 69.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #462      +/-   ##
==========================================
+ Coverage   62.05%   62.13%   +0.08%     
==========================================
  Files          93       93              
  Lines        6580     6619      +39     
==========================================
+ Hits         4083     4113      +30     
- Misses       2271     2278       +7     
- Partials      226      228       +2
Impacted Files Coverage Δ
cmd/run.go 2.4% <0%> (-0.02%) ⬇️
lib/options.go 59.13% <0%> (-1.3%) ⬇️
cmd/options.go 33.89% <14.28%> (-2.65%) ⬇️
ui/summary.go 15.34% <92.85%> (+15.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 747e70e...c83e72a. Read the comment docs.

@robingustafsson
Copy link
Member

Great stuff @antekresic! Will review this tomorrow morning.

Copy link
Member

@robingustafsson robingustafsson left a comment

Choose a reason for hiding this comment

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

@antekresic Looks good, just some minor UX things I think we should improve.

cmd/options.go Outdated
@@ -46,6 +47,7 @@ func optionFlagSet() *pflag.FlagSet {
flags.Bool("no-connection-reuse", false, "don't reuse connections between iterations")
flags.BoolP("throw", "w", false, "throw warnings (like failed http requests) as errors")
flags.StringSlice("blacklist-ip", nil, "blacklist an `ip range` from being called")
flags.StringSlice("summary-trend-stats", nil, "define `stats` for trend metrics (response times)")
Copy link
Member

Choose a reason for hiding this comment

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

I think we should give an example of the format for the option. Something like: define 'stats' for trend metrics (response times), one or more as 'avg,p(95),...'.

ui/summary.go Outdated
@@ -55,6 +55,62 @@ type TrendColumn struct {
Get func(s *stats.TrendSink) float64
}

// VerifyTrendColumnStat checks if stat is a valid trend column
func VerifyTrendColumnStat(stat string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

I think VerifyTrendColumnStat should return bool, error (or just error perhaps?) and then in cmd/options.go when looping through the stats we print any errors returned ("stat 1 (''): empty string", "stat 2 ('p("SomeString")'): percentile stat accepts a number not 'SomeString'" etc).

ui/summary.go Outdated
}
}

func generatePercentileTrendColumn(stat string) func(s *stats.TrendSink) float64 {
Copy link
Member

Choose a reason for hiding this comment

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

Same as for VerifyTrendColumnStat, I think we should return func(s *stats.TrendSink) float64, error with an error messages that helps the user understand what they did wrong, things like:

  • "stat 1 (''): empty string"
  • "stat 2 ('p("SomeString")'): percentile stat accepts a number not 'SomeString'" etc).

cmd/options.go Outdated
return opts, err
}
for _, s := range trendStatStrings {
if ui.VerifyTrendColumnStat(s) {
Copy link
Member

Choose a reason for hiding this comment

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

See other comments on printing stats parsing errors here for the user to see.

@antekresic
Copy link
Contributor Author

@robingustafsson thanks for the feedback!

Updated the code to match the comments.

@robingustafsson
Copy link
Member

robingustafsson commented Jan 17, 2018

LGTM, merging. Thanks @antekresic!

@robingustafsson robingustafsson merged commit 1287709 into grafana:master Jan 17, 2018
@antekresic antekresic deleted the feature/cli-trend-stats-option branch January 17, 2018 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants