Skip to content

Summary: Display thresholds values even when not in summaryTrendStats #4698

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joanlopez
Copy link
Contributor

What?

Makes it possible to display threshold values (since #4089) even when the aggregation on the thresholds expression (e.g. p(99.5)) isn't included as part of options.summaryTrendStats.

Why?

Now those values aren't displayed (instead, it prints undefined, which I would consider a bug), because we're not calculating values for aggregations other than options.summaryTrendStats.

Alternatively, we could just omit these lines from the summary, but I think these are valuable information for the user, and it's aligned with the goal of the revamped summary.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

Closes #4695

@joanlopez joanlopez requested review from oleiade and codebien April 16, 2025 12:01
@joanlopez joanlopez self-assigned this Apr 16, 2025
@joanlopez joanlopez requested a review from a team as a code owner April 16, 2025 12:01
oleiade
oleiade previously approved these changes Apr 16, 2025
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.

🚀 LGTM on my end 🚀

(I believe removing the logs 👇🏻 would fix the tests 🙇🏻 )

Comment on lines 947 to 949
console.log(info);
console.log(metric.values);

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
console.log(info);
console.log(metric.values);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, sorry, I forgot one extra force-push before opening the PR haha 😅

Copy link
Member

Choose a reason for hiding this comment

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

Hehe no worries 😄 Been there, did that, many times 🫶

@@ -839,7 +839,7 @@ function renderThresholdResults(
: formatter.decorate(failMark, 'red');

const sourceText = formatter.decorate(
`'${threshold.source}'`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't directly related, but it's so small that I prefer to add it as part of this PR. It's not a huge deal, but I think it's nice if we trim the threshold's source before displaying it in the summary.


var percentileThresholdSourceRe = regexp.MustCompile(`^p\((\d+(?:\.\d+)?)\)\s*([<>=])`)

func extractPercentileThresholdSource(source string) (agg string, percentile float64, isPercentile bool) {
Copy link
Contributor Author

@joanlopez joanlopez Apr 16, 2025

Choose a reason for hiding this comment

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

I know this isn't ideal, but I cannot see any alternative to this that doesn't imply exposing more things from the metrics package and type (like the parsed expression and related code), and I think that isn't ideal as well because we do plan to do some refactors there soon-ish.

So, that's why I suggest to go with this, which should be fine as I don't expect the thresholds format to change anytime soon, especially now with v1.0 and the versioning strategy and guarantees.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A percentile for not default values is undefined in the report
2 participants