]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: add telemetry counters for flag names and subcommand
authorMichael Matloob <matloob@golang.org>
Thu, 8 Feb 2024 17:50:44 +0000 (17:50 +0000)
committerMichael Matloob <matloob@golang.org>
Thu, 8 Feb 2024 20:48:23 +0000 (20:48 +0000)
For #58894,#65586

This is a revert of CL 560655 which was a revert of CL 559519.
CL 559519 was reverted because it was broken on windows/386. But now
CL 562715 pulls in x/telemetry CL 560462 which disables telemetry on
windows/386, fixing that issue.

Change-Id: I094e90c28bca02f2303807d3b008f2ef9d59433c
Reviewed-on: https://go-review.googlesource.com/c/go/+/562735
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/go/main.go

index 2065c9a157b8efe9208bbda2c00940a699951781..f62477a8392492eea561207d2589f434143754bf 100644 (file)
@@ -97,6 +97,7 @@ func main() {
 
        flag.Usage = base.Usage
        flag.Parse()
+       counter.CountFlags("cmd/go:flag-", *flag.CommandLine)
 
        args := flag.Args()
        if len(args) < 1 {
@@ -152,6 +153,7 @@ func main() {
 
        cmd, used := lookupCmd(args)
        cfg.CmdName = strings.Join(args[:used], " ")
+       counter.Inc("cmd/go:subcommand-" + strings.ReplaceAll(cfg.CmdName, " ", "-"))
        if len(cmd.Commands) > 0 {
                if used >= len(args) {
                        help.PrintUsage(os.Stderr, cmd)
@@ -239,6 +241,7 @@ func invoke(cmd *base.Command, args []string) {
        } else {
                base.SetFromGOFLAGS(&cmd.Flag)
                cmd.Flag.Parse(args[1:])
+               counter.CountFlags("cmd/go/"+cmd.Name()+":flag-", cmd.Flag)
                args = cmd.Flag.Args()
        }
 
@@ -323,6 +326,7 @@ func handleChdirFlag() {
                _, dir, _ = strings.Cut(a, "=")
                os.Args = slices.Delete(os.Args, used, used+1)
        }
+       counter.Inc("cmd/go:flag-C")
 
        if err := os.Chdir(dir); err != nil {
                base.Fatalf("go: %v", err)