Skip to content

[breaking] Rename telemetry to metrics #1108

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

Merged
merged 1 commit into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions cli/config/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ var validMap = map[string]reflect.Kind{
"logging.format": reflect.String,
"logging.level": reflect.String,
"sketch.always_export_binaries": reflect.Bool,
"telemetry.addr": reflect.String,
"telemetry.enabled": reflect.Bool,
"metrics.addr": reflect.String,
"metrics.enabled": reflect.Bool,
}

func typeOf(key string) (reflect.Kind, error) {
Expand Down
8 changes: 4 additions & 4 deletions cli/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ import (
"github.com/arduino/arduino-cli/cli/globals"
"github.com/arduino/arduino-cli/commands/daemon"
"github.com/arduino/arduino-cli/configuration"
"github.com/arduino/arduino-cli/metrics"
srv_commands "github.com/arduino/arduino-cli/rpc/commands"
srv_debug "github.com/arduino/arduino-cli/rpc/debug"
srv_monitor "github.com/arduino/arduino-cli/rpc/monitor"
srv_settings "github.com/arduino/arduino-cli/rpc/settings"
"github.com/arduino/arduino-cli/telemetry"
"github.com/segmentio/stats/v4"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -60,8 +60,8 @@ var daemonize bool

func runDaemonCommand(cmd *cobra.Command, args []string) {

if configuration.Settings.GetBool("telemetry.enabled") {
telemetry.Activate("daemon")
if configuration.Settings.GetBool("metrics.enabled") {
metrics.Activate("daemon")
stats.Incr("daemon", stats.T("success", "true"))
defer stats.Flush()
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func runDaemonCommand(cmd *cobra.Command, args []string) {
go func() {
// Stdin is closed when the controlling parent process ends
_, _ = io.Copy(ioutil.Discard, os.Stdin)
// Flush telemetry stats (this is a no-op if telemetry is disabled)
// Flush metrics stats (this is a no-op if metrics is disabled)
stats.Flush()
os.Exit(0)
}()
Expand Down
6 changes: 3 additions & 3 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
"github.com/arduino/arduino-cli/legacy/builder"
"github.com/arduino/arduino-cli/legacy/builder/i18n"
"github.com/arduino/arduino-cli/legacy/builder/types"
"github.com/arduino/arduino-cli/metrics"
rpc "github.com/arduino/arduino-cli/rpc/commands"
"github.com/arduino/arduino-cli/telemetry"
paths "github.com/arduino/go-paths-helper"
properties "github.com/arduino/go-properties-orderedmap"
"github.com/pkg/errors"
Expand All @@ -47,15 +47,15 @@ func Compile(ctx context.Context, req *rpc.CompileReq, outStream, errStream io.W

tags := map[string]string{
"fqbn": req.Fqbn,
"sketchPath": telemetry.Sanitize(req.SketchPath),
"sketchPath": metrics.Sanitize(req.SketchPath),
"showProperties": strconv.FormatBool(req.ShowProperties),
"preprocess": strconv.FormatBool(req.Preprocess),
"buildProperties": strings.Join(req.BuildProperties, ","),
"warnings": req.Warnings,
"verbose": strconv.FormatBool(req.Verbose),
"quiet": strconv.FormatBool(req.Quiet),
"vidPid": req.VidPid,
"exportDir": telemetry.Sanitize(req.GetExportDir()),
"exportDir": metrics.Sanitize(req.GetExportDir()),
"jobs": strconv.FormatInt(int64(req.Jobs), 10),
"libraries": strings.Join(req.Libraries, ","),
"clean": strconv.FormatBool(req.GetClean()),
Expand Down
4 changes: 2 additions & 2 deletions configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func TestInit(t *testing.T) {

require.Equal(t, "50051", settings.GetString("daemon.port"))

require.Equal(t, true, settings.GetBool("telemetry.enabled"))
require.Equal(t, ":9090", settings.GetString("telemetry.addr"))
require.Equal(t, true, settings.GetBool("metrics.enabled"))
require.Equal(t, ":9090", settings.GetString("metrics.addr"))
}

func TestFindConfigFile(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions configuration/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func SetDefaults(settings *viper.Viper) {
// daemon settings
settings.SetDefault("daemon.port", "50051")

//telemetry settings
settings.SetDefault("telemetry.enabled", true)
settings.SetDefault("telemetry.addr", ":9090")
// metrics settings
settings.SetDefault("metrics.enabled", true)
settings.SetDefault("metrics.addr", ":9090")

// Bind env vars
settings.SetEnvPrefix("ARDUINO")
Expand Down
17 changes: 17 additions & 0 deletions docs/UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

Here you can find a list of migration guides to handle breaking changes between releases of the CLI.

## Unreleased

### Rename `telemetry` settings to `metrics`

All instances of the term `telemetry` in the code and the documentation has been changed to `metrics`. This has been
done to clarify that no data is currently gathered from users of the CLI.

To handle this change the users must edit their config file, usually `arduino-cli.yaml`, and change the `telemetry` key
to `metrics`. The modification must be done by manually editing the file using a text editor, it can't be done via CLI.
No other action is necessary.

The default folders for the `arduino-cli.yaml` are:

- Linux: `/home/<your_username>/.arduino15/arduino-cli.yaml`
- OS X: `/Users/<your_username>/Library/Arduino15/arduino-cli.yaml`
- Windows: `C:\Users\<your_username>\AppData\Arduino15\arduino-cli.yaml`

## 0.14.0

### Changes in `debug` command
Expand Down
6 changes: 3 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
- `format` - output format for the logs. Allowed values are `text` or `json`.
- `level` - messages with this level and above will be logged. Valid levels are: `trace`, `debug`, `info`, `warn`,
`error`, `fatal`, `panic`.
- `telemetry` - settings related to the collection of data used for continued improvement of Arduino CLI.
- `addr` - TCP port used for telemetry communication.
- `enabled` - controls the use of telemetry.
- `metrics` - settings related to the collection of data used for continued improvement of Arduino CLI.
- `addr` - TCP port used for metrics communication.
- `enabled` - controls the use of metrics.

## Configuration methods

Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ The [client_example] folder contains a sample client code that shows how to inte
services and messages are detailed in the [gRPC reference] pages.

To provide observability for the gRPC server activities besides logs, the `daemon` mode activates and exposes by default
a [Prometheus](https://prometheus.io/) endpoint (http://localhost:9090/metrics) that can be fetched for telemetry data
a [Prometheus](https://prometheus.io/) endpoint (http://localhost:9090/metrics) that can be fetched for metrics data
like:

```text
Expand All @@ -340,10 +340,10 @@ daemon_compile{buildProperties="",exportFile="",fqbn="arduino:samd:mkr1000",inst
daemon_board_list{installationID="ed6f1f22-1fbe-4b1f-84be-84d035b6369c",success="true"} 1 1580385724833
```

The telemetry settings are exposed via the `telemetry` section in the CLI configuration:
The metrics settings are exposed via the `metrics` section in the CLI configuration:

```yaml
telemetry:
metrics:
enabled: true
addr: :9090
```
Expand Down
10 changes: 5 additions & 5 deletions telemetry/telemetry.go → metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to [email protected].

package telemetry
package metrics

import (
"crypto/hmac"
Expand All @@ -28,10 +28,10 @@ import (
"github.com/sirupsen/logrus"
)

// serverPattern is the telemetry endpoint resource path for consume metrics
// serverPattern is the metrics endpoint resource path for consume metrics
var serverPattern = "/metrics"

// Activate configures and starts the telemetry server exposing a Prometheus resource
// Activate configures and starts the metrics server exposing a Prometheus resource
func Activate(metricPrefix string) {
// Create a Prometheus default handler
ph := prometheus.DefaultHandler
Expand All @@ -43,8 +43,8 @@ func Activate(metricPrefix string) {
stats.Register(ph)

// Configure using viper settings
serverAddr := configuration.Settings.GetString("telemetry.addr")
logrus.Infof("Setting up Prometheus telemetry on %s%s", serverAddr, serverPattern)
serverAddr := configuration.Settings.GetString("metrics.addr")
logrus.Infof("Setting up Prometheus metrics on %s%s", serverAddr, serverPattern)
go func() {
http.Handle(serverPattern, ph)
logrus.Error(http.ListenAndServe(serverAddr, nil))
Expand Down
16 changes: 8 additions & 8 deletions test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def test_init_with_existing_custom_config(run_command, data_dir, working_dir, do
assert "" == configs["logging"]["file"]
assert "text" == configs["logging"]["format"]
assert "info" == configs["logging"]["level"]
assert ":9090" == configs["telemetry"]["addr"]
assert configs["telemetry"]["enabled"]
assert ":9090" == configs["metrics"]["addr"]
assert configs["metrics"]["enabled"]

config_file_path = Path(working_dir) / "config" / "test" / "config.yaml"
assert not config_file_path.exists()
Expand All @@ -60,8 +60,8 @@ def test_init_with_existing_custom_config(run_command, data_dir, working_dir, do
assert "" == configs["logging"]["file"]
assert "text" == configs["logging"]["format"]
assert "info" == configs["logging"]["level"]
assert ":9090" == configs["telemetry"]["addr"]
assert configs["telemetry"]["enabled"]
assert ":9090" == configs["metrics"]["addr"]
assert configs["metrics"]["enabled"]


def test_init_overwrite_existing_custom_file(run_command, data_dir, working_dir, downloads_dir):
Expand All @@ -80,8 +80,8 @@ def test_init_overwrite_existing_custom_file(run_command, data_dir, working_dir,
assert "" == configs["logging"]["file"]
assert "text" == configs["logging"]["format"]
assert "info" == configs["logging"]["level"]
assert ":9090" == configs["telemetry"]["addr"]
assert configs["telemetry"]["enabled"]
assert ":9090" == configs["metrics"]["addr"]
assert configs["metrics"]["enabled"]

result = run_command("config init --overwrite")
assert result.ok
Expand All @@ -98,8 +98,8 @@ def test_init_overwrite_existing_custom_file(run_command, data_dir, working_dir,
assert "" == configs["logging"]["file"]
assert "text" == configs["logging"]["format"]
assert "info" == configs["logging"]["level"]
assert ":9090" == configs["telemetry"]["addr"]
assert configs["telemetry"]["enabled"]
assert ":9090" == configs["metrics"]["addr"]
assert configs["metrics"]["enabled"]


def test_init_dest_absolute_path(run_command, working_dir):
Expand Down
4 changes: 2 additions & 2 deletions test/test_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


@pytest.mark.timeout(60)
def test_telemetry_prometheus_endpoint(daemon_runner, data_dir):
def test_metrics_prometheus_endpoint(daemon_runner, data_dir):
# Wait for the inventory file to be created and then parse it
# in order to check the generated ids
inventory_file = os.path.join(data_dir, "inventory.yaml")
Expand All @@ -35,7 +35,7 @@ def test_telemetry_prometheus_endpoint(daemon_runner, data_dir):
inventory = yaml.safe_load(stream)

# Check if :9090/metrics endpoint is alive,
# telemetry is enabled by default in daemon mode
# metrics is enabled by default in daemon mode
s = requests.Session()
retries = Retry(total=3, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
s.mount("http://", HTTPAdapter(max_retries=retries))
Expand Down