diff options
| author | Michael Matloob <matloob@golang.org> | 2024-05-13 14:59:02 -0400 |
|---|---|---|
| committer | Michael Matloob <matloob@golang.org> | 2024-05-14 19:41:17 +0000 |
| commit | eef288da1e7d2815cfa07e486b101ba21f0e0db1 (patch) | |
| tree | 3710ab34f42a5b4e1a1ed7d19a086fd0ed744054 /src/cmd/trace | |
| parent | efc347348e965f8db4f036ac0c9c7bf214b7a929 (diff) | |
| download | go-eef288da1e7d2815cfa07e486b101ba21f0e0db1.tar.xz | |
cmd: add telemetry for commands in cmd
This change modifies the commands in cmd to open counter files,
increment invocations counters and to increment counters for the names
of the flags that were passed in.
cmd/pprof and cmd/vet are both wrappers around tools defined in other
modules which do their own flag processing so we can't directly
increment flag counters right after flags are parsed. For those two
commands we wait to increment counters until after the programs have
returned.
cmd/dist is built with the bootstrap go so it can't depend on telemetry
yet. We can add telemetry support to it once 1.23 is the minimum
bootstrap version.
For #58894
Change-Id: Ic7f6009992465e55c56ad4dc6451bcb1ca51374a
Reviewed-on: https://go-review.googlesource.com/c/go/+/585235
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/trace')
| -rw-r--r-- | src/cmd/trace/main.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/trace/main.go b/src/cmd/trace/main.go index 5f0d6f612b..2c0b15623d 100644 --- a/src/cmd/trace/main.go +++ b/src/cmd/trace/main.go @@ -7,6 +7,7 @@ package main import ( "bufio" "cmd/internal/browser" + "cmd/internal/telemetry" cmdv2 "cmd/trace/v2" "flag" "fmt" @@ -65,11 +66,14 @@ var ( ) func main() { + telemetry.Start() flag.Usage = func() { fmt.Fprint(os.Stderr, usageMessage) os.Exit(2) } flag.Parse() + telemetry.Inc("trace/invocations") + telemetry.CountFlags("trace/flag:", *flag.CommandLine) // Go 1.7 traces embed symbol info and does not require the binary. // But we optionally accept binary as first arg for Go 1.5 traces. |
