aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2024-05-01 14:17:24 -0400
committerMichael Matloob <matloob@golang.org>2024-05-03 19:05:42 +0000
commit99fc3179487b8014f5b301e83fce8ccd618afa09 (patch)
tree80e8d0e72b7c8c26583e4bb9888630b7f4e3d6c4 /src
parent23f760fd58a0609b9e03da944e7949f7e26a7e29 (diff)
downloadgo-99fc3179487b8014f5b301e83fce8ccd618afa09.tar.gz
go-99fc3179487b8014f5b301e83fce8ccd618afa09.zip
cmd/go: add flag values to counter for buildmode
Usually, when we increment counters for flags, the counter only contains the flag name. For the buildmode flag, we now include the flag value because there's a limited set of values. We can't use CountFlags directly anymore since we have different behavior for buildmode. Change-Id: I956a1a97d62850df3199b5514ad507ea51355c9f Reviewed-on: https://go-review.googlesource.com/c/go/+/582896 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/main.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/go/main.go b/src/cmd/go/main.go
index dc2a8fd49c..86f3c65a92 100644
--- a/src/cmd/go/main.go
+++ b/src/cmd/go/main.go
@@ -252,7 +252,14 @@ func invoke(cmd *base.Command, args []string) {
} else {
base.SetFromGOFLAGS(&cmd.Flag)
cmd.Flag.Parse(args[1:])
- telemetry.CountFlags("go/flag:"+strings.ReplaceAll(cfg.CmdName, " ", "-")+"-", cmd.Flag)
+ prefix := "go/flag:" + strings.ReplaceAll(cfg.CmdName, " ", "-") + "-"
+ cmd.Flag.Visit(func(f *flag.Flag) {
+ counterName := prefix + f.Name
+ if f.Name == "buildmode" { // Special case: there is a limited set of buildmode values
+ counterName += "-" + f.Value.String()
+ }
+ telemetry.Inc(counterName)
+ })
args = cmd.Flag.Args()
}