Skip to content

Machine-readable summary respects SUMMARY_TREND_STATS#5790

Open
Reranko05 wants to merge 2 commits intografana:masterfrom
Reranko05:fix-machine-readable-trend-stats
Open

Machine-readable summary respects SUMMARY_TREND_STATS#5790
Reranko05 wants to merge 2 commits intografana:masterfrom
Reranko05:fix-machine-readable-trend-stats

Conversation

@Reranko05
Copy link
Copy Markdown
Contributor

What?

This PR updates the machine-readable summary output to respect the values specified in SUMMARY_TREND_STATS.

When additional trend statistics such as p(99) are configured, they are currently computed but not included in the machine-readable output. This change preserves such values by falling back to a dynamic representation when unsupported fields are present.

Why?

The current implementation only supports a fixed set of trend statistics (avg, min, max, med, p(90), p(95)) via the generated TrendValues struct.

However, SUMMARY_TREND_STATS allows specifying additional percentiles like p(99). These values are silently dropped in the machine-readable output, leading to inconsistency between computed metrics and exported results.

This PR ensures that all computed trend statistics are preserved without modifying the generated schema.

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 #5736

@Reranko05 Reranko05 requested a review from a team as a code owner April 3, 2026 09:23
@Reranko05 Reranko05 requested review from ankur22 and mstoykov and removed request for a team April 3, 2026 09:23
@cla-assistant
Copy link
Copy Markdown

cla-assistant bot commented Apr 3, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Reranko05 Reranko05 temporarily deployed to azure-trusted-signing April 6, 2026 15:15 — with GitHub Actions Inactive
@Reranko05 Reranko05 temporarily deployed to azure-trusted-signing April 6, 2026 15:17 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

@ankur22 ankur22 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 the contribution and for digging into this — the issue is real and worth fixing.

After tracing through the code, the root cause is that the TrendValues struct in internal/lib/summary/machinereadable/ is code-generated from the grafana/k6-summary schema (via cog), and the schema itself only defines the six standard trend stats (avg, min, max, med, p(90), p(95)). The fix in machine_readable.go is working around the schema rather than fixing it at the source.

The right path forward is likely:

  1. Update the grafana/k6-summary schema to support additional/dynamic percentiles
  2. Regenerate the Go types via make generate
  3. Update machine_readable.go to map the new schema fields

Tagging @joanlopez as the original author of the machine-readable schema integration (#5338) to weigh in on the best way to extend the schema for dynamic percentiles.

We'll hold off on reviewing the code changes themselves until the schema question is settled.

})
}

func TestMachineReadable_IncludesP99(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add more tests and fix the implementation. We want the exact thigns set - so if you set that you jstu want avg, you should get this. Please add a few tests tahta are just 1,2,3 things and some of them are custome p sucha as p(12) or p(42)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions! Adding more targeted tests makes sense.

Since there’s also an ongoing discussion about addressing this at the schema level, I’ll wait for clarity on that direction before refining the implementation and expanding the test coverage accordingly.

@Reranko05
Copy link
Copy Markdown
Contributor Author

Hi @ankur22, thanks for the detailed explanation, that makes a lot of sense.

I see now that the issue originates from the generated schema rather than the output layer. I’ll wait for input on the schema changes before proceeding further.

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.

machine readable summary should respect SUMMARY_TREND_STATS

3 participants