]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: vendor in golang.org/x/telemetry@abedc37
authorMichael Matloob <matloob@golang.org>
Thu, 14 Mar 2024 21:14:31 +0000 (17:14 -0400)
committerMichael Matloob <matloob@golang.org>
Fri, 15 Mar 2024 18:02:34 +0000 (18:02 +0000)
This pulls in the changes to remove 1.18 support in counter and
countertest, to add counter.CountCommandLineFlags, and to add
countertest.SupportedPlatform

Commands run:
go get golang.org/x/telemetry@abedc37
go mod tidy
go mod vendor

Change-Id: I5c17c5b3ca38df14883ba43316d59437a737b28b
Reviewed-on: https://go-review.googlesource.com/c/go/+/571801
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
src/cmd/go.mod
src/cmd/go.sum
src/cmd/vendor/golang.org/x/telemetry/counter/counter.go
src/cmd/vendor/golang.org/x/telemetry/counter/counter_118.go [deleted file]
src/cmd/vendor/golang.org/x/telemetry/counter/countertest/countertest.go
src/cmd/vendor/golang.org/x/telemetry/counter/countertest/countertest_go118.go [deleted file]
src/cmd/vendor/modules.txt

index 2ab365a9daf9b069ec9f53569b53fc8da01f69f1..00ad03ccb19cca0b53f1d154782c301a58fbedc6 100644 (file)
@@ -9,7 +9,7 @@ require (
        golang.org/x/mod v0.16.0
        golang.org/x/sync v0.6.0
        golang.org/x/sys v0.18.0
-       golang.org/x/telemetry v0.0.0-20240306210657-d5a85b27db3e
+       golang.org/x/telemetry v0.0.0-20240314204428-abedc375dc97
        golang.org/x/term v0.18.0
        golang.org/x/tools v0.18.0
 )
index 4917878db2e1298e109c2511725220aad687a058..3b5545f7de53c5fe794e7c1c3cca997127641b00 100644 (file)
@@ -32,8 +32,8 @@ golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
 golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
 golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/telemetry v0.0.0-20240306210657-d5a85b27db3e h1:PLWTnhLSeWLoHHuUDdzlJeYqRntM+xTyojGjTrFg01c=
-golang.org/x/telemetry v0.0.0-20240306210657-d5a85b27db3e/go.mod h1:wQS78u8AjB4H3mN7DPniFYwsXnV9lPziq+He/eA7JIw=
+golang.org/x/telemetry v0.0.0-20240314204428-abedc375dc97 h1:8xsFCUjK82nH2OGdUR3elXWEngFLc2SM/IplvhGHFjk=
+golang.org/x/telemetry v0.0.0-20240314204428-abedc375dc97/go.mod h1:wQS78u8AjB4H3mN7DPniFYwsXnV9lPziq+He/eA7JIw=
 golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
 golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
 golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
index e6af9ea6cfb46290b10ef5f73322acb1a86e8813..ba1c68889e1ec0ea35e05f37f4235fb10aa863cf 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build go1.19
-
 package counter
 
 // The implementation of this package and tests are located in
@@ -13,6 +11,8 @@ package counter
 // type aliasing or restructuring the internal/counter package.
 import (
        "flag"
+       "path"
+       "runtime/debug"
 
        "golang.org/x/telemetry/internal/counter"
 )
@@ -92,9 +92,30 @@ func Open() {
 // and increments the counter. The name of the counter is
 // the concatenation of prefix and the flag name.
 //
-//     For instance, CountFlags("gopls:flag-", flag.CommandLine)
+//     For instance, CountFlags("gopls/flag:", *flag.CommandLine)
 func CountFlags(prefix string, fs flag.FlagSet) {
        fs.Visit(func(f *flag.Flag) {
                New(prefix + f.Name).Inc()
        })
 }
+
+// CountCommandLineFlags creates a counter for every flag
+// that is set in the default flag.CommandLine FlagSet using
+// the counter name binaryName+"/flag:"+flagName where
+// binaryName is the base name of the Path embedded in the
+// binary's build info. If the binary does not have embedded build
+// info, the "flag:"+flagName counter will be incremented.
+//
+// CountCommandLineFlags must be called after flags are parsed
+// with flag.Parse.
+//
+// For instance, if the -S flag is passed to cmd/compile and
+// CountCommandLineFlags is called after flags are parsed,
+// the "compile/flag:S" counter will be incremented.
+func CountCommandLineFlags() {
+       prefix := "flag:"
+       if buildInfo, ok := debug.ReadBuildInfo(); ok && buildInfo.Path != "" {
+               prefix = path.Base(buildInfo.Path) + "/" + prefix
+       }
+       CountFlags(prefix, *flag.CommandLine)
+}
diff --git a/src/cmd/vendor/golang.org/x/telemetry/counter/counter_118.go b/src/cmd/vendor/golang.org/x/telemetry/counter/counter_118.go
deleted file mode 100644 (file)
index 432e0d7..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2023 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 !go1.19
-
-package counter
-
-import (
-       "flag"
-)
-
-func Add(string, int64)                         {}
-func Inc(string)                                {}
-func Open()                                     {}
-func CountFlags(prefix string, fs flag.FlagSet) {}
-
-type Counter struct{ name string }
-
-func New(name string) *Counter  { return &Counter{name} }
-func (c *Counter) Add(n int64)  {}
-func (c *Counter) Inc()         {}
-func (c *Counter) Name() string { return c.name }
-
-type StackCounter struct{ name string }
-
-func NewStack(name string, _ int) *StackCounter { return &StackCounter{name} }
-func (c *StackCounter) Counters() []*Counter    { return nil }
-func (c *StackCounter) Inc()                    {}
-func (c *StackCounter) Names() []string         { return nil }
index b9bec1f82586f5cf7a442eb8dcff0d9f525d2bae..c2f41f6d77a296553bd3c50be5f7b841c97c8320 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build go1.19
-
 // countertest provides testing utilities for counters.
 // This package cannot be used except for testing.
 package countertest
@@ -22,6 +20,9 @@ var (
        opened   bool
 )
 
+// SupportedPlatform reports if this platform supports Open()
+const SupportedPlatform = !telemetry.DisabledOnPlatform
+
 func isOpen() bool {
        openedMu.Lock()
        defer openedMu.Unlock()
diff --git a/src/cmd/vendor/golang.org/x/telemetry/counter/countertest/countertest_go118.go b/src/cmd/vendor/golang.org/x/telemetry/counter/countertest/countertest_go118.go
deleted file mode 100644 (file)
index d9eaecc..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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 !go1.19
-
-package countertest
-
-import "golang.org/x/telemetry/counter"
-
-func Open(telemetryDir string) {}
-
-func ReadCounter(c *counter.Counter) (count uint64, _ error) {
-       return 0, nil
-}
-
-func ReadStackCounter(c *counter.StackCounter) (stackCounts map[string]uint64, _ error) {
-       return nil, nil
-}
-
-func ReadFile(name string) (map[string]uint64, map[string]uint64, error) { return nil, nil, nil }
index a62ce7a360bebac9185e7d81022e8fc2d73c7a31..549a3fdc7f4c3b768574f056af69ba4bfd3c41b0 100644 (file)
@@ -45,7 +45,7 @@ golang.org/x/sync/semaphore
 golang.org/x/sys/plan9
 golang.org/x/sys/unix
 golang.org/x/sys/windows
-# golang.org/x/telemetry v0.0.0-20240306210657-d5a85b27db3e
+# golang.org/x/telemetry v0.0.0-20240314204428-abedc375dc97
 ## explicit; go 1.20
 golang.org/x/telemetry
 golang.org/x/telemetry/counter