]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/telemetry: add NewStackCounter functions
authorMichael Matloob <matloob@golang.org>
Tue, 30 Apr 2024 20:23:24 +0000 (16:23 -0400)
committerMichael Matloob <matloob@golang.org>
Wed, 1 May 2024 17:37:58 +0000 (17:37 +0000)
This CL adds a wrapper for the golang.org/x/telemetry/counter.NewStack
function so that it can be used by the compiler.

Also add build constraints for compiler_bootstrap to build the stubs
when we're bootstrapping the compiler.

For #58894

Change-Id: Icdbdd7aa6d2a3f1147112739c6939e14414f5ee9
Cq-Include-Trybots: luci.golang.try:gotip-linux-arm64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/582695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
src/cmd/internal/telemetry/telemetry.go
src/cmd/internal/telemetry/telemetry_bootstrap.go

index 0e223442ffd99432689c005ced9e012fe3b7c6ac..d31f0eeff3dc7619cbf79aa96dd73ed1848abedd 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !cmd_go_bootstrap
+//go:build !cmd_go_bootstrap && !compiler_bootstrap
 
 // Package telemetry is a shim package around the golang.org/x/telemetry
 // and golang.org/x/telemetry/counter packages that has code build tagged
@@ -38,14 +38,24 @@ func StartWithUpload() {
        })
 }
 
+// Inc increments the counter with the given name.
 func Inc(name string) {
        counter.Inc(name)
 }
 
+// NewCounter returns a counter with the given name.
 func NewCounter(name string) *counter.Counter {
        return counter.New(name)
 }
 
+// NewStack returns a new stack counter with the given name and depth.
+func NewStackCounter(name string, depth int) *counter.StackCounter {
+       return counter.NewStack(name, depth)
+}
+
+// CountFlags creates a counter for every flag that is set
+// and increments the counter. The name of the counter is
+// the concatenation of prefix and the flag name.
 func CountFlags(prefix string, flagSet flag.FlagSet) {
        counter.CountFlags(prefix, flagSet)
 }
index 9fb03507d984509cc583ecde5c9844871e30635a..2e127bec289dd6fc639db205cc8d3eb8c1cc68bb 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build cmd_go_bootstrap
+//go:build cmd_go_bootstrap || compiler_bootstrap
 
 package telemetry
 
@@ -12,8 +12,9 @@ type dummyCounter struct{}
 
 func (dc dummyCounter) Inc() {}
 
-func Start()                                       {}
-func StartWithUpload()                             {}
-func Inc(name string)                              {}
-func NewCounter(name string) dummyCounter          { return dummyCounter{} }
-func CountFlags(name string, flagSet flag.FlagSet) {}
+func Start()                                              {}
+func StartWithUpload()                                    {}
+func Inc(name string)                                     {}
+func NewCounter(name string) dummyCounter                 { return dummyCounter{} }
+func NewStackCounter(name string, depth int) dummyCounter { return dummyCounter{} }
+func CountFlags(name string, flagSet flag.FlagSet)        {}