telemetry

package
v0.141.0-rc.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package telemetry reports anonymous usage signals to TelemetryDeck, the way kubectl-gs does. One per agentlab command (Command): which command ran, on which agentlab version, operating system and architecture, under a hashed machine identifier that lets Giant Swarm count users without knowing who they are. And one per platform install (Platform): the meta chart line the lab installs and its feature switches, as versions and booleans. Once a command has read its lab's configuration (EnterLab), every signal names the lab's deployment, a random ID the lab's Backstage sends with its own signals. Nothing else about the lab — its users, clusters, paths, arguments or flags — leaves the machine. See docs/telemetry.md.

Setting AGENTLAB_TELEMETRY_OPTOUT (any value) or the console convention DO_NOT_TRACK=1 disables both, and a lab's `telemetry: false` does for the commands that run against it (AwaitLab, EnterLab). Reporting never fails a command and never speaks on its output: the signals travel while the command works, a command that finishes first waits for them at most half a second (Flush) before the process exits, and not at all once the endpoint has proven out of reach. AGENTLAB_TELEMETRY_DEBUG tells on stderr what happened to them.

Index

Constants

View Source
const (
	// OptOutEnv disables usage data collection when set to any value.
	OptOutEnv = "AGENTLAB_TELEMETRY_OPTOUT"

	// TestModeEnv files the signals as test data (kept apart from production
	// numbers in the TelemetryDeck dashboard), for developing the lab.
	TestModeEnv = "AGENTLAB_TELEMETRY_TESTMODE"

	// DebugEnv logs what happens to the signals on stderr: a delivery that
	// failed, a rejected request with its answer, an endpoint out of reach —
	// for proving the integration. Without it telemetry prints nothing.
	DebugEnv = "AGENTLAB_TELEMETRY_DEBUG"
)
View Source
const StartsDeployment = "agentlab.giantswarm.io/telemetry-starts-deployment"

StartsDeployment is the annotation of the command that starts a lab's deployment (`up`): its signal waits for StartDeployment, past EnterLab.

Variables

This section is empty.

Functions

func AppID added in v0.138.0

func AppID() string

AppID is the TelemetryDeck app agentlab files its signals under; the lab's Backstage reports into the same app.

func AwaitLab added in v0.139.0

func AwaitLab()

AwaitLab is a command that runs against a lab: its signal waits for the lab's configuration (EnterLab), and one that fails before reading it sends nothing, the lab's setting being unknown.

func Command

func Command(cmd *cobra.Command)

Command records one execution of a user-facing command ("agentlab up"). The signal leaves once the command has read its lab's configuration (EnterLab), so that it follows the lab's setting and names the lab's deployment — for `up`, once it has started one (StartDeployment) — or at Flush for a command that runs against no lab; its HTTP request runs on its own goroutine, and a failure to deliver is swallowed — telemetry must never get in the user's way. Same shape as kubectl-gs: signal type GiantSwarm.command with the command path and the app version in the payload, plus the OS, architecture and SDK version the library adds. The version and commit also go out as TelemetryDeck.AppInfo.version and .buildNumber (the library's WithAppVersion/WithBuildNumber): those are the parameters the TelemetryDeck dashboard's standard "App Versions" insight reads — the payload's appVersion is what the shared usage report queries.

Not every invocation is a person using the lab: hidden commands are plumbing (__complete runs on every TAB press), `completion` runs on every shell start once sourced from a profile, and `help` is help. None of those count.

func Enabled

func Enabled() bool

Enabled reports whether this process sends usage signals.

func EnterLab added in v0.138.0

func EnterLab(id string, on bool)

EnterLab is the lab's configuration read, as saved: on is its setting, off sending nothing from here on, and id names its deployment, carried by every signal from here on as deploymentID. The command's own signal (Command) leaves now, unless the command is held (StartsDeployment). An empty ID, a lab without a recorded deployment, sends the command signal without one.

func EnvOptOut added in v0.139.0

func EnvOptOut() string

EnvOptOut names the environment variable that turns usage data off for every lab, "" when none does.

func Flush added in v0.25.1

func Flush(ctx context.Context)

Flush sends the command signal if it has not left yet — a command that runs against no lab, or `up` failing before it started its deployment — and lets the signals sent so far (Command, Platform) finish their trip before the process exits, waiting at most flushTimeout (and no longer than ctx allows): a sub-second command such as `agentlab version` would otherwise exit before its request has left the machine. An endpoint none of them has connected to within connectTimeout of the first one setting out is out of reach, and Flush stops waiting for it then — at once for a command whose signal set out longer ago than that (one that entered its lab early); a signal Flush itself sends costs at most connectTimeout. Never an error for the caller — a signal that did not make it is dropped, and said so only under DebugEnv.

func Logf added in v0.138.0

func Logf(format string, args ...any)

Logf reports a telemetry problem on stderr under DebugEnv; every other run, test mode included, stays silent, telemetry being nobody's concern but the lab's developers and never part of a command's output.

func Platform added in v0.51.0

func Platform(ctx context.Context, cfg *config.Config, chartVersion string)

Platform records one install or upgrade of the agent platform: `agentlab up` and `agentlab platform` send it once per run, after the config is loaded and the chart resolved (the dev channel's build picked), so chartVersion is what the run installs. Nothing else sends it — `render`, the proofs and every other command say nothing about the platform.

The payload is the meta chart line and the lab's shape: the exact chart version and its major, the channel the chart comes from (stable, dev or a chart directory), whether the lab renders the legacy 3.x shape, and the feature switches of agentlab.yaml as booleans. Never a path (a chart directory reports the version its Chart.yaml carries, not where it is), a hostname, a user or a token: every value is a version or a bool, so the dashboard can count labs per chart line and channel while nothing in a signal points back at a machine. Same opt-outs, test mode and client as Command, so Flush covers this signal too.

func StartDeployment added in v0.138.0

func StartDeployment(id string)

StartDeployment is EnterLab for the command that starts the lab's deployment: its signal leaves now, naming id.

func TestMode added in v0.138.0

func TestMode() bool

TestMode says whether AGENTLAB_TELEMETRY_TESTMODE is set.

func UserFacing added in v0.20.0

func UserFacing(cmd *cobra.Command) bool

UserFacing says whether cmd is something a person runs on purpose: not hidden, and not cobra's built-in completion or help trees.

Types

type Deployment added in v0.138.0

type Deployment struct {
	ID       string `json:"id"`
	Salt     string `json:"salt"`
	TestMode bool   `json:"testMode,omitempty"`
}

Deployment is one lab cluster, from the `agentlab up` that creates it to its deletion. ID goes out with every signal of the lab, the CLI's (EnterLab) and its Backstage's, so the two can be read together. Salt hashes the lab's Backstage users, scoping them to the deployment: every lab has the same Dex users, and an unscoped admin@lab.local would be one person across all labs. The salt never leaves the lab — sent next to the hashes, it would let a guessed GitHub login be checked against them.

TestMode is AGENTLAB_TELEMETRY_TESTMODE as the deployment started: the lab's portal keeps it for the deployment's lifetime, so a later command run from another shell does not change the portal's config and restart it.

func NewDeployment added in v0.138.0

func NewDeployment() (Deployment, error)

NewDeployment draws a deployment's ID and salt, in the environment's test mode.

Directories

Path Synopsis
Package machineid reads the identifier the operating system keeps for the computer it runs on: `kern.uuid` on macOS, /etc/machine-id on Linux, the registry's MachineGuid on Windows.
Package machineid reads the identifier the operating system keeps for the computer it runs on: `kern.uuid` on macOS, /etc/machine-id on Linux, the registry's MachineGuid on Windows.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL