Skip to content

Commit 660a071

Browse files
committed
cmd/internal/telemetry: add NewStackCounter functions
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 <[email protected]> Reviewed-by: Sam Thanawalla <[email protected]>
1 parent c5698e3 commit 660a071

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/cmd/internal/telemetry/telemetry.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !cmd_go_bootstrap
5+
//go:build !cmd_go_bootstrap && !compiler_bootstrap
66

77
// Package telemetry is a shim package around the golang.org/x/telemetry
88
// and golang.org/x/telemetry/counter packages that has code build tagged
@@ -38,14 +38,24 @@ func StartWithUpload() {
3838
})
3939
}
4040

41+
// Inc increments the counter with the given name.
4142
func Inc(name string) {
4243
counter.Inc(name)
4344
}
4445

46+
// NewCounter returns a counter with the given name.
4547
func NewCounter(name string) *counter.Counter {
4648
return counter.New(name)
4749
}
4850

51+
// NewStack returns a new stack counter with the given name and depth.
52+
func NewStackCounter(name string, depth int) *counter.StackCounter {
53+
return counter.NewStack(name, depth)
54+
}
55+
56+
// CountFlags creates a counter for every flag that is set
57+
// and increments the counter. The name of the counter is
58+
// the concatenation of prefix and the flag name.
4959
func CountFlags(prefix string, flagSet flag.FlagSet) {
5060
counter.CountFlags(prefix, flagSet)
5161
}

src/cmd/internal/telemetry/telemetry_bootstrap.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build cmd_go_bootstrap
5+
//go:build cmd_go_bootstrap || compiler_bootstrap
66

77
package telemetry
88

@@ -12,8 +12,9 @@ type dummyCounter struct{}
1212

1313
func (dc dummyCounter) Inc() {}
1414

15-
func Start() {}
16-
func StartWithUpload() {}
17-
func Inc(name string) {}
18-
func NewCounter(name string) dummyCounter { return dummyCounter{} }
19-
func CountFlags(name string, flagSet flag.FlagSet) {}
15+
func Start() {}
16+
func StartWithUpload() {}
17+
func Inc(name string) {}
18+
func NewCounter(name string) dummyCounter { return dummyCounter{} }
19+
func NewStackCounter(name string, depth int) dummyCounter { return dummyCounter{} }
20+
func CountFlags(name string, flagSet flag.FlagSet) {}

0 commit comments

Comments
 (0)