Skip to content

Commit 117164f

Browse files
committed
cmd/go: add telemetry counters for flag names and subcommand
For #58894 Change-Id: I6b5d5b14be9858f5855eeac0110aa44e762cee03 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/559519 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent 6d3c1ce commit 117164f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/cmd/go/main.go

Lines changed: 4 additions & 0 deletions
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)