]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal: separate counter package from telemetry package
authorMichael Matloob <matloob@golang.org>
Fri, 21 Jun 2024 18:35:14 +0000 (14:35 -0400)
committerMichael Matloob <matloob@golang.org>
Fri, 21 Jun 2024 19:58:04 +0000 (19:58 +0000)
Move the code that opens and increments counters out of the
cmd/internal/telemetry package into cmd/internal/telemetry/counter. The
telemetry package has dependencies on the upload code, which we do not
want to pull into the rest of the go toolchain.

For #68109

Change-Id: I463c106819b169177a783de4a7d93377e81f4e3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/593976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
38 files changed:
src/cmd/addr2line/main.go
src/cmd/asm/main.go
src/cmd/buildid/buildid.go
src/cmd/cgo/main.go
src/cmd/compile/internal/base/flag.go
src/cmd/compile/internal/base/print.go
src/cmd/compile/internal/gc/main.go
src/cmd/covdata/covdata.go
src/cmd/cover/cover.go
src/cmd/dist/buildtool.go
src/cmd/distpack/pack.go
src/cmd/doc/main.go
src/cmd/fix/main.go
src/cmd/go/internal/help/help.go
src/cmd/go/internal/modfetch/cache.go
src/cmd/go/internal/telemetrystats/telemetrystats.go
src/cmd/go/internal/telemetrystats/version_other.go
src/cmd/go/internal/telemetrystats/version_unix.go
src/cmd/go/internal/telemetrystats/version_windows.go
src/cmd/go/internal/tool/tool.go
src/cmd/go/internal/toolchain/select.go
src/cmd/go/internal/toolchain/switch.go
src/cmd/go/internal/work/buildid.go
src/cmd/go/main.go
src/cmd/gofmt/gofmt.go
src/cmd/internal/telemetry/counter/counter.go [new file with mode: 0644]
src/cmd/internal/telemetry/counter/counter_bootstrap.go [new file with mode: 0644]
src/cmd/internal/telemetry/telemetry.go
src/cmd/internal/telemetry/telemetry_bootstrap.go
src/cmd/link/internal/ld/main.go
src/cmd/nm/nm.go
src/cmd/objdump/main.go
src/cmd/pack/pack.go
src/cmd/pprof/pprof.go
src/cmd/preprofile/main.go
src/cmd/test2json/main.go
src/cmd/trace/main.go
src/cmd/vet/main.go

index b1ec4e02785d7338a387455c1a6836e5545461c4..500da717ff3f2d84c4d76aaa2b323123651d1df0 100644 (file)
@@ -28,7 +28,7 @@ import (
        "strings"
 
        "cmd/internal/objfile"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 func printUsage(w *os.File) {
@@ -46,7 +46,7 @@ func usage() {
 func main() {
        log.SetFlags(0)
        log.SetPrefix("addr2line: ")
-       telemetry.OpenCounters()
+       counter.Open()
 
        // pprof expects this behavior when checking for addr2line
        if len(os.Args) > 1 && os.Args[1] == "--help" {
@@ -56,8 +56,8 @@ func main() {
 
        flag.Usage = usage
        flag.Parse()
-       telemetry.Inc("addr2line/invocations")
-       telemetry.CountFlags("addr2line/flag:", *flag.CommandLine)
+       counter.Inc("addr2line/invocations")
+       counter.CountFlags("addr2line/flag:", *flag.CommandLine)
        if flag.NArg() != 1 {
                usage()
        }
index ca4e25d047c4a9706960991f6ba12dfc67002881..9fdb7c49a2bb5631e5fe4309cd70b67de35a00e5 100644 (file)
@@ -20,20 +20,20 @@ import (
        "cmd/internal/bio"
        "cmd/internal/obj"
        "cmd/internal/objabi"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 func main() {
        log.SetFlags(0)
        log.SetPrefix("asm: ")
-       telemetry.OpenCounters()
+       counter.Open()
 
        buildcfg.Check()
        GOARCH := buildcfg.GOARCH
 
        flags.Parse()
-       telemetry.Inc("asm/invocations")
-       telemetry.CountFlags("asm/flag:", *flag.CommandLine)
+       counter.Inc("asm/invocations")
+       counter.CountFlags("asm/flag:", *flag.CommandLine)
 
        architecture := arch.Set(GOARCH, *flags.Shared || *flags.Dynlink)
        if architecture == nil {
index a008122a0aa743380071b2c23fc25a1f5cf4708a..a16b96f677a676ef7dcd902f332cd7391ce06c4d 100644 (file)
@@ -12,7 +12,7 @@ import (
        "strings"
 
        "cmd/internal/buildid"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 func usage() {
@@ -26,11 +26,11 @@ var wflag = flag.Bool("w", false, "write build ID")
 func main() {
        log.SetPrefix("buildid: ")
        log.SetFlags(0)
-       telemetry.OpenCounters()
+       counter.Open()
        flag.Usage = usage
        flag.Parse()
-       telemetry.Inc("buildid/invocations")
-       telemetry.CountFlags("buildid/flag:", *flag.CommandLine)
+       counter.Inc("buildid/invocations")
+       counter.CountFlags("buildid/flag:", *flag.CommandLine)
        if flag.NArg() != 1 {
                usage()
        }
index bf879be814fe997798204edb10b2e01f3e9b907b..156038b33b410c51f5c03d2c363497905bc0b98b 100644 (file)
@@ -28,7 +28,7 @@ import (
        "cmd/internal/edit"
        "cmd/internal/notsha256"
        "cmd/internal/objabi"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 // A Package collects information about the package we're going to write.
@@ -258,11 +258,11 @@ var goarch, goos, gomips, gomips64 string
 var gccBaseCmd []string
 
 func main() {
-       telemetry.OpenCounters()
+       counter.Open()
        objabi.AddVersionFlag() // -V
        objabi.Flagparse(usage)
-       telemetry.Inc("cgo/invocations")
-       telemetry.CountFlags("cgo/flag:", *flag.CommandLine)
+       counter.Inc("cgo/invocations")
+       counter.CountFlags("cgo/flag:", *flag.CommandLine)
 
        if *gccgoDefineCgoIncomplete {
                if !*gccgo {
index 8c17c5f27d8802f645f8f3340cea0650f7cdeda4..b296f3666cf4752c06466dba4da787e69201f6ed 100644 (file)
@@ -6,7 +6,7 @@ package base
 
 import (
        "cmd/internal/cov/covcmd"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
        "encoding/json"
        "flag"
        "fmt"
@@ -195,7 +195,7 @@ func ParseFlags() {
        objabi.AddVersionFlag() // -V
        registerFlags()
        objabi.Flagparse(usage)
-       telemetry.CountFlags("compile/flag:", *flag.CommandLine)
+       counter.CountFlags("compile/flag:", *flag.CommandLine)
 
        if gcd := os.Getenv("GOCOMPILEDEBUG"); gcd != "" {
                // This will only override the flags set in gcd;
index 15256186afe4dcad1d9e5c487a6e2c8ba2b9c57b..119f06fbc033518e5942ef64710ec1e965ec15d7 100644 (file)
@@ -14,7 +14,7 @@ import (
        "strings"
 
        "cmd/internal/src"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 // An errorMsg is a queued error message, waiting to be printed.
@@ -195,7 +195,7 @@ func Fatalf(format string, args ...interface{}) {
        FatalfAt(Pos, format, args...)
 }
 
-var bugStack = telemetry.NewStackCounter("compile/bug", 16) // 16 is arbitrary; used by gopls and crashmonitor
+var bugStack = counter.NewStack("compile/bug", 16) // 16 is arbitrary; used by gopls and crashmonitor
 
 // FatalfAt reports a fatal error - an internal problem - at pos and exits.
 // If other errors have already been printed, then FatalfAt just quietly exits.
index 3887d4156d6e3f4988c3888c3b6261e42cf226c5..f68cf4deaf041a92d34ba3ac610adb519e2bf2a6 100644 (file)
@@ -30,7 +30,7 @@ import (
        "cmd/internal/obj"
        "cmd/internal/objabi"
        "cmd/internal/src"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
        "flag"
        "fmt"
        "internal/buildcfg"
@@ -59,8 +59,8 @@ func handlePanic() {
 // code, and finally writes the compiled package definition to disk.
 func Main(archInit func(*ssagen.ArchInfo)) {
        base.Timer.Start("fe", "init")
-       telemetry.OpenCounters()
-       telemetry.Inc("compile/invocations")
+       counter.Open()
+       counter.Inc("compile/invocations")
 
        defer handlePanic()
 
index 48d7b9ed08915a786b15bd5d648a5cb2055edf8b..122ad28b5cafce6e2753e71f8ebf0afa440d0e32 100644 (file)
@@ -7,7 +7,7 @@ package main
 import (
        "cmd/internal/cov"
        "cmd/internal/pkgpattern"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
        "flag"
        "fmt"
        "os"
@@ -109,7 +109,7 @@ const (
 )
 
 func main() {
-       telemetry.OpenCounters()
+       counter.Open()
 
        // First argument should be mode/subcommand.
        if len(os.Args) < 2 {
@@ -146,8 +146,8 @@ func main() {
                op.Usage("")
        }
        flag.Parse()
-       telemetry.Inc("covdata/invocations")
-       telemetry.CountFlags("covdata/flag:", *flag.CommandLine)
+       counter.Inc("covdata/invocations")
+       counter.CountFlags("covdata/flag:", *flag.CommandLine)
 
        // Mode-independent flag setup
        dbgtrace(1, "starting mode-independent setup")
index 47eebaadd3a1ce4e3dc4c0f147edc8a6c5b37817..d8bb989bcce2444baf75405cbc25f9c25aeff665 100644 (file)
@@ -26,7 +26,7 @@ import (
 
        "cmd/internal/edit"
        "cmd/internal/objabi"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 const usageMessage = "" +
@@ -87,13 +87,13 @@ const (
 )
 
 func main() {
-       telemetry.OpenCounters()
+       counter.Open()
 
        objabi.AddVersionFlag()
        flag.Usage = usage
        objabi.Flagparse(usage)
-       telemetry.Inc("cover/invocations")
-       telemetry.CountFlags("cover/flag:", *flag.CommandLine)
+       counter.Inc("cover/invocations")
+       counter.CountFlags("cover/flag:", *flag.CommandLine)
 
        // Usage information when no arguments.
        if flag.NFlag() == 0 && flag.NArg() == 0 {
index 62f9693210230ad46a22cc277b1fcbc23e0ebc9e..9ca8fc539c43d448893e31f24f63a5e8bf45b67d 100644 (file)
@@ -53,6 +53,7 @@ var bootstrapDirs = []string{
        "cmd/internal/src",
        "cmd/internal/sys",
        "cmd/internal/telemetry",
+       "cmd/internal/telemetry/counter",
        "cmd/link",
        "cmd/link/internal/...",
        "compress/flate",
index 9ad33ee589cc8b45e20a96beaf03de4a6d50d7d2..552524936699f7b3ae34796e9b6ee49aa9563450 100644 (file)
@@ -45,7 +45,7 @@ import (
        "strings"
        "time"
 
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 func usage() {
@@ -69,11 +69,11 @@ var (
 func main() {
        log.SetPrefix("distpack: ")
        log.SetFlags(0)
-       telemetry.OpenCounters()
+       counter.Open()
        flag.Usage = usage
        flag.Parse()
-       telemetry.Inc("distpack/invocations")
-       telemetry.CountFlags("distpack/flag:", *flag.CommandLine)
+       counter.Inc("distpack/invocations")
+       counter.CountFlags("distpack/flag:", *flag.CommandLine)
        if flag.NArg() != 0 {
                usage()
        }
index 4dbddcb79fcd217c65ccd1ab2253ae88a50998c2..502de097f50688e2326b35c0660327334c4fb4de 100644 (file)
@@ -55,7 +55,7 @@ import (
        "path/filepath"
        "strings"
 
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 var (
@@ -87,7 +87,7 @@ func usage() {
 func main() {
        log.SetFlags(0)
        log.SetPrefix("doc: ")
-       telemetry.OpenCounters()
+       counter.Open()
        dirsInit()
        err := do(os.Stdout, flag.CommandLine, os.Args[1:])
        if err != nil {
@@ -108,8 +108,8 @@ func do(writer io.Writer, flagSet *flag.FlagSet, args []string) (err error) {
        flagSet.BoolVar(&showSrc, "src", false, "show source code for symbol")
        flagSet.BoolVar(&short, "short", false, "one-line representation for each symbol")
        flagSet.Parse(args)
-       telemetry.Inc("doc/invocations")
-       telemetry.CountFlags("doc/flag:", *flag.CommandLine)
+       counter.Inc("doc/invocations")
+       counter.CountFlags("doc/flag:", *flag.CommandLine)
        if chdir != "" {
                if err := os.Chdir(chdir); err != nil {
                        return err
index d915ece4ceb839e1570fac527e220ab26c8c95ed..6f1ff120da1057c8bfe59c5ee33e7f3c4721701a 100644 (file)
@@ -22,7 +22,7 @@ import (
        "sort"
        "strings"
 
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 var (
@@ -65,11 +65,11 @@ func usage() {
 }
 
 func main() {
-       telemetry.OpenCounters()
+       counter.Open()
        flag.Usage = usage
        flag.Parse()
-       telemetry.Inc("fix/invocations")
-       telemetry.CountFlags("fix/flag:", *flag.CommandLine)
+       counter.Inc("fix/invocations")
+       counter.CountFlags("fix/flag:", *flag.CommandLine)
 
        if !version.IsValid(*goVersion) {
                report(fmt.Errorf("invalid -go=%s", *goVersion))
index 98382f2423ad15434b8c20b60fc67ec21a3b97c8..4f2607fef2b89f082f96f22b01346226d48ceb3c 100644 (file)
@@ -16,10 +16,10 @@ import (
        "unicode/utf8"
 
        "cmd/go/internal/base"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
-var counterErrorsHelpUnknownTopic = telemetry.NewCounter("go/errors:help-unknown-topic")
+var counterErrorsHelpUnknownTopic = counter.New("go/errors:help-unknown-topic")
 
 // Help implements the 'help' command.
 func Help(w io.Writer, args []string) {
index 75b28b9bbc7f5d653eccd3ae0ba301e3197cc8db..02c4833a1b80100ecad6a8abc427bc3cb4fef235 100644 (file)
@@ -26,7 +26,7 @@ import (
        "cmd/go/internal/modfetch/codehost"
        "cmd/go/internal/par"
        "cmd/go/internal/robustio"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 
        "golang.org/x/mod/module"
        "golang.org/x/mod/semver"
@@ -779,7 +779,7 @@ var (
        statCacheOnce sync.Once
        statCacheErr  error
 
-       counterErrorsGOMODCACHEEntryRelative = telemetry.NewCounter("go/errors:gomodcache-entry-relative")
+       counterErrorsGOMODCACHEEntryRelative = counter.New("go/errors:gomodcache-entry-relative")
 )
 
 // checkCacheDir checks if the directory specified by GOMODCACHE exists. An
index 610c4a22e85a73a56e7be4916b1d8ce6a871ba2d..950453fa9513746324d4bde210e8a29bc0426d06 100644 (file)
@@ -10,7 +10,7 @@ import (
        "cmd/go/internal/base"
        "cmd/go/internal/cfg"
        "cmd/go/internal/modload"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 func Increment() {
@@ -22,30 +22,30 @@ func Increment() {
 // the command is running in.
 func incrementConfig() {
        if !modload.WillBeEnabled() {
-               telemetry.Inc("go/mode:gopath")
+               counter.Inc("go/mode:gopath")
        } else if workfile := modload.FindGoWork(base.Cwd()); workfile != "" {
-               telemetry.Inc("go/mode:workspace")
+               counter.Inc("go/mode:workspace")
        } else {
-               telemetry.Inc("go/mode:module")
+               counter.Inc("go/mode:module")
        }
-       telemetry.Inc("go/platform/target/goos:" + cfg.Goos)
-       telemetry.Inc("go/platform/target/goarch:" + cfg.Goarch)
+       counter.Inc("go/platform/target/goos:" + cfg.Goos)
+       counter.Inc("go/platform/target/goarch:" + cfg.Goarch)
        switch cfg.Goarch {
        case "386":
-               telemetry.Inc("go/platform/target/go386:" + cfg.GO386)
+               counter.Inc("go/platform/target/go386:" + cfg.GO386)
        case "amd64":
-               telemetry.Inc("go/platform/target/goamd64:" + cfg.GOAMD64)
+               counter.Inc("go/platform/target/goamd64:" + cfg.GOAMD64)
        case "arm":
-               telemetry.Inc("go/platform/target/goarm:" + cfg.GOARM)
+               counter.Inc("go/platform/target/goarm:" + cfg.GOARM)
        case "arm64":
-               telemetry.Inc("go/platform/target/goarm64:" + cfg.GOARM64)
+               counter.Inc("go/platform/target/goarm64:" + cfg.GOARM64)
        case "mips":
-               telemetry.Inc("go/platform/target/gomips:" + cfg.GOMIPS)
+               counter.Inc("go/platform/target/gomips:" + cfg.GOMIPS)
        case "ppc64":
-               telemetry.Inc("go/platform/target/goppc64:" + cfg.GOPPC64)
+               counter.Inc("go/platform/target/goppc64:" + cfg.GOPPC64)
        case "riscv64":
-               telemetry.Inc("go/platform/target/goriscv64:" + cfg.GORISCV64)
+               counter.Inc("go/platform/target/goriscv64:" + cfg.GORISCV64)
        case "wasm":
-               telemetry.Inc("go/platform/target/gowasm:" + cfg.GOWASM)
+               counter.Inc("go/platform/target/gowasm:" + cfg.GOWASM)
        }
 }
index b20294e2237f32fad5c1fb64601a6ed7120152ac..efce5fcf362985b2cd1863f53e6d497a882d5628 100644 (file)
@@ -6,8 +6,8 @@
 
 package telemetrystats
 
-import "cmd/internal/telemetry"
+import "cmd/internal/telemetry/counter"
 
 func incrementVersionCounters() {
-       telemetry.Inc("go/platform:version-not-supported")
+       counter.Inc("go/platform:version-not-supported")
 }
index 08259b7c89655e8bbc8356311d2055d60b86bff1..517e7829b68ef4768d2dfaaafb4322cf36478437 100644 (file)
@@ -12,7 +12,7 @@ import (
        "runtime"
        "strings"
 
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 
        "golang.org/x/sys/unix"
 )
@@ -29,7 +29,7 @@ func incrementVersionCounters() {
        var v unix.Utsname
        err := unix.Uname(&v)
        if err != nil {
-               telemetry.Inc(fmt.Sprintf("go/platform/host/%s/version:unknown-uname-error", runtime.GOOS))
+               counter.Inc(fmt.Sprintf("go/platform/host/%s/version:unknown-uname-error", runtime.GOOS))
                return
        }
        major, minor, ok := majorMinor(convert(v.Release[:]))
@@ -37,11 +37,11 @@ func incrementVersionCounters() {
                major, minor, ok = convert(v.Version[:]), convert(v.Release[:]), true
        }
        if !ok {
-               telemetry.Inc(fmt.Sprintf("go/platform/host/%s/version:unknown-bad-format", runtime.GOOS))
+               counter.Inc(fmt.Sprintf("go/platform/host/%s/version:unknown-bad-format", runtime.GOOS))
                return
        }
-       telemetry.Inc(fmt.Sprintf("go/platform/host/%s/major-version:%s", runtime.GOOS, major))
-       telemetry.Inc(fmt.Sprintf("go/platform/host/%s/version:%s-%s", runtime.GOOS, major, minor))
+       counter.Inc(fmt.Sprintf("go/platform/host/%s/major-version:%s", runtime.GOOS, major))
+       counter.Inc(fmt.Sprintf("go/platform/host/%s/version:%s-%s", runtime.GOOS, major, minor))
 }
 
 func majorMinor(v string) (string, string, bool) {
index e6a33e00cdc5685ae80121ce0016166f7c2ad8af..7de87193c67236223638240db64925370ce9fdcb 100644 (file)
@@ -9,14 +9,14 @@ package telemetrystats
 import (
        "fmt"
 
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 
        "golang.org/x/sys/windows"
 )
 
 func incrementVersionCounters() {
        v := windows.RtlGetVersion()
-       telemetry.Inc(fmt.Sprintf("go/platform/host/windows/major-version:%d", v.MajorVersion))
-       telemetry.Inc(fmt.Sprintf("go/platform/host/windows/version:%d-%d", v.MajorVersion, v.MinorVersion))
-       telemetry.Inc(fmt.Sprintf("go/platform/host/windows/build:%d", v.BuildNumber))
+       counter.Inc(fmt.Sprintf("go/platform/host/windows/major-version:%d", v.MajorVersion))
+       counter.Inc(fmt.Sprintf("go/platform/host/windows/version:%d-%d", v.MajorVersion, v.MinorVersion))
+       counter.Inc(fmt.Sprintf("go/platform/host/windows/build:%d", v.BuildNumber))
 }
index da219f041cf548afe7aa105265a1a261eee29db3..77cee564b3d557f95907a5cb8ba1740b163ef1c7 100644 (file)
@@ -6,7 +6,7 @@
 package tool
 
 import (
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
        "context"
        "encoding/json"
        "flag"
@@ -58,7 +58,7 @@ func init() {
 
 func runTool(ctx context.Context, cmd *base.Command, args []string) {
        if len(args) == 0 {
-               telemetry.Inc("go/subcommand:tool")
+               counter.Inc("go/subcommand:tool")
                listTools()
                return
        }
@@ -86,17 +86,17 @@ func runTool(ctx context.Context, cmd *base.Command, args []string) {
                        if impersonateDistList(args[2:]) {
                                // If it becomes necessary, we could increment an additional counter to indicate
                                // that we're impersonating dist list if knowing that becomes important?
-                               telemetry.Inc("go/subcommand:tool-dist")
+                               counter.Inc("go/subcommand:tool-dist")
                                return
                        }
                }
 
-               telemetry.Inc("go/subcommand:tool-unknown")
+               counter.Inc("go/subcommand:tool-unknown")
                // Emit the usual error for the missing tool.
                _ = base.Tool(toolName)
        } else {
                // Increment a counter for the tool subcommand with the tool name.
-               telemetry.Inc("go/subcommand:tool-" + toolName)
+               counter.Inc("go/subcommand:tool-" + toolName)
        }
 
        if toolN {
index d4787a844f07306a91a6f47842b6e6fd46a6e8aa..8e93e6c903308736fe5de01998da50936d8a1bbb 100644 (file)
@@ -26,7 +26,7 @@ import (
        "cmd/go/internal/modload"
        "cmd/go/internal/run"
        "cmd/go/internal/work"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 
        "golang.org/x/mod/module"
 )
@@ -82,7 +82,7 @@ func FilterEnv(env []string) []string {
        return out
 }
 
-var counterErrorsInvalidToolchainInFile = telemetry.NewCounter("go/errors:invalid-toolchain-in-file")
+var counterErrorsInvalidToolchainInFile = counter.New("go/errors:invalid-toolchain-in-file")
 
 // Select invokes a different Go toolchain if directed by
 // the GOTOOLCHAIN environment variable or the user's configuration
@@ -253,7 +253,7 @@ func Select() {
        Exec(gotoolchain)
 }
 
-var counterSelectExec = telemetry.NewCounter("go/toolchain/select-exec")
+var counterSelectExec = counter.New("go/toolchain/select-exec")
 
 // TestVersionSwitch is set in the test go binary to the value in $TESTGO_VERSION_SWITCH.
 // Valid settings are:
index ba1e6973cf4186b542d53bfd7614bc49472d0c03..37c1bcdcbec6567734a033622ebe5589d93e54ac 100644 (file)
@@ -16,7 +16,7 @@ import (
        "cmd/go/internal/cfg"
        "cmd/go/internal/gover"
        "cmd/go/internal/modfetch"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 // A Switcher collects errors to be reported and then decides
@@ -104,7 +104,7 @@ func (s *Switcher) Switch(ctx context.Context) {
        panic("unreachable")
 }
 
-var counterSwitchExec = telemetry.NewCounter("go/toolchain/switch-exec")
+var counterSwitchExec = counter.New("go/toolchain/switch-exec")
 
 // SwitchOrFatal attempts a toolchain switch based on the information in err
 // and otherwise falls back to base.Fatal(err).
index 889cc6ca508ef706a9b1bec375562a2146af4bd6..4ee43e24369286264ef69f9a373f25edb1140ca2 100644 (file)
@@ -19,7 +19,7 @@ import (
        "cmd/go/internal/str"
        "cmd/internal/buildid"
        "cmd/internal/quoted"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 // Build IDs
@@ -406,11 +406,11 @@ func (b *Builder) fileHash(file string) string {
 }
 
 var (
-       counterCacheHit  = telemetry.NewCounter("go/buildcache/hit")
-       counterCacheMiss = telemetry.NewCounter("go/buildcache/miss")
+       counterCacheHit  = counter.New("go/buildcache/hit")
+       counterCacheMiss = counter.New("go/buildcache/miss")
 
        onceIncStdlibRecompiled sync.Once
-       stdlibRecompiled        = telemetry.NewCounter("go/buildcache/stdlib-recompiled")
+       stdlibRecompiled        = counter.New("go/buildcache/stdlib-recompiled")
 )
 
 // useCache tries to satisfy the action a, which has action ID actionHash,
index eb33df1ad4c9296534eb893486195fefcea2bb51..1c58232a6621b98564627751c9b6b8ec514bbd77 100644 (file)
@@ -45,6 +45,7 @@ import (
        "cmd/go/internal/work"
        "cmd/go/internal/workcmd"
        "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 func init() {
@@ -91,20 +92,20 @@ func init() {
 
 var _ = go11tag
 
-var counterErrorsGOPATHEntryRelative = telemetry.NewCounter("go/errors:gopath-entry-relative")
+var counterErrorsGOPATHEntryRelative = counter.New("go/errors:gopath-entry-relative")
 
 func main() {
        log.SetFlags(0)
-       telemetry.MaybeChild()   // Run in child mode if this is the telemetry sidecar child process.
-       telemetry.OpenCounters() // Open the telemetry counter file so counters can be written to it.
+       telemetry.MaybeChild() // Run in child mode if this is the telemetry sidecar child process.
+       counter.Open()         // Open the telemetry counter file so counters can be written to it.
        handleChdirFlag()
        toolchain.Select()
 
        telemetry.MaybeParent() // Run the upload process. Opening the counter file is idempotent.
        flag.Usage = base.Usage
        flag.Parse()
-       telemetry.Inc("go/invocations")
-       telemetry.CountFlags("go/flag:", *flag.CommandLine)
+       counter.Inc("go/invocations")
+       counter.CountFlags("go/flag:", *flag.CommandLine)
 
        args := flag.Args()
        if len(args) < 1 {
@@ -113,7 +114,7 @@ func main() {
 
        cfg.CmdName = args[0] // for error messages
        if args[0] == "help" {
-               telemetry.Inc("go/subcommand:" + strings.Join(append([]string{"help"}, args[1:]...), "-"))
+               counter.Inc("go/subcommand:" + strings.Join(append([]string{"help"}, args[1:]...), "-"))
                help.Help(os.Stdout, args[1:])
                return
        }
@@ -128,17 +129,17 @@ func main() {
        }
        switch strings.ToLower(cfg.GOROOT) {
        case "/usr/local/go": // Location recommended for installation on Linux and Darwin and used by Mac installer.
-               telemetry.Inc("go/goroot:usr-local-go")
+               counter.Inc("go/goroot:usr-local-go")
        case "/usr/lib/go": // A typical location used by Linux package managers.
-               telemetry.Inc("go/goroot:usr-lib-go")
+               counter.Inc("go/goroot:usr-lib-go")
        case "/usr/lib/golang": // Another typical location used by Linux package managers.
-               telemetry.Inc("go/goroot:usr-lib-golang")
+               counter.Inc("go/goroot:usr-lib-golang")
        case `c:\program files\go`: // Location used by Windows installer.
-               telemetry.Inc("go/goroot:program-files-go")
+               counter.Inc("go/goroot:program-files-go")
        case `c:\program files (x86)\go`: // Location used by 386 Windows installer on amd64 platform.
-               telemetry.Inc("go/goroot:program-files-x86-go")
+               counter.Inc("go/goroot:program-files-x86-go")
        default:
-               telemetry.Inc("go/goroot:other")
+               counter.Inc("go/goroot:other")
        }
 
        // Diagnose common mistake: GOPATH==GOROOT.
@@ -184,7 +185,7 @@ func main() {
                }
                if args[used] == "help" {
                        // Accept 'go mod help' and 'go mod help foo' for 'go help mod' and 'go help mod foo'.
-                       telemetry.Inc("go/subcommand:" + strings.ReplaceAll(cfg.CmdName, " ", "-") + "-" + strings.Join(args[used:], "-"))
+                       counter.Inc("go/subcommand:" + strings.ReplaceAll(cfg.CmdName, " ", "-") + "-" + strings.Join(args[used:], "-"))
                        help.Help(os.Stdout, append(slices.Clip(args[:used]), args[used+1:]...))
                        base.Exit()
                }
@@ -196,7 +197,7 @@ func main() {
                if cmdName == "" {
                        cmdName = args[0]
                }
-               telemetry.Inc("go/subcommand:unknown")
+               counter.Inc("go/subcommand:unknown")
                fmt.Fprintf(os.Stderr, "go %s: unknown command\nRun 'go help%s' for usage.\n", cmdName, helpArg)
                base.SetExitStatus(2)
                base.Exit()
@@ -206,7 +207,7 @@ func main() {
        // increment in the tool subcommand's Run function because we need
        // to do the flag processing in invoke first.
        if cfg.CmdName != "tool" {
-               telemetry.Inc("go/subcommand:" + strings.ReplaceAll(cfg.CmdName, " ", "-"))
+               counter.Inc("go/subcommand:" + strings.ReplaceAll(cfg.CmdName, " ", "-"))
        }
        telemetrystats.Increment()
        invoke(cmd, args[used-1:])
@@ -274,8 +275,8 @@ func invoke(cmd *base.Command, args []string) {
                base.SetFromGOFLAGS(&cmd.Flag)
                cmd.Flag.Parse(args[1:])
                flagCounterPrefix := "go/" + strings.ReplaceAll(cfg.CmdName, " ", "-") + "/flag"
-               telemetry.CountFlags(flagCounterPrefix+":", cmd.Flag)
-               telemetry.CountFlagValue(flagCounterPrefix+"/", cmd.Flag, "buildmode")
+               counter.CountFlags(flagCounterPrefix+":", cmd.Flag)
+               counter.CountFlagValue(flagCounterPrefix+"/", cmd.Flag, "buildmode")
                args = cmd.Flag.Args()
        }
 
@@ -361,7 +362,7 @@ func handleChdirFlag() {
                _, dir, _ = strings.Cut(a, "=")
                os.Args = slices.Delete(os.Args, used, used+1)
        }
-       telemetry.Inc("go/flag:C")
+       counter.Inc("go/flag:C")
 
        if err := os.Chdir(dir); err != nil {
                base.Fatalf("go: %v", err)
index d6721f9327316d33aac605feea93451c235669db..d91a75b1050e2090e92bfbfec92e72edc61c7c99 100644 (file)
@@ -25,7 +25,7 @@ import (
        "strconv"
        "strings"
 
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 
        "golang.org/x/sync/semaphore"
 )
@@ -374,11 +374,11 @@ func main() {
 }
 
 func gofmtMain(s *sequencer) {
-       telemetry.OpenCounters()
+       counter.Open()
        flag.Usage = usage
        flag.Parse()
-       telemetry.Inc("gofmt/invocations")
-       telemetry.CountFlags("gofmt/flag:", *flag.CommandLine)
+       counter.Inc("gofmt/invocations")
+       counter.CountFlags("gofmt/flag:", *flag.CommandLine)
 
        if *cpuprofile != "" {
                fdSem <- true
diff --git a/src/cmd/internal/telemetry/counter/counter.go b/src/cmd/internal/telemetry/counter/counter.go
new file mode 100644 (file)
index 0000000..5cef0b0
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// 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 && !compiler_bootstrap
+
+package counter
+
+import (
+       "flag"
+       "os"
+
+       "golang.org/x/telemetry/counter"
+)
+
+var openCalled bool
+
+func OpenCalled() bool { return openCalled }
+
+// Open opens the counter files for writing if telemetry is supported
+// on the current platform (and does nothing otherwise).
+func Open() {
+       openCalled = true
+       counter.OpenDir(os.Getenv("TEST_TELEMETRY_DIR"))
+}
+
+// Inc increments the counter with the given name.
+func Inc(name string) {
+       counter.Inc(name)
+}
+
+// New returns a counter with the given name.
+func New(name string) *counter.Counter {
+       return counter.New(name)
+}
+
+// NewStack returns a new stack counter with the given name and depth.
+func NewStack(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)
+}
+
+// CountFlagValue creates a counter for the flag value
+// if it is set and increments the counter. The name of the
+// counter is the concatenation of prefix, the flagName, ":",
+// and value.String() for the flag's value.
+func CountFlagValue(prefix string, flagSet flag.FlagSet, flagName string) {
+       // TODO(matloob): Maybe pass in a list of flagNames if we end up counting
+       // values for more than one?
+       // TODO(matloob): Add this to x/telemetry?
+       flagSet.Visit(func(f *flag.Flag) {
+               if f.Name == flagName {
+                       counter.New(prefix + f.Name + ":" + f.Value.String()).Inc()
+               }
+       })
+}
diff --git a/src/cmd/internal/telemetry/counter/counter_bootstrap.go b/src/cmd/internal/telemetry/counter/counter_bootstrap.go
new file mode 100644 (file)
index 0000000..0080829
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// 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 || compiler_bootstrap
+
+package counter
+
+import "flag"
+
+type dummyCounter struct{}
+
+func (dc dummyCounter) Inc() {}
+
+func Open()                                                               {}
+func Inc(name string)                                                     {}
+func New(name string) dummyCounter                                        { return dummyCounter{} }
+func NewStack(name string, depth int) dummyCounter                        { return dummyCounter{} }
+func CountFlags(name string, flagSet flag.FlagSet)                        {}
+func CountFlagValue(prefix string, flagSet flag.FlagSet, flagName string) {}
index b0c864a1a95ec6a4b0de08f0fb5a39005aa97f57..ca84fe39b18438db5f269202dfad6f2b7d153952 100644 (file)
 package telemetry
 
 import (
-       "flag"
        "os"
 
+       "cmd/internal/telemetry/counter"
+
        "golang.org/x/telemetry"
-       "golang.org/x/telemetry/counter"
 )
 
 var openCountersCalled, maybeChildCalled bool
 
-// OpenCounters opens the counter files for writing if telemetry is supported
-// on the current platform (and does nothing otherwise).
-func OpenCounters() {
-       openCountersCalled = true
-       telemetry.Start(telemetry.Config{
-               TelemetryDir: os.Getenv("TEST_TELEMETRY_DIR"),
-       })
-}
-
 // MaybeParent does a once a day check to see if the weekly reports are
 // ready to be processed or uploaded, and if so, starts the telemetry child to
 // do so. It should only be called by cmd/go, and only after OpenCounters and MaybeChild
 // have already been called.
 func MaybeParent() {
-       if !openCountersCalled || !maybeChildCalled {
+       if !counter.OpenCalled() || !maybeChildCalled {
                panic("MaybeParent must be called after OpenCounters and MaybeChild")
        }
        telemetry.Start(telemetry.Config{
@@ -56,43 +47,6 @@ func MaybeChild() {
        })
 }
 
-// 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)
-}
-
-// NewStackCounter 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)
-}
-
-// CountFlagValue creates a counter for the flag value
-// if it is set and increments the counter. The name of the
-// counter is the concatenation of prefix, the flagName, ":",
-// and value.String() for the flag's value.
-func CountFlagValue(prefix string, flagSet flag.FlagSet, flagName string) {
-       // TODO(matloob): Maybe pass in a list of flagNames if we end up counting
-       // values for more than one?
-       // TODO(matloob): Add this to x/telemetry?
-       flagSet.Visit(func(f *flag.Flag) {
-               if f.Name == flagName {
-                       counter.New(prefix + f.Name + ":" + f.Value.String()).Inc()
-               }
-       })
-}
-
 // Mode returns the current telemetry mode.
 //
 // The telemetry mode is a global value that controls both the local collection
index 05c0ee1c56e9c94faa6a7dffc5c9714386f716d9..e301e30cc8175f7c0d8dc72a7d70b97886605b27 100644 (file)
@@ -6,20 +6,8 @@
 
 package telemetry
 
-import "flag"
-
-type dummyCounter struct{}
-
-func (dc dummyCounter) Inc() {}
-
-func OpenCounters()                                                       {}
-func MaybeParent()                                                        {}
-func MaybeChild()                                                         {}
-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)                        {}
-func CountFlagValue(prefix string, flagSet flag.FlagSet, flagName string) {}
-func Mode() string                                                        { return "" }
-func SetMode(mode string) error                                           { return nil }
-func Dir() string                                                         { return "" }
+func MaybeParent()              {}
+func MaybeChild()               {}
+func Mode() string              { return "" }
+func SetMode(mode string) error { return nil }
+func Dir() string               { return "" }
index 3183e1a13ed86606e4f42f1a6ff36bc7fa97b711..56e865d8a5328737592dbb3afa7cc4118b704e62 100644 (file)
@@ -36,7 +36,7 @@ import (
        "cmd/internal/objabi"
        "cmd/internal/quoted"
        "cmd/internal/sys"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
        "cmd/link/internal/benchmark"
        "flag"
        "internal/buildcfg"
@@ -157,8 +157,8 @@ func (t *ternaryFlag) IsBoolFlag() bool { return true } // parse like a boolean
 func Main(arch *sys.Arch, theArch Arch) {
        log.SetPrefix("link: ")
        log.SetFlags(0)
-       telemetry.OpenCounters()
-       telemetry.Inc("link/invocations")
+       counter.Open()
+       counter.Inc("link/invocations")
 
        thearch = theArch
        ctxt := linknew(arch)
@@ -204,7 +204,7 @@ func Main(arch *sys.Arch, theArch Arch) {
        objabi.Flagfn1("importcfg", "read import configuration from `file`", ctxt.readImportCfg)
 
        objabi.Flagparse(usage)
-       telemetry.CountFlags("link/flag:", *flag.CommandLine)
+       counter.CountFlags("link/flag:", *flag.CommandLine)
 
        if ctxt.Debugvlog > 0 {
                // dump symbol info on crash
index e0d98d5f6c67d015e331e9df9ce830675abeb46a..752870654d5ccd1c57a3ab178e921904fc4b14cb 100644 (file)
@@ -13,7 +13,7 @@ import (
        "sort"
 
        "cmd/internal/objfile"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 const helpText = `usage: go tool nm [options] file...
@@ -68,11 +68,11 @@ func (nflag) String() string {
 
 func main() {
        log.SetFlags(0)
-       telemetry.OpenCounters()
+       counter.Open()
        flag.Usage = usage
        flag.Parse()
-       telemetry.Inc("nm/invocations")
-       telemetry.CountFlags("nm/flag:", *flag.CommandLine)
+       counter.Inc("nm/invocations")
+       counter.CountFlags("nm/flag:", *flag.CommandLine)
 
        switch *sortOrder {
        case "address", "name", "none", "size":
index 7554b5500c1216604e6402c05200b6074aa5fa9a..b5b0d7f5178d5bf4aa13ba81c7a29ae25a222640 100644 (file)
@@ -41,7 +41,7 @@ import (
        "strings"
 
        "cmd/internal/objfile"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 )
 
 var printCode = flag.Bool("S", false, "print Go code alongside assembly")
@@ -58,12 +58,12 @@ func usage() {
 func main() {
        log.SetFlags(0)
        log.SetPrefix("objdump: ")
-       telemetry.OpenCounters()
+       counter.Open()
 
        flag.Usage = usage
        flag.Parse()
-       telemetry.Inc("objdump/invocations")
-       telemetry.CountFlags("objdump/flag:", *flag.CommandLine)
+       counter.Inc("objdump/invocations")
+       counter.CountFlags("objdump/flag:", *flag.CommandLine)
        if flag.NArg() != 1 && flag.NArg() != 3 {
                usage()
        }
index 28f217ace1b57ee0006a1299077619f45a8c4546..4ac6ce995fe9185ff8b20065e28e34bfe6ca2237 100644 (file)
@@ -6,7 +6,7 @@ package main
 
 import (
        "cmd/internal/archive"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
        "fmt"
        "io"
        "io/fs"
@@ -31,7 +31,7 @@ func usage() {
 func main() {
        log.SetFlags(0)
        log.SetPrefix("pack: ")
-       telemetry.OpenCounters()
+       counter.Open()
        // need "pack op archive" at least.
        if len(os.Args) < 3 {
                log.Print("not enough arguments")
@@ -39,8 +39,8 @@ func main() {
                usage()
        }
        setOp(os.Args[1])
-       telemetry.Inc("pack/invocations")
-       telemetry.Inc("pack/op:" + string(op))
+       counter.Inc("pack/invocations")
+       counter.Inc("pack/op:" + string(op))
        var ar *Archive
        switch op {
        case 'p':
index 722b745287eec1ffe1560ef3acd93c4fd61f5e31..a1c2cd210f8dbaf2c3d4d49739af962e6793120f 100644 (file)
@@ -25,22 +25,22 @@ import (
        "time"
 
        "cmd/internal/objfile"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
 
        "github.com/google/pprof/driver"
        "github.com/google/pprof/profile"
 )
 
 func main() {
-       telemetry.OpenCounters()
-       telemetry.Inc("pprof/invocations")
+       counter.Open()
+       counter.Inc("pprof/invocations")
        options := &driver.Options{
                Fetch: new(fetcher),
                Obj:   new(objTool),
                UI:    newUI(),
        }
        err := driver.PProf(options)
-       telemetry.CountFlags("pprof/flag:", *flag.CommandLine) // pprof will use the flag package as its default
+       counter.CountFlags("pprof/flag:", *flag.CommandLine) // pprof will use the flag package as its default
        if err != nil {
                fmt.Fprintf(os.Stderr, "%v\n", err)
                os.Exit(2)
index 1260eed10471ee8044c2420ce42f3730650eb2c7..60aa1f7cc6cdd66ea11816bc4439e5018c220c84 100644 (file)
@@ -18,7 +18,7 @@ import (
        "bufio"
        "cmd/internal/objabi"
        "cmd/internal/pgo"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
        "flag"
        "fmt"
        "log"
@@ -73,12 +73,12 @@ func main() {
 
        log.SetFlags(0)
        log.SetPrefix("preprofile: ")
-       telemetry.OpenCounters()
+       counter.Open()
 
        flag.Usage = usage
        flag.Parse()
-       telemetry.Inc("preprofile/invocations")
-       telemetry.CountFlags("preprofile/flag:", *flag.CommandLine)
+       counter.Inc("preprofile/invocations")
+       counter.CountFlags("preprofile/flag:", *flag.CommandLine)
        if *input == "" {
                log.Print("Input pprof path required (-i)")
                usage()
index 844ee5aa6c6cc13c47600c9f758e37e06f9627bc..b704dd4d31a5e537821e9a956963e5473de7a08f 100644 (file)
@@ -96,7 +96,7 @@ import (
        "os/exec"
        "os/signal"
 
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
        "cmd/internal/test2json"
 )
 
@@ -116,12 +116,12 @@ func ignoreSignals() {
 }
 
 func main() {
-       telemetry.OpenCounters()
+       counter.Open()
 
        flag.Usage = usage
        flag.Parse()
-       telemetry.Inc("test2json/invocations")
-       telemetry.CountFlags("test2json/flag:", *flag.CommandLine)
+       counter.Inc("test2json/invocations")
+       counter.CountFlags("test2json/flag:", *flag.CommandLine)
 
        var mode test2json.Mode
        if *flagT {
index e48048b9f257caa3cc39ff48850be9ab55192efc..d51ee5816456bf9a1e120e653b987b17e9f9bda8 100644 (file)
@@ -6,7 +6,7 @@ package main
 
 import (
        "cmd/internal/browser"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
        "flag"
        "fmt"
        "internal/trace"
@@ -64,14 +64,14 @@ var (
 )
 
 func main() {
-       telemetry.OpenCounters()
+       counter.Open()
        flag.Usage = func() {
                fmt.Fprint(os.Stderr, usageMessage)
                os.Exit(2)
        }
        flag.Parse()
-       telemetry.Inc("trace/invocations")
-       telemetry.CountFlags("trace/flag:", *flag.CommandLine)
+       counter.Inc("trace/invocations")
+       counter.CountFlags("trace/flag:", *flag.CommandLine)
 
        // Go 1.7 traces embed symbol info and does not require the binary.
        // But we optionally accept binary as first arg for Go 1.5 traces.
index 84821d43fcb149a12fe25a6d86b5814e0973606c..3ace8ad6897b888adc9717b7f1012a6614774ac6 100644 (file)
@@ -6,7 +6,7 @@ package main
 
 import (
        "cmd/internal/objabi"
-       "cmd/internal/telemetry"
+       "cmd/internal/telemetry/counter"
        "flag"
 
        "golang.org/x/tools/go/analysis/unitchecker"
@@ -47,10 +47,10 @@ import (
 )
 
 func main() {
-       telemetry.OpenCounters()
+       counter.Open()
        objabi.AddVersionFlag()
 
-       telemetry.Inc("vet/invocations")
+       counter.Inc("vet/invocations")
        unitchecker.Main(
                appends.Analyzer,
                asmdecl.Analyzer,
@@ -89,5 +89,5 @@ func main() {
 
        // It's possible that unitchecker will exit early. In
        // those cases the flags won't be counted.
-       telemetry.CountFlags("vet/flag:", *flag.CommandLine)
+       counter.CountFlags("vet/flag:", *flag.CommandLine)
 }