cmd/internal: separate counter package from telemetry package

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>
This commit is contained in:
Michael Matloob 2024-06-21 14:35:14 -04:00
parent 52ce25b44e
commit d79c350916
38 changed files with 236 additions and 210 deletions

View file

@ -28,7 +28,7 @@ import (
"strings" "strings"
"cmd/internal/objfile" "cmd/internal/objfile"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
func printUsage(w *os.File) { func printUsage(w *os.File) {
@ -46,7 +46,7 @@ func usage() {
func main() { func main() {
log.SetFlags(0) log.SetFlags(0)
log.SetPrefix("addr2line: ") log.SetPrefix("addr2line: ")
telemetry.OpenCounters() counter.Open()
// pprof expects this behavior when checking for addr2line // pprof expects this behavior when checking for addr2line
if len(os.Args) > 1 && os.Args[1] == "--help" { if len(os.Args) > 1 && os.Args[1] == "--help" {
@ -56,8 +56,8 @@ func main() {
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
telemetry.Inc("addr2line/invocations") counter.Inc("addr2line/invocations")
telemetry.CountFlags("addr2line/flag:", *flag.CommandLine) counter.CountFlags("addr2line/flag:", *flag.CommandLine)
if flag.NArg() != 1 { if flag.NArg() != 1 {
usage() usage()
} }

View file

@ -20,20 +20,20 @@ import (
"cmd/internal/bio" "cmd/internal/bio"
"cmd/internal/obj" "cmd/internal/obj"
"cmd/internal/objabi" "cmd/internal/objabi"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
func main() { func main() {
log.SetFlags(0) log.SetFlags(0)
log.SetPrefix("asm: ") log.SetPrefix("asm: ")
telemetry.OpenCounters() counter.Open()
buildcfg.Check() buildcfg.Check()
GOARCH := buildcfg.GOARCH GOARCH := buildcfg.GOARCH
flags.Parse() flags.Parse()
telemetry.Inc("asm/invocations") counter.Inc("asm/invocations")
telemetry.CountFlags("asm/flag:", *flag.CommandLine) counter.CountFlags("asm/flag:", *flag.CommandLine)
architecture := arch.Set(GOARCH, *flags.Shared || *flags.Dynlink) architecture := arch.Set(GOARCH, *flags.Shared || *flags.Dynlink)
if architecture == nil { if architecture == nil {

View file

@ -12,7 +12,7 @@ import (
"strings" "strings"
"cmd/internal/buildid" "cmd/internal/buildid"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
func usage() { func usage() {
@ -26,11 +26,11 @@ var wflag = flag.Bool("w", false, "write build ID")
func main() { func main() {
log.SetPrefix("buildid: ") log.SetPrefix("buildid: ")
log.SetFlags(0) log.SetFlags(0)
telemetry.OpenCounters() counter.Open()
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
telemetry.Inc("buildid/invocations") counter.Inc("buildid/invocations")
telemetry.CountFlags("buildid/flag:", *flag.CommandLine) counter.CountFlags("buildid/flag:", *flag.CommandLine)
if flag.NArg() != 1 { if flag.NArg() != 1 {
usage() usage()
} }

View file

@ -28,7 +28,7 @@ import (
"cmd/internal/edit" "cmd/internal/edit"
"cmd/internal/notsha256" "cmd/internal/notsha256"
"cmd/internal/objabi" "cmd/internal/objabi"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
// A Package collects information about the package we're going to write. // 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 var gccBaseCmd []string
func main() { func main() {
telemetry.OpenCounters() counter.Open()
objabi.AddVersionFlag() // -V objabi.AddVersionFlag() // -V
objabi.Flagparse(usage) objabi.Flagparse(usage)
telemetry.Inc("cgo/invocations") counter.Inc("cgo/invocations")
telemetry.CountFlags("cgo/flag:", *flag.CommandLine) counter.CountFlags("cgo/flag:", *flag.CommandLine)
if *gccgoDefineCgoIncomplete { if *gccgoDefineCgoIncomplete {
if !*gccgo { if !*gccgo {

View file

@ -6,7 +6,7 @@ package base
import ( import (
"cmd/internal/cov/covcmd" "cmd/internal/cov/covcmd"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
@ -195,7 +195,7 @@ func ParseFlags() {
objabi.AddVersionFlag() // -V objabi.AddVersionFlag() // -V
registerFlags() registerFlags()
objabi.Flagparse(usage) objabi.Flagparse(usage)
telemetry.CountFlags("compile/flag:", *flag.CommandLine) counter.CountFlags("compile/flag:", *flag.CommandLine)
if gcd := os.Getenv("GOCOMPILEDEBUG"); gcd != "" { if gcd := os.Getenv("GOCOMPILEDEBUG"); gcd != "" {
// This will only override the flags set in gcd; // This will only override the flags set in gcd;

View file

@ -14,7 +14,7 @@ import (
"strings" "strings"
"cmd/internal/src" "cmd/internal/src"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
// An errorMsg is a queued error message, waiting to be printed. // 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...) 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. // FatalfAt reports a fatal error - an internal problem - at pos and exits.
// If other errors have already been printed, then FatalfAt just quietly exits. // If other errors have already been printed, then FatalfAt just quietly exits.

View file

@ -30,7 +30,7 @@ import (
"cmd/internal/obj" "cmd/internal/obj"
"cmd/internal/objabi" "cmd/internal/objabi"
"cmd/internal/src" "cmd/internal/src"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"flag" "flag"
"fmt" "fmt"
"internal/buildcfg" "internal/buildcfg"
@ -59,8 +59,8 @@ func handlePanic() {
// code, and finally writes the compiled package definition to disk. // code, and finally writes the compiled package definition to disk.
func Main(archInit func(*ssagen.ArchInfo)) { func Main(archInit func(*ssagen.ArchInfo)) {
base.Timer.Start("fe", "init") base.Timer.Start("fe", "init")
telemetry.OpenCounters() counter.Open()
telemetry.Inc("compile/invocations") counter.Inc("compile/invocations")
defer handlePanic() defer handlePanic()

View file

@ -7,7 +7,7 @@ package main
import ( import (
"cmd/internal/cov" "cmd/internal/cov"
"cmd/internal/pkgpattern" "cmd/internal/pkgpattern"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"flag" "flag"
"fmt" "fmt"
"os" "os"
@ -109,7 +109,7 @@ const (
) )
func main() { func main() {
telemetry.OpenCounters() counter.Open()
// First argument should be mode/subcommand. // First argument should be mode/subcommand.
if len(os.Args) < 2 { if len(os.Args) < 2 {
@ -146,8 +146,8 @@ func main() {
op.Usage("") op.Usage("")
} }
flag.Parse() flag.Parse()
telemetry.Inc("covdata/invocations") counter.Inc("covdata/invocations")
telemetry.CountFlags("covdata/flag:", *flag.CommandLine) counter.CountFlags("covdata/flag:", *flag.CommandLine)
// Mode-independent flag setup // Mode-independent flag setup
dbgtrace(1, "starting mode-independent setup") dbgtrace(1, "starting mode-independent setup")

View file

@ -26,7 +26,7 @@ import (
"cmd/internal/edit" "cmd/internal/edit"
"cmd/internal/objabi" "cmd/internal/objabi"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
const usageMessage = "" + const usageMessage = "" +
@ -87,13 +87,13 @@ const (
) )
func main() { func main() {
telemetry.OpenCounters() counter.Open()
objabi.AddVersionFlag() objabi.AddVersionFlag()
flag.Usage = usage flag.Usage = usage
objabi.Flagparse(usage) objabi.Flagparse(usage)
telemetry.Inc("cover/invocations") counter.Inc("cover/invocations")
telemetry.CountFlags("cover/flag:", *flag.CommandLine) counter.CountFlags("cover/flag:", *flag.CommandLine)
// Usage information when no arguments. // Usage information when no arguments.
if flag.NFlag() == 0 && flag.NArg() == 0 { if flag.NFlag() == 0 && flag.NArg() == 0 {

View file

@ -53,6 +53,7 @@ var bootstrapDirs = []string{
"cmd/internal/src", "cmd/internal/src",
"cmd/internal/sys", "cmd/internal/sys",
"cmd/internal/telemetry", "cmd/internal/telemetry",
"cmd/internal/telemetry/counter",
"cmd/link", "cmd/link",
"cmd/link/internal/...", "cmd/link/internal/...",
"compress/flate", "compress/flate",

View file

@ -45,7 +45,7 @@ import (
"strings" "strings"
"time" "time"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
func usage() { func usage() {
@ -69,11 +69,11 @@ var (
func main() { func main() {
log.SetPrefix("distpack: ") log.SetPrefix("distpack: ")
log.SetFlags(0) log.SetFlags(0)
telemetry.OpenCounters() counter.Open()
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
telemetry.Inc("distpack/invocations") counter.Inc("distpack/invocations")
telemetry.CountFlags("distpack/flag:", *flag.CommandLine) counter.CountFlags("distpack/flag:", *flag.CommandLine)
if flag.NArg() != 0 { if flag.NArg() != 0 {
usage() usage()
} }

View file

@ -55,7 +55,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
var ( var (
@ -87,7 +87,7 @@ func usage() {
func main() { func main() {
log.SetFlags(0) log.SetFlags(0)
log.SetPrefix("doc: ") log.SetPrefix("doc: ")
telemetry.OpenCounters() counter.Open()
dirsInit() dirsInit()
err := do(os.Stdout, flag.CommandLine, os.Args[1:]) err := do(os.Stdout, flag.CommandLine, os.Args[1:])
if err != nil { 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(&showSrc, "src", false, "show source code for symbol")
flagSet.BoolVar(&short, "short", false, "one-line representation for each symbol") flagSet.BoolVar(&short, "short", false, "one-line representation for each symbol")
flagSet.Parse(args) flagSet.Parse(args)
telemetry.Inc("doc/invocations") counter.Inc("doc/invocations")
telemetry.CountFlags("doc/flag:", *flag.CommandLine) counter.CountFlags("doc/flag:", *flag.CommandLine)
if chdir != "" { if chdir != "" {
if err := os.Chdir(chdir); err != nil { if err := os.Chdir(chdir); err != nil {
return err return err

View file

@ -22,7 +22,7 @@ import (
"sort" "sort"
"strings" "strings"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
var ( var (
@ -65,11 +65,11 @@ func usage() {
} }
func main() { func main() {
telemetry.OpenCounters() counter.Open()
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
telemetry.Inc("fix/invocations") counter.Inc("fix/invocations")
telemetry.CountFlags("fix/flag:", *flag.CommandLine) counter.CountFlags("fix/flag:", *flag.CommandLine)
if !version.IsValid(*goVersion) { if !version.IsValid(*goVersion) {
report(fmt.Errorf("invalid -go=%s", *goVersion)) report(fmt.Errorf("invalid -go=%s", *goVersion))

View file

@ -16,10 +16,10 @@ import (
"unicode/utf8" "unicode/utf8"
"cmd/go/internal/base" "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. // Help implements the 'help' command.
func Help(w io.Writer, args []string) { func Help(w io.Writer, args []string) {

View file

@ -26,7 +26,7 @@ import (
"cmd/go/internal/modfetch/codehost" "cmd/go/internal/modfetch/codehost"
"cmd/go/internal/par" "cmd/go/internal/par"
"cmd/go/internal/robustio" "cmd/go/internal/robustio"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"golang.org/x/mod/module" "golang.org/x/mod/module"
"golang.org/x/mod/semver" "golang.org/x/mod/semver"
@ -779,7 +779,7 @@ var (
statCacheOnce sync.Once statCacheOnce sync.Once
statCacheErr error 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 // checkCacheDir checks if the directory specified by GOMODCACHE exists. An

View file

@ -10,7 +10,7 @@ import (
"cmd/go/internal/base" "cmd/go/internal/base"
"cmd/go/internal/cfg" "cmd/go/internal/cfg"
"cmd/go/internal/modload" "cmd/go/internal/modload"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
func Increment() { func Increment() {
@ -22,30 +22,30 @@ func Increment() {
// the command is running in. // the command is running in.
func incrementConfig() { func incrementConfig() {
if !modload.WillBeEnabled() { if !modload.WillBeEnabled() {
telemetry.Inc("go/mode:gopath") counter.Inc("go/mode:gopath")
} else if workfile := modload.FindGoWork(base.Cwd()); workfile != "" { } else if workfile := modload.FindGoWork(base.Cwd()); workfile != "" {
telemetry.Inc("go/mode:workspace") counter.Inc("go/mode:workspace")
} else { } else {
telemetry.Inc("go/mode:module") counter.Inc("go/mode:module")
} }
telemetry.Inc("go/platform/target/goos:" + cfg.Goos) counter.Inc("go/platform/target/goos:" + cfg.Goos)
telemetry.Inc("go/platform/target/goarch:" + cfg.Goarch) counter.Inc("go/platform/target/goarch:" + cfg.Goarch)
switch cfg.Goarch { switch cfg.Goarch {
case "386": case "386":
telemetry.Inc("go/platform/target/go386:" + cfg.GO386) counter.Inc("go/platform/target/go386:" + cfg.GO386)
case "amd64": case "amd64":
telemetry.Inc("go/platform/target/goamd64:" + cfg.GOAMD64) counter.Inc("go/platform/target/goamd64:" + cfg.GOAMD64)
case "arm": case "arm":
telemetry.Inc("go/platform/target/goarm:" + cfg.GOARM) counter.Inc("go/platform/target/goarm:" + cfg.GOARM)
case "arm64": case "arm64":
telemetry.Inc("go/platform/target/goarm64:" + cfg.GOARM64) counter.Inc("go/platform/target/goarm64:" + cfg.GOARM64)
case "mips": case "mips":
telemetry.Inc("go/platform/target/gomips:" + cfg.GOMIPS) counter.Inc("go/platform/target/gomips:" + cfg.GOMIPS)
case "ppc64": case "ppc64":
telemetry.Inc("go/platform/target/goppc64:" + cfg.GOPPC64) counter.Inc("go/platform/target/goppc64:" + cfg.GOPPC64)
case "riscv64": case "riscv64":
telemetry.Inc("go/platform/target/goriscv64:" + cfg.GORISCV64) counter.Inc("go/platform/target/goriscv64:" + cfg.GORISCV64)
case "wasm": case "wasm":
telemetry.Inc("go/platform/target/gowasm:" + cfg.GOWASM) counter.Inc("go/platform/target/gowasm:" + cfg.GOWASM)
} }
} }

View file

@ -6,8 +6,8 @@
package telemetrystats package telemetrystats
import "cmd/internal/telemetry" import "cmd/internal/telemetry/counter"
func incrementVersionCounters() { func incrementVersionCounters() {
telemetry.Inc("go/platform:version-not-supported") counter.Inc("go/platform:version-not-supported")
} }

View file

@ -12,7 +12,7 @@ import (
"runtime" "runtime"
"strings" "strings"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -29,7 +29,7 @@ func incrementVersionCounters() {
var v unix.Utsname var v unix.Utsname
err := unix.Uname(&v) err := unix.Uname(&v)
if err != nil { 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 return
} }
major, minor, ok := majorMinor(convert(v.Release[:])) major, minor, ok := majorMinor(convert(v.Release[:]))
@ -37,11 +37,11 @@ func incrementVersionCounters() {
major, minor, ok = convert(v.Version[:]), convert(v.Release[:]), true major, minor, ok = convert(v.Version[:]), convert(v.Release[:]), true
} }
if !ok { 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 return
} }
telemetry.Inc(fmt.Sprintf("go/platform/host/%s/major-version:%s", runtime.GOOS, major)) counter.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/version:%s-%s", runtime.GOOS, major, minor))
} }
func majorMinor(v string) (string, string, bool) { func majorMinor(v string) (string, string, bool) {

View file

@ -9,14 +9,14 @@ package telemetrystats
import ( import (
"fmt" "fmt"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
func incrementVersionCounters() { func incrementVersionCounters() {
v := windows.RtlGetVersion() v := windows.RtlGetVersion()
telemetry.Inc(fmt.Sprintf("go/platform/host/windows/major-version:%d", v.MajorVersion)) counter.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)) counter.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/build:%d", v.BuildNumber))
} }

View file

@ -6,7 +6,7 @@
package tool package tool
import ( import (
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"context" "context"
"encoding/json" "encoding/json"
"flag" "flag"
@ -58,7 +58,7 @@ func init() {
func runTool(ctx context.Context, cmd *base.Command, args []string) { func runTool(ctx context.Context, cmd *base.Command, args []string) {
if len(args) == 0 { if len(args) == 0 {
telemetry.Inc("go/subcommand:tool") counter.Inc("go/subcommand:tool")
listTools() listTools()
return return
} }
@ -86,17 +86,17 @@ func runTool(ctx context.Context, cmd *base.Command, args []string) {
if impersonateDistList(args[2:]) { if impersonateDistList(args[2:]) {
// If it becomes necessary, we could increment an additional counter to indicate // If it becomes necessary, we could increment an additional counter to indicate
// that we're impersonating dist list if knowing that becomes important? // that we're impersonating dist list if knowing that becomes important?
telemetry.Inc("go/subcommand:tool-dist") counter.Inc("go/subcommand:tool-dist")
return return
} }
} }
telemetry.Inc("go/subcommand:tool-unknown") counter.Inc("go/subcommand:tool-unknown")
// Emit the usual error for the missing tool. // Emit the usual error for the missing tool.
_ = base.Tool(toolName) _ = base.Tool(toolName)
} else { } else {
// Increment a counter for the tool subcommand with the tool name. // 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 { if toolN {

View file

@ -26,7 +26,7 @@ import (
"cmd/go/internal/modload" "cmd/go/internal/modload"
"cmd/go/internal/run" "cmd/go/internal/run"
"cmd/go/internal/work" "cmd/go/internal/work"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"golang.org/x/mod/module" "golang.org/x/mod/module"
) )
@ -82,7 +82,7 @@ func FilterEnv(env []string) []string {
return out 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 // Select invokes a different Go toolchain if directed by
// the GOTOOLCHAIN environment variable or the user's configuration // the GOTOOLCHAIN environment variable or the user's configuration
@ -253,7 +253,7 @@ func Select() {
Exec(gotoolchain) 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. // TestVersionSwitch is set in the test go binary to the value in $TESTGO_VERSION_SWITCH.
// Valid settings are: // Valid settings are:

View file

@ -16,7 +16,7 @@ import (
"cmd/go/internal/cfg" "cmd/go/internal/cfg"
"cmd/go/internal/gover" "cmd/go/internal/gover"
"cmd/go/internal/modfetch" "cmd/go/internal/modfetch"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
// A Switcher collects errors to be reported and then decides // A Switcher collects errors to be reported and then decides
@ -104,7 +104,7 @@ func (s *Switcher) Switch(ctx context.Context) {
panic("unreachable") 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 // SwitchOrFatal attempts a toolchain switch based on the information in err
// and otherwise falls back to base.Fatal(err). // and otherwise falls back to base.Fatal(err).

View file

@ -19,7 +19,7 @@ import (
"cmd/go/internal/str" "cmd/go/internal/str"
"cmd/internal/buildid" "cmd/internal/buildid"
"cmd/internal/quoted" "cmd/internal/quoted"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
// Build IDs // Build IDs
@ -406,11 +406,11 @@ func (b *Builder) fileHash(file string) string {
} }
var ( var (
counterCacheHit = telemetry.NewCounter("go/buildcache/hit") counterCacheHit = counter.New("go/buildcache/hit")
counterCacheMiss = telemetry.NewCounter("go/buildcache/miss") counterCacheMiss = counter.New("go/buildcache/miss")
onceIncStdlibRecompiled sync.Once 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, // useCache tries to satisfy the action a, which has action ID actionHash,

View file

@ -45,6 +45,7 @@ import (
"cmd/go/internal/work" "cmd/go/internal/work"
"cmd/go/internal/workcmd" "cmd/go/internal/workcmd"
"cmd/internal/telemetry" "cmd/internal/telemetry"
"cmd/internal/telemetry/counter"
) )
func init() { func init() {
@ -91,20 +92,20 @@ func init() {
var _ = go11tag var _ = go11tag
var counterErrorsGOPATHEntryRelative = telemetry.NewCounter("go/errors:gopath-entry-relative") var counterErrorsGOPATHEntryRelative = counter.New("go/errors:gopath-entry-relative")
func main() { func main() {
log.SetFlags(0) log.SetFlags(0)
telemetry.MaybeChild() // Run in child mode if this is the telemetry sidecar child process. 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. counter.Open() // Open the telemetry counter file so counters can be written to it.
handleChdirFlag() handleChdirFlag()
toolchain.Select() toolchain.Select()
telemetry.MaybeParent() // Run the upload process. Opening the counter file is idempotent. telemetry.MaybeParent() // Run the upload process. Opening the counter file is idempotent.
flag.Usage = base.Usage flag.Usage = base.Usage
flag.Parse() flag.Parse()
telemetry.Inc("go/invocations") counter.Inc("go/invocations")
telemetry.CountFlags("go/flag:", *flag.CommandLine) counter.CountFlags("go/flag:", *flag.CommandLine)
args := flag.Args() args := flag.Args()
if len(args) < 1 { if len(args) < 1 {
@ -113,7 +114,7 @@ func main() {
cfg.CmdName = args[0] // for error messages cfg.CmdName = args[0] // for error messages
if args[0] == "help" { 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:]) help.Help(os.Stdout, args[1:])
return return
} }
@ -128,17 +129,17 @@ func main() {
} }
switch strings.ToLower(cfg.GOROOT) { switch strings.ToLower(cfg.GOROOT) {
case "/usr/local/go": // Location recommended for installation on Linux and Darwin and used by Mac installer. 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. 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. 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. 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. 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: default:
telemetry.Inc("go/goroot:other") counter.Inc("go/goroot:other")
} }
// Diagnose common mistake: GOPATH==GOROOT. // Diagnose common mistake: GOPATH==GOROOT.
@ -184,7 +185,7 @@ func main() {
} }
if args[used] == "help" { if args[used] == "help" {
// Accept 'go mod help' and 'go mod help foo' for 'go help mod' and 'go help mod foo'. // 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:]...)) help.Help(os.Stdout, append(slices.Clip(args[:used]), args[used+1:]...))
base.Exit() base.Exit()
} }
@ -196,7 +197,7 @@ func main() {
if cmdName == "" { if cmdName == "" {
cmdName = args[0] 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) fmt.Fprintf(os.Stderr, "go %s: unknown command\nRun 'go help%s' for usage.\n", cmdName, helpArg)
base.SetExitStatus(2) base.SetExitStatus(2)
base.Exit() base.Exit()
@ -206,7 +207,7 @@ func main() {
// increment in the tool subcommand's Run function because we need // increment in the tool subcommand's Run function because we need
// to do the flag processing in invoke first. // to do the flag processing in invoke first.
if cfg.CmdName != "tool" { if cfg.CmdName != "tool" {
telemetry.Inc("go/subcommand:" + strings.ReplaceAll(cfg.CmdName, " ", "-")) counter.Inc("go/subcommand:" + strings.ReplaceAll(cfg.CmdName, " ", "-"))
} }
telemetrystats.Increment() telemetrystats.Increment()
invoke(cmd, args[used-1:]) invoke(cmd, args[used-1:])
@ -274,8 +275,8 @@ func invoke(cmd *base.Command, args []string) {
base.SetFromGOFLAGS(&cmd.Flag) base.SetFromGOFLAGS(&cmd.Flag)
cmd.Flag.Parse(args[1:]) cmd.Flag.Parse(args[1:])
flagCounterPrefix := "go/" + strings.ReplaceAll(cfg.CmdName, " ", "-") + "/flag" flagCounterPrefix := "go/" + strings.ReplaceAll(cfg.CmdName, " ", "-") + "/flag"
telemetry.CountFlags(flagCounterPrefix+":", cmd.Flag) counter.CountFlags(flagCounterPrefix+":", cmd.Flag)
telemetry.CountFlagValue(flagCounterPrefix+"/", cmd.Flag, "buildmode") counter.CountFlagValue(flagCounterPrefix+"/", cmd.Flag, "buildmode")
args = cmd.Flag.Args() args = cmd.Flag.Args()
} }
@ -361,7 +362,7 @@ func handleChdirFlag() {
_, dir, _ = strings.Cut(a, "=") _, dir, _ = strings.Cut(a, "=")
os.Args = slices.Delete(os.Args, used, used+1) 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 { if err := os.Chdir(dir); err != nil {
base.Fatalf("go: %v", err) base.Fatalf("go: %v", err)

View file

@ -25,7 +25,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"golang.org/x/sync/semaphore" "golang.org/x/sync/semaphore"
) )
@ -374,11 +374,11 @@ func main() {
} }
func gofmtMain(s *sequencer) { func gofmtMain(s *sequencer) {
telemetry.OpenCounters() counter.Open()
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
telemetry.Inc("gofmt/invocations") counter.Inc("gofmt/invocations")
telemetry.CountFlags("gofmt/flag:", *flag.CommandLine) counter.CountFlags("gofmt/flag:", *flag.CommandLine)
if *cpuprofile != "" { if *cpuprofile != "" {
fdSem <- true fdSem <- true

View file

@ -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()
}
})
}

View file

@ -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) {}

View file

@ -12,30 +12,21 @@
package telemetry package telemetry
import ( import (
"flag"
"os" "os"
"cmd/internal/telemetry/counter"
"golang.org/x/telemetry" "golang.org/x/telemetry"
"golang.org/x/telemetry/counter"
) )
var openCountersCalled, maybeChildCalled bool 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 // 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 // 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 // do so. It should only be called by cmd/go, and only after OpenCounters and MaybeChild
// have already been called. // have already been called.
func MaybeParent() { func MaybeParent() {
if !openCountersCalled || !maybeChildCalled { if !counter.OpenCalled() || !maybeChildCalled {
panic("MaybeParent must be called after OpenCounters and MaybeChild") panic("MaybeParent must be called after OpenCounters and MaybeChild")
} }
telemetry.Start(telemetry.Config{ 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. // Mode returns the current telemetry mode.
// //
// The telemetry mode is a global value that controls both the local collection // The telemetry mode is a global value that controls both the local collection

View file

@ -6,20 +6,8 @@
package telemetry package telemetry
import "flag"
type dummyCounter struct{}
func (dc dummyCounter) Inc() {}
func OpenCounters() {}
func MaybeParent() {} func MaybeParent() {}
func MaybeChild() {} 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 Mode() string { return "" }
func SetMode(mode string) error { return nil } func SetMode(mode string) error { return nil }
func Dir() string { return "" } func Dir() string { return "" }

View file

@ -36,7 +36,7 @@ import (
"cmd/internal/objabi" "cmd/internal/objabi"
"cmd/internal/quoted" "cmd/internal/quoted"
"cmd/internal/sys" "cmd/internal/sys"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"cmd/link/internal/benchmark" "cmd/link/internal/benchmark"
"flag" "flag"
"internal/buildcfg" "internal/buildcfg"
@ -157,8 +157,8 @@ func (t *ternaryFlag) IsBoolFlag() bool { return true } // parse like a boolean
func Main(arch *sys.Arch, theArch Arch) { func Main(arch *sys.Arch, theArch Arch) {
log.SetPrefix("link: ") log.SetPrefix("link: ")
log.SetFlags(0) log.SetFlags(0)
telemetry.OpenCounters() counter.Open()
telemetry.Inc("link/invocations") counter.Inc("link/invocations")
thearch = theArch thearch = theArch
ctxt := linknew(arch) 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.Flagfn1("importcfg", "read import configuration from `file`", ctxt.readImportCfg)
objabi.Flagparse(usage) objabi.Flagparse(usage)
telemetry.CountFlags("link/flag:", *flag.CommandLine) counter.CountFlags("link/flag:", *flag.CommandLine)
if ctxt.Debugvlog > 0 { if ctxt.Debugvlog > 0 {
// dump symbol info on crash // dump symbol info on crash

View file

@ -13,7 +13,7 @@ import (
"sort" "sort"
"cmd/internal/objfile" "cmd/internal/objfile"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
const helpText = `usage: go tool nm [options] file... const helpText = `usage: go tool nm [options] file...
@ -68,11 +68,11 @@ func (nflag) String() string {
func main() { func main() {
log.SetFlags(0) log.SetFlags(0)
telemetry.OpenCounters() counter.Open()
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
telemetry.Inc("nm/invocations") counter.Inc("nm/invocations")
telemetry.CountFlags("nm/flag:", *flag.CommandLine) counter.CountFlags("nm/flag:", *flag.CommandLine)
switch *sortOrder { switch *sortOrder {
case "address", "name", "none", "size": case "address", "name", "none", "size":

View file

@ -41,7 +41,7 @@ import (
"strings" "strings"
"cmd/internal/objfile" "cmd/internal/objfile"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
) )
var printCode = flag.Bool("S", false, "print Go code alongside assembly") var printCode = flag.Bool("S", false, "print Go code alongside assembly")
@ -58,12 +58,12 @@ func usage() {
func main() { func main() {
log.SetFlags(0) log.SetFlags(0)
log.SetPrefix("objdump: ") log.SetPrefix("objdump: ")
telemetry.OpenCounters() counter.Open()
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
telemetry.Inc("objdump/invocations") counter.Inc("objdump/invocations")
telemetry.CountFlags("objdump/flag:", *flag.CommandLine) counter.CountFlags("objdump/flag:", *flag.CommandLine)
if flag.NArg() != 1 && flag.NArg() != 3 { if flag.NArg() != 1 && flag.NArg() != 3 {
usage() usage()
} }

View file

@ -6,7 +6,7 @@ package main
import ( import (
"cmd/internal/archive" "cmd/internal/archive"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
@ -31,7 +31,7 @@ func usage() {
func main() { func main() {
log.SetFlags(0) log.SetFlags(0)
log.SetPrefix("pack: ") log.SetPrefix("pack: ")
telemetry.OpenCounters() counter.Open()
// need "pack op archive" at least. // need "pack op archive" at least.
if len(os.Args) < 3 { if len(os.Args) < 3 {
log.Print("not enough arguments") log.Print("not enough arguments")
@ -39,8 +39,8 @@ func main() {
usage() usage()
} }
setOp(os.Args[1]) setOp(os.Args[1])
telemetry.Inc("pack/invocations") counter.Inc("pack/invocations")
telemetry.Inc("pack/op:" + string(op)) counter.Inc("pack/op:" + string(op))
var ar *Archive var ar *Archive
switch op { switch op {
case 'p': case 'p':

View file

@ -25,22 +25,22 @@ import (
"time" "time"
"cmd/internal/objfile" "cmd/internal/objfile"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"github.com/google/pprof/driver" "github.com/google/pprof/driver"
"github.com/google/pprof/profile" "github.com/google/pprof/profile"
) )
func main() { func main() {
telemetry.OpenCounters() counter.Open()
telemetry.Inc("pprof/invocations") counter.Inc("pprof/invocations")
options := &driver.Options{ options := &driver.Options{
Fetch: new(fetcher), Fetch: new(fetcher),
Obj: new(objTool), Obj: new(objTool),
UI: newUI(), UI: newUI(),
} }
err := driver.PProf(options) 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 { if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err) fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(2) os.Exit(2)

View file

@ -18,7 +18,7 @@ import (
"bufio" "bufio"
"cmd/internal/objabi" "cmd/internal/objabi"
"cmd/internal/pgo" "cmd/internal/pgo"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"flag" "flag"
"fmt" "fmt"
"log" "log"
@ -73,12 +73,12 @@ func main() {
log.SetFlags(0) log.SetFlags(0)
log.SetPrefix("preprofile: ") log.SetPrefix("preprofile: ")
telemetry.OpenCounters() counter.Open()
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
telemetry.Inc("preprofile/invocations") counter.Inc("preprofile/invocations")
telemetry.CountFlags("preprofile/flag:", *flag.CommandLine) counter.CountFlags("preprofile/flag:", *flag.CommandLine)
if *input == "" { if *input == "" {
log.Print("Input pprof path required (-i)") log.Print("Input pprof path required (-i)")
usage() usage()

View file

@ -96,7 +96,7 @@ import (
"os/exec" "os/exec"
"os/signal" "os/signal"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"cmd/internal/test2json" "cmd/internal/test2json"
) )
@ -116,12 +116,12 @@ func ignoreSignals() {
} }
func main() { func main() {
telemetry.OpenCounters() counter.Open()
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
telemetry.Inc("test2json/invocations") counter.Inc("test2json/invocations")
telemetry.CountFlags("test2json/flag:", *flag.CommandLine) counter.CountFlags("test2json/flag:", *flag.CommandLine)
var mode test2json.Mode var mode test2json.Mode
if *flagT { if *flagT {

View file

@ -6,7 +6,7 @@ package main
import ( import (
"cmd/internal/browser" "cmd/internal/browser"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"flag" "flag"
"fmt" "fmt"
"internal/trace" "internal/trace"
@ -64,14 +64,14 @@ var (
) )
func main() { func main() {
telemetry.OpenCounters() counter.Open()
flag.Usage = func() { flag.Usage = func() {
fmt.Fprint(os.Stderr, usageMessage) fmt.Fprint(os.Stderr, usageMessage)
os.Exit(2) os.Exit(2)
} }
flag.Parse() flag.Parse()
telemetry.Inc("trace/invocations") counter.Inc("trace/invocations")
telemetry.CountFlags("trace/flag:", *flag.CommandLine) counter.CountFlags("trace/flag:", *flag.CommandLine)
// Go 1.7 traces embed symbol info and does not require the binary. // 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. // But we optionally accept binary as first arg for Go 1.5 traces.

View file

@ -6,7 +6,7 @@ package main
import ( import (
"cmd/internal/objabi" "cmd/internal/objabi"
"cmd/internal/telemetry" "cmd/internal/telemetry/counter"
"flag" "flag"
"golang.org/x/tools/go/analysis/unitchecker" "golang.org/x/tools/go/analysis/unitchecker"
@ -47,10 +47,10 @@ import (
) )
func main() { func main() {
telemetry.OpenCounters() counter.Open()
objabi.AddVersionFlag() objabi.AddVersionFlag()
telemetry.Inc("vet/invocations") counter.Inc("vet/invocations")
unitchecker.Main( unitchecker.Main(
appends.Analyzer, appends.Analyzer,
asmdecl.Analyzer, asmdecl.Analyzer,
@ -89,5 +89,5 @@ func main() {
// It's possible that unitchecker will exit early. In // It's possible that unitchecker will exit early. In
// those cases the flags won't be counted. // those cases the flags won't be counted.
telemetry.CountFlags("vet/flag:", *flag.CommandLine) counter.CountFlags("vet/flag:", *flag.CommandLine)
} }