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

Configurable Trend stats #64

Merged
merged 1 commit into from Dec 1, 2022
Merged

Configurable Trend stats #64

merged 1 commit into from Dec 1, 2022

Conversation

codebien
Copy link
Contributor

No description provided.

@codebien codebien marked this pull request as ready for review November 29, 2022 13:19
@codebien codebien requested a review from na-- November 29, 2022 13:21
Copy link
Member

@oleiade oleiade left a comment

Choose a reason for hiding this comment

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

Some tiny comments, but looks really good overall, great work 👍🏻

// TODO: remove the assumption that Name label is the first.
func sortByNameLabel(s []*prompb.TimeSeries) {
sort.Slice(s, func(i, j int) bool {
return s[i].Labels[0].Value <= s[j].Labels[0].Value
Copy link
Member

Choose a reason for hiding this comment

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

Beotian question, but won't that break if Labels is empty?

@@ -76,6 +85,50 @@ func (o *Output) Stop() error {
return nil
}

// setTrendStatsResolver sets the resolver for the Trend stats.
//
// TODO: refactor, the code can be improved
Copy link
Member

Choose a reason for hiding this comment

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

I would find the TODO comment more valuable to our future selves if it mentioned how it could be improved 😄

//
// TODO: maybe decoupling mapping from the stat resolver keys?
if strings.HasPrefix(statKey, "p(") {
statKey = stat[2 : len(statKey)-1] // trim the parenthesis
Copy link
Member

Choose a reason for hiding this comment

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

I believe you could use strings.TrimPrefix here instead 👍🏻

assert.Len(t, o.trendStatsResolver, len(tt.expResolverKeys))
assert.ElementsMatch(t, tt.expResolverKeys, func() []string {
var keys []string
for statKey := range o.trendStatsResolver {
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 you could use copy here instead. That would make the code even shorter?

@codebien
Copy link
Contributor Author

codebien commented Dec 1, 2022

@oleiade thanks, your request changes are internal changes, so I'm going to merge then address them in a dedicated PR.

@oleiade
Copy link
Member

oleiade commented Dec 1, 2022

@codebien makes sense 🙇🏻

Comment on lines +24 to +25
var defaultTrendStats = []string{"p(99)"}

Copy link
Contributor Author

@codebien codebien Dec 1, 2022

Choose a reason for hiding this comment

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

@na-- @oleiade it would be good to get an opinion on this. I took this decision autonomously, but you could have a different opinion.

I'm going to merge but if you would like to change it then drop a comment.

Copy link
Member

Choose a reason for hiding this comment

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

For me it makes some sense that the default value should match whatever the value of --summary-trend-stats in k6 is (default or user-supplied). But I can also see why that might be a bit too expensive to maintain by default... So, I don't have a strong opinion either way, sorry.

@codebien codebien merged commit 7de5db5 into main Dec 1, 2022
@codebien codebien deleted the stats-option branch December 1, 2022 11:35
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