aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/nm/nm.go
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2024-05-13 14:59:02 -0400
committerMichael Matloob <matloob@golang.org>2024-05-14 19:41:17 +0000
commiteef288da1e7d2815cfa07e486b101ba21f0e0db1 (patch)
tree3710ab34f42a5b4e1a1ed7d19a086fd0ed744054 /src/cmd/nm/nm.go
parentefc347348e965f8db4f036ac0c9c7bf214b7a929 (diff)
downloadgo-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/nm/nm.go')
-rw-r--r--src/cmd/nm/nm.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/nm/nm.go b/src/cmd/nm/nm.go
index 78fa60014b..62cf155362 100644
--- a/src/cmd/nm/nm.go
+++ b/src/cmd/nm/nm.go
@@ -13,6 +13,7 @@ import (
"sort"
"cmd/internal/objfile"
+ "cmd/internal/telemetry"
)
const helpText = `usage: go tool nm [options] file...
@@ -67,8 +68,11 @@ func (nflag) String() string {
func main() {
log.SetFlags(0)
+ telemetry.Start()
flag.Usage = usage
flag.Parse()
+ telemetry.Inc("nm/invocations")
+ telemetry.CountFlags("nm/flag:", *flag.CommandLine)
switch *sortOrder {
case "address", "name", "none", "size":