Skip to content

Commit

Permalink
Document imported modules and used outputs report (#1478)
Browse files Browse the repository at this point in the history
Added the new collected data and refreshed a bit the page.

---------

Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
  • Loading branch information
codebien and joanlopez authored Jan 16, 2024
1 parent 02b46d1 commit 7ddd0d3
Showing 1 changed file with 8 additions and 44 deletions.
52 changes: 8 additions & 44 deletions docs/sources/next/misc/usage-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ weight: 02

# Usage collection

By default, k6 sends a usage report each time it is run, so that we can track how often people use it. This report can be turned off by setting the environment variable `K6_NO_USAGE_REPORT` or by adding the option `--no-usage-report` when executing k6.
By default, k6 sends an anonymous usage report each time it is run, so that we can track relevant information to be able to build the product making better data-driven decisions. Prioritizing the features that benefit the most and reducing the impact of changes.

The report can be turned off by setting the [no usage report](https://grafana.com/docs/k6/<K6_VERSION>/using-k6/k6-options/reference/#no-usage-report) option setting the environment variable `K6_NO_USAGE_REPORT` or by adding the flag `--no-usage-report` when executing k6.

The usage report does not contain any information about what you are testing. The contents are the following:

Expand All @@ -17,49 +19,11 @@ The usage report does not contain any information about what you are testing. Th
- VU iterations configured (number)
- The running program's operating system target (`darwin`, `freebsd`, `linux`...)
- The running program's architecture target (386, amd64, arm, s390x...)
- The list of JavaScript imported modules (`k6/http`, `k6/experimental/webcrypto`, ...)
- The list of used outputs (`json`, `influxdb`, ...)

This info is sent to an HTTP server that collects statistics on k6 usage.

For those interested, here is the actual Go [code](https://github.com/grafana/k6/blob/master/cmd/run.go) that generates and sends the usage report:

{{< code >}}

```go
// If the user hasn't opted out: report usage.

if !conf.NoUsageReport.Bool {
go func() {
u := "http://k6reports.k6.io/"
mime := "application/json"
var endTSeconds float64

if endT := engine.Executor.GetEndTime(); endT.Valid {
endTSeconds = time.Duration(endT.Duration).Seconds()
}

var stagesEndTSeconds float64
if stagesEndT := lib.SumStages(engine.Executor.GetStages()); stagesEndT.Valid {
stagesEndTSeconds = time.Duration(stagesEndT.Duration).Seconds()
}

body, err := json.Marshal(map[string]interface{}{
"k6_version": Version,
"vus_max": engine.Executor.GetVUsMax(),
"iterations": engine.Executor.GetEndIterations(),
"duration": endTSeconds,
"st_duration": stagesEndTSeconds,
"goos": runtime.GOOS,
"goarch": runtime.GOARCH,
})
> Only k6 built-in JavaScript modules and outputs are considered. Private modules and custom extensions are excluded.
if err != nil {
panic(err) // This should never happen!!
}
if _, err := http.Post(u, mime, bytes.NewBuffer(body)); err != nil {
log.WithError(err).Debug("Couldn't send usage blip")
}
}()
}
```
This report is sent to an HTTPS server that collects statistics on k6 usage.

{{< /code >}}
k6 is an open-source project and for those interested, the actual code that generates and sends the usage report can be directly reviewed [here](https://github.com/grafana/k6/blob/d031d2b65e9e28143742b4b109f383e6b103ab31/cmd/report.go).

0 comments on commit 7ddd0d3

Please sign in to comment.