Skip to content
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

Document telemetry in README, backtrace only on crash, ignore errors #388

Merged
merged 5 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,30 @@ k0sctl completion > /usr/local/share/zsh/site-functions/_k0sctl
k0sctl completion > ~/.config/fish/completions/k0sctl.fish
```

## Anonymous telemetry

K0sctl will send anonymized telemetry data when used. This can be disabled by using the `--disable-telemetry` flag or setting `DISABLE_TELEMETRY=true` environment variable.
kke marked this conversation as resolved.
Show resolved Hide resolved

The telemetry data includes:

- K0sctl version
- Operating system + CPU architecture ("linux x86", "darwin arm64", ...)
- An anonymous machine ID generated by [denisbrodbeck/machineid](https://github.com/denisbrodbeck/machineid) or if that fails, an md5 sum of the hostname
- Event information:
* Phase name ("Connecting to hosts", "Gathering facts", ...) and the duration how long it took to finish
* Possible crash error message without identifying information
kke marked this conversation as resolved.
Show resolved Hide resolved
* Cluster UUID (`kubectl get -n kube-system namespace kube-system -o template={{.metadata.uid}}`)
* Was k0s dynamic config enabled (true/false)
* Was a custom or the default k0s configuration used (true/false)

The data is used to estimate the number of users and to identify failure hotspots.

## Development status

K0sctl is ready for use and in continuous development. It is still at a stage where maintaining backwards compatibility is not a high priority goal.

Missing major features include at least:

* Windows targets are not yet supported
* The released binaries have not been signed
* Nodes can't be removed
* The configuration specification and command-line interface options are still evolving
Expand Down
20 changes: 18 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
package main

import (
"fmt"
"os"
"regexp"

"github.com/k0sproject/k0sctl/analytics"
"github.com/k0sproject/k0sctl/cmd"
log "github.com/sirupsen/logrus"
)

func cleanError(e any) string {
if err, ok := e.(error); ok {
ipRE := regexp.MustCompile(`\d+\.\d+\.\d+\.\d+`)
hostRE := regexp.MustCompile(`(?:[a-zA-Z0-9]\.){1,}[a-zA-Z0-9]{2,6}`)
userRE := regexp.MustCompile(`[a-zA-Z0-9]+@\w+`)

res := ipRE.ReplaceAllString(err.Error(), "[...]")
res = hostRE.ReplaceAllString(res, "[...]")
res = userRE.ReplaceAllString(res, "[...]@")

return res
}

return "unknown"
}

func handlepanic() {
if err := recover(); err != nil {
_ = analytics.Client.Publish("panic", map[string]interface{}{"error": fmt.Sprint(err)})
_ = analytics.Client.Publish("panic", map[string]interface{}{"error": cleanError(err)})
log.Fatalf("PANIC: %s", err)
}
}
Expand Down