-
Notifications
You must be signed in to change notification settings - Fork 223
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
Add initial xk6 documentation #346
Conversation
[`context.Context`](https://golang.org/pkg/context/#Context) instance as the first argument. | ||
This context is used throughout the k6 codebase and contains embedded objects | ||
which can be extracted to access the | ||
[`goja.Runtime`](https://pkg.go.dev/github.com/dop251/goja#Runtime) for a | ||
particular VU, and to get more information about the test in progress. | ||
Take a look at | ||
[`common.GetRuntime()`](https://pkg.go.dev/go.k6.io/[email protected]/js/common#GetRuntime), | ||
[`lib.GetState()`](https://pkg.go.dev/go.k6.io/[email protected]/lib#GetState) and | ||
[`lib.GetExecutionState()`](https://pkg.go.dev/go.k6.io/[email protected]/lib#GetExecutionState). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might drastically change depending on the changes around grafana/k6#1802, so maybe we should first decide on whether we will do any of the changes proposed there before we document stuff we might break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, but that will change in v0.34.0, right? Since we have versioned docs now, I think it's fine to mention the current API here.
EDIT: Actually, only JS API docs are versioned, so guess not 😞
There's a version of the docs published here: https://mdr-ci.staging.k6.io/docs/refs/pull/346/merge It will be deleted automatically in 30 days. |
--- | ||
|
||
Traditionally, extending k6 with custom functionality that isn't available in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Docs, I'd remove the whole historical intro.
Additionally, I would add a label about version support like in Scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hhmm I think explaining the issues extensions were meant to solve serves as a good introduction for why someone might want to use them. Starting from "What are k6 extensions?" would be too abrupt IMO. Unless you have another suggestion for the intro :)
And sure, I'll add a more prominent version support notice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the version support notice in a89ceda.
Let me know about the intro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
k6 extensions are standalone Go projects that call k6 APIs but are otherwise | ||
unrestricted in their functionality. This provides the freedom for extension authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the beginning, we should focus on describing the benefits of this feature.
Having the ability to experiment with extensions that can become part of the feature is a "secondary" benefit, at least for the end user, imho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly a definition paragraph, but what other benefits would you mention?
The historical introduction explains the issues extensions are meant to solve for end users, so I'm not sure what else to mention here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also about https://github.com/grafana/k6-docs/pull/346/files#r661994675
My view here is that the intro and the what is k6 extension
and what is xk6
sections are a little verbose. For the Intro sections, I rather going more direct to the point in Docs and extend the historical in the blog post.
I like Extension Types
section, but perhaps the Getting Started
section could be better connected with the intro.
The article is very good. If you want, I can give it a try in the future for a new proposal of the intro.
that output implementations can use which handles bufferring and periodic | ||
flushing in a thread-safe way. | ||
For usage examples see the [`statsd` output](https://github.com/k6io/k6/blob/v0.33.0/output/statsd/output.go#L55). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an example of an extension instead of the k6 codebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hhmm we already have a lot of external examples and I thought it would be good to link to an internal module for once, to showcase that extensions and internal modules are near identical in implementation.
Besides, I'm not sure there are any extensions that actually use this yet, since it hasn't been documented ;)
|
||
A few things to keep in mind when writing a new extension: | ||
<!-- TODO: Better structure this list? --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. It is a bit hard to follow.
I wonder if. it could be good to show snippets of relevant extension code to distinguish between the various sections and make the whole section more pleasant to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, could be... In #169 we kind of agreed to not show any Go code here, but we could split this section into "Writing a new JS extension" (linking to the existing article) and "Writing a new Output extension", and do a small walkthrough with some snippets of code instead of a complete extension like in the article.
I'll think about it, and more opinions are welcome. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ppcano Take a look at the latest changes. It kind of breaks the no-code rule, but I really don't think we can document writing an extension without showing code... :)
It's a good start @imiric. I have added a few comments about the first impressions, take the feedback as suggestions or to think about. |
Maybe resolves #346 (comment) ? Still needs a bit of work.
src/data/markdown/translated-guides/en/07 Misc/05 k6 Extensions.md
Outdated
Show resolved
Hide resolved
src/data/markdown/translated-guides/en/07 Misc/05 k6 Extensions.md
Outdated
Show resolved
Hide resolved
This is ready for review again. @na-- @mstoykov @ppcano 🙏 @simskij I mentioned the supported modes of execution in 56b3702, but can you clarify what you meant by "considerations and drawbacks"? I'm not sure what else to mention besides whether custom k6 binaries are supported or not. Suggestions welcome :) |
is on our roadmap. However, it is possible to run a binary built with xk6 and send | ||
metrics produced by extension code to the Cloud using the | ||
[`cloud` output](https://k6.io/docs/results-visualization/cloud/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add some kind of outro here, relevant links, etc.?
src/data/markdown/translated-guides/en/07 Misc/05 k6 Extensions.md
Outdated
Show resolved
Hide resolved
src/data/markdown/translated-guides/en/07 Misc/05 k6 Extensions.md
Outdated
Show resolved
Hide resolved
src/data/markdown/translated-guides/en/07 Misc/05 k6 Extensions.md
Outdated
Show resolved
Hide resolved
This briefly mentions common.Bind() and shows a more advanced module example using the new IsModuleV2 approach. Should resolve #346 (comment)
This briefly mentions common.Bind() and shows a more advanced module example using the new IsModuleV2 approach. Should resolve #346 (comment)
@na-- @mstoykov Any blocker here? I suggest merging it and iterating it next. We want to migrate this content to the Extensions section and will require some minor changes later. |
@imiric Does |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, we'd just need to update some things when v0.35.0 is released. @ppcano, feel free to merge this
Closes #169