From d034ec8eefe43cd91ee7300769f45b332034b26b Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Fri, 17 Nov 2023 09:25:57 +0100 Subject: [PATCH] Option --profiling-enabled --- .../next/using-k6/k6-options/reference.md | 139 ++++++++++-------- 1 file changed, 78 insertions(+), 61 deletions(-) diff --git a/docs/sources/next/using-k6/k6-options/reference.md b/docs/sources/next/using-k6/k6-options/reference.md index ac9003834b..01b8da92ef 100644 --- a/docs/sources/next/using-k6/k6-options/reference.md +++ b/docs/sources/next/using-k6/k6-options/reference.md @@ -15,65 +15,66 @@ If an option is defined in multiple places, k6 chooses the value from the highes Each option has its own detailed reference in a separate section. -| Option | Description | -| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| [Address](#address) | Address of the REST API server | -| [Batch](#batch) | Max number of simultaneous connections of a `http.batch()` call | -| [Batch per host](#batch-per-host) | Max number of simultaneous connections of a `http.batch()` call for a host | -| [Blacklist IP](#blacklist-ip) | Blacklist IP ranges from being called | -| [Block hostnames](#block-hostnames) | Block any requests to specific hostnames | -| [Compatibility mode](#compatibility-mode) | Support running scripts with different ECMAScript modes | -| [Config](#config) | Specify the config file in JSON format to read the options values | -| [Console output](#console-output) | Redirects logs logged by `console` methods to the provided output file | -| [Discard response bodies](#discard-response-bodies) | Specify whether response bodies should be discarded | -| [DNS](#dns) | Configure DNS resolution behavior | +| Option | Description | +| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [Address](#address) | Address of the REST API server | +| [Batch](#batch) | Max number of simultaneous connections of a `http.batch()` call | +| [Batch per host](#batch-per-host) | Max number of simultaneous connections of a `http.batch()` call for a host | +| [Blacklist IP](#blacklist-ip) | Blacklist IP ranges from being called | +| [Block hostnames](#block-hostnames) | Block any requests to specific hostnames | +| [Compatibility mode](#compatibility-mode) | Support running scripts with different ECMAScript modes | +| [Config](#config) | Specify the config file in JSON format to read the options values | +| [Console output](#console-output) | Redirects logs logged by `console` methods to the provided output file | +| [Discard response bodies](#discard-response-bodies) | Specify whether response bodies should be discarded | +| [DNS](#dns) | Configure DNS resolution behavior | | [Duration](#duration) | A string specifying the total duration of the test run; together with the [vus option](#vus), it's a shortcut for a single [scenario](https://grafana.com/docs/k6//using-k6/scenarios) with a [constant VUs executor](https://grafana.com/docs/k6//using-k6/scenarios/executors/constant-vus) | -| [Execution segment](#execution-segment) | Limit execution to a segment of the total test | -| [Exit on running](#exit-on-running) | Exits when test reaches the running status | -| [Extension options](#extension-options) | An object used to set configuration options for cloud parameters and third-party collectors | -| [Hosts](#hosts) | An object with overrides to DNS resolution | -| [HTTP debug](#http-debug) | Log all HTTP requests and responses | -| [Include system Env vars](#include-system-env-vars) | Pass the real system environment variables to the runtime | -| [Insecure skip TLS verify](#insecure-skip-tls-verify) | A boolean specifying whether k6 should ignore TLS verifications for connections established from code | +| [Execution segment](#execution-segment) | Limit execution to a segment of the total test | +| [Exit on running](#exit-on-running) | Exits when test reaches the running status | +| [Extension options](#extension-options) | An object used to set configuration options for cloud parameters and third-party collectors | +| [Hosts](#hosts) | An object with overrides to DNS resolution | +| [HTTP debug](#http-debug) | Log all HTTP requests and responses | +| [Include system Env vars](#include-system-env-vars) | Pass the real system environment variables to the runtime | +| [Insecure skip TLS verify](#insecure-skip-tls-verify) | A boolean specifying whether k6 should ignore TLS verifications for connections established from code | | [Iterations](#iterations) | A number specifying a fixed number of iterations to execute of the script; together with the [vus option](#vus), it's a shortcut for a single [scenario](https://grafana.com/docs/k6//using-k6/scenarios) with a [shared iterations executor](https://grafana.com/docs/k6//using-k6/scenarios/executors/shared-iterations) | -| [Linger](#linger) | A boolean specifying whether k6 should linger around after test run completion | -| [Local IPs](#local-ips) | A list of local IPs, IP ranges, and CIDRs from which VUs will make requests | -| [Log output](#log-output) | Configuration about where logs from k6 should be send | -| [LogFormat](#logformat) | Specify the format of the log output | -| [Max redirects](#max-redirects) | The maximum number of HTTP redirects that k6 will follow | -| [Minimum iteration duration](#minimum-iteration-duration) | Specify the minimum duration for every single execution | -| [No color](#no-color) | A boolean specifying whether colored output is disabled | -| [No connection reuse](#no-connection-reuse) | A boolean specifying whether k6 should disable keep-alive connections | -| [No cookies reset](#no-cookies-reset) | This disables resetting the cookie jar after each VU iteration | -| [No summary](#no-summary) | disables the [end-of-test summary](https://grafana.com/docs/k6//results-output/end-of-test) | -| [No setup](#no-setup) | A boolean specifying whether `setup()` function should be run | -| [No teardown](#no-teardown) | A boolean specifying whether `teardown()` function should be run | -| [No thresholds](#no-thresholds) | Disables threshold execution | -| [No usage report](#no-usage-report) | A boolean specifying whether k6 should send a usage report | -| [No VU connection reuse](#no-vu-connection-reuse) | A boolean specifying whether k6 should reuse TCP connections | -| [Paused](#paused) | A boolean specifying whether the test should start in a paused state | -| [Quiet](#quiet) | A boolean specifying whether to show the progress update in the console or not | -| [Results output](#results-output) | Specify the results output | -| [RPS](#rps) | The maximum number of requests to make per second globally (discouraged, use [arrival-rate executors](https://grafana.com/docs/k6//using-k6/scenarios/concepts/open-vs-closed) instead) | -| [Scenarios](#scenarios) | Define advanced execution scenarios | -| [Setup timeout](#setup-timeout) | Specify how long the `setup()` function is allow to run before it's terminated | -| [Show logs](#show-logs) | A boolean specifying whether the cloud logs are printed out to the terminal | +| [Linger](#linger) | A boolean specifying whether k6 should linger around after test run completion | +| [Local IPs](#local-ips) | A list of local IPs, IP ranges, and CIDRs from which VUs will make requests | +| [Log output](#log-output) | Configuration about where logs from k6 should be send | +| [LogFormat](#logformat) | Specify the format of the log output | +| [Max redirects](#max-redirects) | The maximum number of HTTP redirects that k6 will follow | +| [Minimum iteration duration](#minimum-iteration-duration) | Specify the minimum duration for every single execution | +| [No color](#no-color) | A boolean specifying whether colored output is disabled | +| [No connection reuse](#no-connection-reuse) | A boolean specifying whether k6 should disable keep-alive connections | +| [No cookies reset](#no-cookies-reset) | This disables resetting the cookie jar after each VU iteration | +| [No summary](#no-summary) | disables the [end-of-test summary](https://grafana.com/docs/k6//results-output/end-of-test) | +| [No setup](#no-setup) | A boolean specifying whether `setup()` function should be run | +| [No teardown](#no-teardown) | A boolean specifying whether `teardown()` function should be run | +| [No thresholds](#no-thresholds) | Disables threshold execution | +| [No usage report](#no-usage-report) | A boolean specifying whether k6 should send a usage report | +| [No VU connection reuse](#no-vu-connection-reuse) | A boolean specifying whether k6 should reuse TCP connections | +| [Paused](#paused) | A boolean specifying whether the test should start in a paused state | +| [Profiling Enabled](#profiling-enabled) | Enables profiling endpoints | +| [Quiet](#quiet) | A boolean specifying whether to show the progress update in the console or not | +| [Results output](#results-output) | Specify the results output | +| [RPS](#rps) | The maximum number of requests to make per second globally (discouraged, use [arrival-rate executors](https://grafana.com/docs/k6//using-k6/scenarios/concepts/open-vs-closed) instead) | +| [Scenarios](#scenarios) | Define advanced execution scenarios | +| [Setup timeout](#setup-timeout) | Specify how long the `setup()` function is allow to run before it's terminated | +| [Show logs](#show-logs) | A boolean specifying whether the cloud logs are printed out to the terminal | | [Stages](#stages) | A list of objects that specify the target number of VUs to ramp up or down; shortcut option for a single [scenario](https://grafana.com/docs/k6//using-k6/scenarios) with a [ramping VUs executor](https://grafana.com/docs/k6//using-k6/scenarios/executors/ramping-vus) | -| [Supply environment variable](#supply-environment-variables) | Add/override environment variable with `VAR=value` | -| [System tags](#system-tags) | Specify which System Tags will be in the collected metrics | +| [Supply environment variable](#supply-environment-variables) | Add/override environment variable with `VAR=value` | +| [System tags](#system-tags) | Specify which System Tags will be in the collected metrics | | [Summary export](#summary-export) | Output the [end-of-test summary](https://grafana.com/docs/k6//results-output/end-of-test) report to a JSON file (discouraged, use [handleSummary()](https://grafana.com/docs/k6//results-output/end-of-test/custom-summary) instead) | -| [Summary trend stats](#summary-trend-stats) | Define stats for trend metrics in the [end-of-test summary](https://grafana.com/docs/k6//results-output/end-of-test) | -| [Summary time unit](#summary-time-unit) | Time unit to be used for _all_ time values in the [end-of-test summary](https://grafana.com/docs/k6//results-output/end-of-test) | -| [Tags](#tags) | Specify tags that should be set test-wide across all metrics | -| [Teardown timeout](#teardown-timeout) | Specify how long the teardown() function is allowed to run before it's terminated | -| [Thresholds](#thresholds) | Configure under what conditions a test is successful or not | -| [Throw](#throw) | A boolean specifying whether to throw errors on failed HTTP requests | -| [TLS auth](#tls-auth) | A list of TLS client certificate configuration objects | -| [TLS cipher suites](#tls-cipher-suites) | A list of cipher suites allowed to be used by in SSL/TLS interactions with a server | -| [TLS version](#tls-version) | String or object representing the only SSL/TLS version allowed | -| [User agent](#user-agent) | A string specifying the User-Agent header when sending HTTP requests | -| [Verbose](#verbose) | A boolean specifying whether verbose logging is enabled | -| [VUs](#vus) | A number specifying the number of VUs to run concurrently | +| [Summary trend stats](#summary-trend-stats) | Define stats for trend metrics in the [end-of-test summary](https://grafana.com/docs/k6//results-output/end-of-test) | +| [Summary time unit](#summary-time-unit) | Time unit to be used for _all_ time values in the [end-of-test summary](https://grafana.com/docs/k6//results-output/end-of-test) | +| [Tags](#tags) | Specify tags that should be set test-wide across all metrics | +| [Teardown timeout](#teardown-timeout) | Specify how long the teardown() function is allowed to run before it's terminated | +| [Thresholds](#thresholds) | Configure under what conditions a test is successful or not | +| [Throw](#throw) | A boolean specifying whether to throw errors on failed HTTP requests | +| [TLS auth](#tls-auth) | A list of TLS client certificate configuration objects | +| [TLS cipher suites](#tls-cipher-suites) | A list of cipher suites allowed to be used by in SSL/TLS interactions with a server | +| [TLS version](#tls-version) | String or object representing the only SSL/TLS version allowed | +| [User agent](#user-agent) | A string specifying the User-Agent header when sending HTTP requests | +| [Verbose](#verbose) | A boolean specifying whether verbose logging is enabled | +| [VUs](#vus) | A number specifying the number of VUs to run concurrently | The following sections detail all available options that you can be specify within a script. @@ -230,7 +231,7 @@ Available in `k6 run` and `k6 cloud` commands: When running tests in k6 Cloud and using a non-default config.json file, specify the cloud token inside your config file to authenticate. - {{% /admonition %}} +{{% /admonition %}} ## Console output @@ -434,7 +435,7 @@ k6 also supports ways to narrow or widen the scope of your redirects: This does not modify the actual HTTP `Host` header, but rather where it will be routed. - {{% /admonition %}} +{{% /admonition %}} | Env | CLI | Code / Config file | Default | | --- | --- | ------------------ | ------- | @@ -904,6 +905,22 @@ export const options = { {{< /code >}} +## Profiling Enabled + +Enables [pprof](https://pkg.go.dev/net/http/pprof) profiling endpoints under the k6's REST API [address](#address). These endpoints help debug and profile k6 itself. k6's REST API should be enabled as well. + +| Env | CLI | Code / Config file | Default | +| --- | --------------------- | ------------------ | ------------------------------------ | +| N/A | `--profiling-enabled` | N/A | `http://localhost:6565/debug/pprof/` | + +{{< code >}} + +```bash +$ k6 run --profiling-enabled script.js +``` + +{{< /code >}} + ## Quiet A boolean, true or false, that disables the progress update bar on the console output. Available in `k6 run` and `k6 cloud` commands. @@ -956,7 +973,7 @@ That is, it is not sharded like VUs are.
We strongly recommend the [arrival-rate executors](https://grafana.com/docs/k6//using-k6/scenarios/concepts/open-vs-closed) to simulate constant RPS instead of this option. - {{% /admonition %}} +{{% /admonition %}} | Env | CLI | Code / Config file | Default | | -------- | ------- | ------------------ | --------------- | @@ -1165,7 +1182,7 @@ For example, `-e K6_ITERATIONS=120` does _not_ configure the script iterations. Compare this behavior with `K6_ITERATIONS=120 k6 run script.js`, which _does_ set iterations. - {{% /admonition %}} +{{% /admonition %}} | Env | CLI | Code / Config file | Default | | --- | ------------- | ------------------ | ------- | @@ -1302,7 +1319,7 @@ at the [Thresholds](https://grafana.com/docs/k6//using-k6/thresholds ```javascript export const options = { thresholds: { - http_req_duration: ['avg<100', 'p(95)<200'], + 'http_req_duration': ['avg<100', 'p(95)<200'], 'http_req_connecting{cdnAsset:true}': ['p(95)<100'], }, }; @@ -1368,7 +1385,7 @@ For a full listing of available ciphers go [here](https://golang.org/pkg/crypto/ Due to limitations in the underlying [go implementation](https://github.com/golang/go/issues/29349), changing the ciphers for TLS 1.3 is _not_ supported and will do nothing. - {{% /admonition %}} +{{% /admonition %}} | Env | CLI | Code / Config file | Default | | --- | --- | ------------------ | ------------------------- |