Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: nicolevanderhoeven <[email protected]>
Co-authored-by: Mihail Stoykov <[email protected]>
  • Loading branch information
3 people authored Mar 11, 2021
1 parent bd237b4 commit 9794479
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions release notes/v0.31.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ In addition to this, it is now possible to implement custom k6 output extensions

Writing output extensions is done very similarly to [how JS module extensions are currently written](https://k6.io/blog/extending-k6-with-xk6), though instead of calling `js/modules.Register()`, you should implement the new [`Output` interface](https://github.com/loadimpact/k6/blob/2036baeaa83d76ce17aae95fef7e78e3ef24c735/output/types.go#L51-L74) and call [`output.RegisterExtension()`](https://github.com/loadimpact/k6/blob/2036baeaa83d76ce17aae95fef7e78e3ef24c735/output/extensions.go#L47) with your constructor.

We are working on the proper documentation for this, as well as the overdue xk6 documentation about JS extensions, so keep a lookout on https://k6.io/docs/ .
We are working on the proper documentation for this, as well as the overdue xk6 documentation about JS extensions, so keep a lookout for those on https://k6.io/docs/ .


### Marking requests as failed ([#1856](https://github.com/loadimpact/k6/pull/1856))

It's now possible to declare expected HTTP response statuses for either the entire test or for individual HTTP requests, and k6 will emit a new `http_req_failed` metric as well as tag HTTP metrics with `expected_response: <bool>`.
It's now possible to declare expected HTTP response statuses for either the entire test or for individual HTTP requests, and k6 will emit a new `http_req_failed` metric as well as tag HTTP metrics with `expected_response: <bool>`. By default, k6 will now fail requests that return HTTP 4xx/5xx response codes.

For example:

Expand All @@ -41,13 +41,13 @@ http_req_duration..............: avg=204.57ms min=203.31ms med=204.57ms max=205.
http_req_failed................: 50.00% ✓ 1 ✗ 1
```

Note the new `http_req_duration` sub-metric for expected responses only, and the new `http_req_failed` `Rate` metric. This new new metric and metric tag have many potential use cases, though one of the most important ones is the ability to set better [thresholds](https://k6.io/docs/using-k6/thresholds). For example:
Note the new `http_req_duration` sub-metric for expected responses only, and the new `http_req_failed` `Rate` metric. This new metric and metric tag have many potential use cases, though one of the most important ones is the ability to set better [thresholds](https://k6.io/docs/using-k6/thresholds). For example:
- `'http_req_failed': ['rate<0.1']`, i.e. fail the test if more than 10% of requests fail.
- `'http_req_duration{expected_response:true}': ['p(95)<300', 'p(99.9)<500']` - fail the test if the the 95th percentile HTTP request duration is above 300ms or the 99.9th percentile is above 500ms; specifying `expected_response:true` here may be important, because a lot of times failed requests may return more quickly than normal ones, thus skewing the results and wrongly satisfying the threshold.

If the response callback is not specified, the default expected statuses will be `{min: 200, max: 399}`. The previous behavior of not emitting anything can be achieved by setting the callback to `null`, i.e. `http.setResponseCallback(null)`. Additionally the `expected_response` tag can be disabled by removing it from the default list of system tags, e.g. `k6 run --system-tags 'proto,subproto,status,method,url,name,group,check,error,error_code,tls_version,scenario,service'`.

The `http.setResponseCallback()` is meant to allow arbitrary JS functions to process responses, but for now only the `http.expectedStatuses()` callback is supported.
The `http.setResponseCallback()` is planned to allow arbitrary JS functions to process responses in the future, but for now only the `http.expectedStatuses()` callback is supported.


## Other enhancements and UX improvements
Expand Down

0 comments on commit 9794479

Please sign in to comment.