]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/telemetrystats: count goexperiments
authorqmuntal <quimmuntal@gmail.com>
Tue, 15 Jul 2025 13:24:25 +0000 (15:24 +0200)
committerQuim Muntal <quimmuntal@gmail.com>
Tue, 29 Jul 2025 17:38:55 +0000 (10:38 -0700)
Knowing which goexperiments are enabled by the users is
useful information to have in the local telemetry database.

It also opens the door for uploading them in the future if
desired.

Change-Id: I12c8eaa3997dec0ed26703885f1c216676f5590d
Reviewed-on: https://go-review.googlesource.com/c/go/+/688135
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/go/internal/telemetrystats/telemetrystats.go

index 950453fa9513746324d4bde210e8a29bc0426d06..d5b642240f16b7a3d3bccf9157b3d512f1e8e590 100644 (file)
@@ -11,6 +11,7 @@ import (
        "cmd/go/internal/cfg"
        "cmd/go/internal/modload"
        "cmd/internal/telemetry/counter"
+       "strings"
 )
 
 func Increment() {
@@ -48,4 +49,16 @@ func incrementConfig() {
        case "wasm":
                counter.Inc("go/platform/target/gowasm:" + cfg.GOWASM)
        }
+
+       // Use cfg.Experiment.String instead of cfg.Experiment.Enabled
+       // because we only want to count the experiments that differ
+       // from the baseline.
+       if cfg.Experiment != nil {
+               for exp := range strings.SplitSeq(cfg.Experiment.String(), ",") {
+                       if exp == "" {
+                               continue
+                       }
+                       counter.Inc("go/goexperiment:" + exp)
+               }
+       }
 }