Skip to content

Collect usage about used js modules and outputs #3525

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

Merged
merged 7 commits into from
Jan 10, 2024
Merged

Conversation

codebien
Copy link
Contributor

@codebien codebien commented Jan 8, 2024

What?

It collects usage stats about the js modules and outputs used in the test. It collects only the names of the used modules or outputs that are built-in in k6 binary.

Why?

It will help to refine our prioritization method based on more objective and data-driven decisions regarding a feature or a breaking change to introduce.

Updates #2952

@codebien codebien self-assigned this Jan 8, 2024
@codebien codebien force-pushed the usage-stats branch 2 times, most recently from eab8e60 to 8c742d3 Compare January 8, 2024 18:06
We need to collect data about what is the usage of the builtin JS
modules and outputs.
We only collect the names of the used modules and outputs that are
builtin in k6. We don't collect any data about extensions or other
private modules.
@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2024

Codecov Report

Attention: 44 lines in your changes are missing coverage. Please review.

Comparison is base (77bb9ae) 72.55% compared to head (b9f797e) 72.53%.
Report is 1 commits behind head on master.

❗ Current head b9f797e differs from pull request most recent head 2786005. Consider uploading reports for the commit 2786005 to get more accurate results

Files Patch % Lines
cmd/builtin_output_gen.go 16.66% 19 Missing and 1 partial ⚠️
cmd/report.go 63.41% 15 Missing ⚠️
js/modules/resolution.go 0.00% 5 Missing ⚠️
cmd/outputs.go 62.50% 2 Missing and 1 partial ⚠️
cmd/run.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3525      +/-   ##
==========================================
- Coverage   72.55%   72.53%   -0.02%     
==========================================
  Files         276      278       +2     
  Lines       20840    20891      +51     
==========================================
+ Hits        15120    15154      +34     
- Misses       4758     4774      +16     
- Partials      962      963       +1     
Flag Coverage Δ
ubuntu 72.47% <46.98%> (-0.02%) ⬇️
windows 72.38% <46.98%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codebien codebien marked this pull request as ready for review January 9, 2024 08:59
@codebien codebien requested a review from a team as a code owner January 9, 2024 08:59
@codebien codebien requested review from olegbespalov and joanlopez and removed request for a team January 9, 2024 08:59
for _, module := range importedModules {
// Exclude JS modules extensions to prevent to leak
// any user's custom extensions
if strings.HasPrefix(module, "k6/x") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would make sense to keep a list, even if manually, here to also get usage stats for the extensions that we do own? At least until we find a better way to do so.

From the product perspective, I guess it could make lot of sense to know what extensions worth some attention and which ones not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

xk6-client-tracing
xk6-notification
xk6-disruptor
xk6-sql
xk6-exec
xk6-kubernetes
xk6-ssh
xk6-loki
xk6-dashboard
xk6-output-influxdb
xk6-output-kafka
xk6-output-timescaledb

This is the list of extensions marked as official here: https://k6.io/docs/extensions/get-started/explore. None of them sounds so relevant at the moment to justify the risk of having this logic. Let me know if you have a different opinion.

Copy link
Contributor

@joanlopez joanlopez Jan 9, 2024

Choose a reason for hiding this comment

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

Okay! Sounds fair! Thanks!

joanlopez
joanlopez previously approved these changes Jan 9, 2024
Copy link
Contributor

@joanlopez joanlopez left a comment

Choose a reason for hiding this comment

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

I left a few comments, but none of them is blocking, so it looks good enough to be merged to me! 👍🏻 Thanks!

@codebien codebien requested a review from joanlopez January 9, 2024 16:51
@codebien
Copy link
Contributor Author

codebien commented Jan 9, 2024

@mstoykov as you are working on refactoring some closer areas, it would be good to get a review from you as well.

olegbespalov
olegbespalov previously approved these changes Jan 9, 2024
Copy link
Contributor

@olegbespalov olegbespalov left a comment

Choose a reason for hiding this comment

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

LGTM, with a minor non-blocking nit.

cmd/report.go Outdated
}

builtinOutputs := map[string]bool{
"cloud": true, "csv": true, "experimental-prometheus-rw": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: These output keys (cloud, csv, etc.) come from the map https://github.com/grafana/k6/blob/master/cmd/outputs.go#L26-L47. It's better to extract this as the variable/method and use it here. That way, we protect the future maintainers/contributors from forgetting to update this place.

Some alternatives (e.g., using const) could also be considered, but the main idea is to couple the places through the code, not the string 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.

Added a new proposal for addressing this in the last commits

mstoykov
mstoykov previously approved these changes Jan 10, 2024
Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

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

LGTM! I did check commit by commit and did some 👍 on some comments that I agreed more strongly with 😅

My only concern around pushing every imported module has been adressed so I am happy.

I guess (as future improvement) we can also send whether and how many k6/x/ modules were imported? Maybe even how many source modules were imported 🤷 . Just as a number.

Also, I guess at some point we might want to have a "whitelist" of `k6/x/' modules that are still reported, but that definitely should be done later and with more discussion.

@codebien codebien dismissed stale reviews from mstoykov and olegbespalov via 21cc9ef January 10, 2024 10:58
@codebien codebien added this to the v0.49.0 milestone Jan 10, 2024
@codebien codebien added the documentation-needed A PR which will need a separate PR for documentation label Jan 10, 2024
@codebien codebien merged commit a5227b9 into master Jan 10, 2024
@codebien codebien deleted the usage-stats branch January 10, 2024 17:44
@olegbespalov olegbespalov mentioned this pull request Jan 11, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation-needed A PR which will need a separate PR for documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants