From eef288da1e7d2815cfa07e486b101ba21f0e0db1 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Mon, 13 May 2024 14:59:02 -0400 Subject: 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 Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI --- src/cmd/nm/nm.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/cmd/nm/nm.go') 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": -- cgit v1.3