-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove the JS runtime from threshold calculations #1443
Comments
#1526 demonstrates that we should probably emit a warning for thresholds that don't correspond to a system or custom metric |
Not sure if this should be here or in #1441, or even in #1313, but in the next version of the threshold submetric definition syntax, we should likely ditch the colon for equality and use |
Another benefit for having the thresholds be defined as an array instead of a map, besides distinguishing between the old and new format for specifying them, is that when we have them ordered, we can more easily implement the custom exit code per threshold: #680 (comment) |
For the reference, and to support my own understanding, here's a little BNF definition of the proposed threshold expression format I tried to extract from the existing syntax, as well as the proposed one:
N.B I followed the BNF definition syntax presented in Crafting Interpreters, as I find it both more readable/understandable and easy to manipulate (considering we're not intending to produce an actual parser out of it). |
Here's a little update on the context and scope of this issue posted by @na-- in #2251 for future reference:
|
We had initially planned for the refactor to ship with |
The reframed scope as discussed in the comments is implemented as of #2400. The initial scope is still something we'd like to achieve as a longer-term goal. Because the issue is already so old, and there have been numerous iterations on this, we prefer to close this issue in favor of a new one as soon as the initial scope gets prioritized again. |
This issue aims to bring 80% of the benefits of #1441 while doing only 20% of the work.
The ideal future state of thresholds is defined in #1441 .
This issue addresses only the most important problem of thresholds - removing the js runtime. This issue doesn't introduce the new concepts from the original specification.
Motivation
This issue addresses the following issues (two first issues from the original spec).
Quick overview of the new thresholds
Yes, it's the old format, but the threshold expression is no longer executed in a JS runtime. Instead, it's parsed and executed in go.
Parsing
(copied from the original spec).
To provide consistency between local and cloud execution, threshold parsing should happen only in k6.
When the test is executed in the cloud, k6 should parse and provide the agreed-upon format to the k6-cloud backend.
The proposed format is
Validation
Thresholds should be validated and abort the execution in case of validation errors.
metric_name
validation.The metric name must be one of:
http_req_duration
, etc)successful_logins
, etc).When k6 detects a threshold on a metric that's not defined, the test should be aborted.
The init context must be executed to find user-defined metrics. Metric defined in branches are no longer supported
filters
validationExample of filtered-threshold
Should be parsed as:
Spaces between left-hand, operator and right-hand are allowed but should be stripped away by the parser.
left-hand
should follow the ECMAScript variable-name restrictions - https://mathiasbynens.be/notes/javascript-identifiersor more strict restrictions (left for the implementer to decide).
right-hand-type
can only be a string at the moment.conditions
array validationEach threshold can have multiple conditions. Conditions can't be combined. Each condition must be a separate string.
Invalid
Valid
"conditions" array has a similar restriction as "filters" and should be parsed in a similar way.
aggregation method
validationInvalid aggregation method should raise an exception and abort the test execution.
The
aggregation methods
available for Metric types are specified below.Counter
count
(number of times the.add("whatever")
has been called )sum
(sum of numeric values passed to.add(5)
)rate
(count/s)Gauge
last
min
max
value
(undocumented alias for last)Rate
rate
Trend
min
mean
avg
max
p(N)
Operators
>
>=
<
<=
==
===
!=
The text was updated successfully, but these errors were encountered: