Skip to content

Commit 58fea5d

Browse files
committed
cmd/go: add telemetry counters for flag names and subcommand
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>
1 parent c2de291 commit 58fea5d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/cmd/go/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func main() {
9797

9898
flag.Usage = base.Usage
9999
flag.Parse()
100+
counter.CountFlags("cmd/go:flag-", *flag.CommandLine)
100101

101102
args := flag.Args()
102103
if len(args) < 1 {
@@ -152,6 +153,7 @@ func main() {
152153

153154
cmd, used := lookupCmd(args)
154155
cfg.CmdName = strings.Join(args[:used], " ")
156+
counter.Inc("cmd/go:subcommand-" + strings.ReplaceAll(cfg.CmdName, " ", "-"))
155157
if len(cmd.Commands) > 0 {
156158
if used >= len(args) {
157159
help.PrintUsage(os.Stderr, cmd)
@@ -239,6 +241,7 @@ func invoke(cmd *base.Command, args []string) {
239241
} else {
240242
base.SetFromGOFLAGS(&cmd.Flag)
241243
cmd.Flag.Parse(args[1:])
244+
counter.CountFlags("cmd/go/"+cmd.Name()+":flag-", cmd.Flag)
242245
args = cmd.Flag.Args()
243246
}
244247

@@ -323,6 +326,7 @@ func handleChdirFlag() {
323326
_, dir, _ = strings.Cut(a, "=")
324327
os.Args = slices.Delete(os.Args, used, used+1)
325328
}
329+
counter.Inc("cmd/go:flag-C")
326330

327331
if err := os.Chdir(dir); err != nil {
328332
base.Fatalf("go: %v", err)

0 commit comments

Comments
 (0)