cmd/vendor: pull in golang.org/x/telemetry@bf80d56

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

Pulls in CL 586195 and CL 586098

Change-Id: I21ba2ddce0e9c355e9f1c06961ba6cba5475375c
Reviewed-on: https://go-review.googlesource.com/c/go/+/586877
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
This commit is contained in:
Michael Matloob 2024-05-20 16:54:23 -04:00 committed by Gopher Robot
parent 8b990f2592
commit ecad164da7
4 changed files with 21 additions and 18 deletions

View File

@ -9,7 +9,7 @@ require (
golang.org/x/mod v0.17.1-0.20240514174713-c0bdc7bd01c9
golang.org/x/sync v0.7.0
golang.org/x/sys v0.20.0
golang.org/x/telemetry v0.0.0-20240515213752-9ff3ad9b3e68
golang.org/x/telemetry v0.0.0-20240520205152-bf80d5667fb9
golang.org/x/term v0.18.0
golang.org/x/tools v0.20.1-0.20240429173604-74c9cfe4d22f
)

View File

@ -32,8 +32,8 @@ golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/telemetry v0.0.0-20240515213752-9ff3ad9b3e68 h1:UpbHwFpoVYf6i5cMzwsNuPGNsZzfJXFr8R4uUv2HVgk=
golang.org/x/telemetry v0.0.0-20240515213752-9ff3ad9b3e68/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
golang.org/x/telemetry v0.0.0-20240520205152-bf80d5667fb9 h1:YjhQ60ZAs9YrTY7Fz05TnZ8jS7kN+w50q4dihOdsqGM=
golang.org/x/telemetry v0.0.0-20240520205152-bf80d5667fb9/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
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=

View File

@ -110,11 +110,15 @@ func Start(config Config) *StartResult {
}
// Crash monitoring and uploading both require a sidecar process.
if (config.ReportCrashes && crashmonitor.Supported()) || (config.Upload && mode != "off") {
var (
reportCrashes = config.ReportCrashes && crashmonitor.Supported()
upload = config.Upload && mode != "off"
)
if reportCrashes || upload {
switch v := os.Getenv(telemetryChildVar); v {
case "":
// The subprocess started by parent has X_TELEMETRY_CHILD=1.
parent(config, result)
parent(reportCrashes, result)
case "1":
// golang/go#67211: be sure to set telemetryChildVar before running the
// child, because the child itself invokes the go command to download the
@ -126,7 +130,7 @@ func Start(config Config) *StartResult {
// delegated go commands would fork themselves recursively. Short-circuit
// this recursion.
os.Setenv(telemetryChildVar, "2")
child(config)
child(reportCrashes, upload, config.UploadStartTime, config.UploadURL)
os.Exit(0)
case "2":
// Do nothing: see note above.
@ -161,7 +165,7 @@ var daemonize = func(cmd *exec.Cmd) {}
// further forking should occur.
const telemetryChildVar = "X_TELEMETRY_CHILD"
func parent(config Config, result *StartResult) {
func parent(reportCrashes bool, result *StartResult) {
// This process is the application (parent).
// Fork+exec the telemetry child.
exe, err := os.Executable()
@ -184,10 +188,9 @@ func parent(config Config, result *StartResult) {
// to gather the output of the parent.
//
// By default, we discard the child process's stderr,
// but in line with the uploader, log to a file in local/debug
// but in line with the uploader, log to a file in debug
// only if that directory was created by the user.
localDebug := filepath.Join(telemetry.Default.LocalDir(), "debug")
fd, err := os.Stat(localDebug)
fd, err := os.Stat(telemetry.Default.DebugDir())
if err != nil {
if !os.IsNotExist(err) {
log.Fatalf("failed to stat debug directory: %v", err)
@ -195,7 +198,7 @@ func parent(config Config, result *StartResult) {
} else if fd.IsDir() {
// local/debug exists and is a directory. Set stderr to a log file path
// in local/debug.
childLogPath := filepath.Join(localDebug, "sidecar.log")
childLogPath := filepath.Join(telemetry.Default.DebugDir(), "sidecar.log")
childLog, err := os.OpenFile(childLogPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0600)
if err != nil {
log.Fatalf("opening sidecar log file for child: %v", err)
@ -204,7 +207,7 @@ func parent(config Config, result *StartResult) {
cmd.Stderr = childLog
}
if config.ReportCrashes {
if reportCrashes {
pipe, err := cmd.StdinPipe()
if err != nil {
log.Fatalf("StdinPipe: %v", err)
@ -223,7 +226,7 @@ func parent(config Config, result *StartResult) {
}()
}
func child(config Config) {
func child(reportCrashes, upload bool, uploadStartTime time.Time, uploadURL string) {
log.SetPrefix(fmt.Sprintf("telemetry-sidecar (pid %v): ", os.Getpid()))
// Start crashmonitoring and uploading depending on what's requested
@ -232,15 +235,15 @@ func child(config Config) {
// upload to finish before exiting
var g errgroup.Group
if config.Upload {
if reportCrashes {
g.Go(func() error {
uploaderChild(config.UploadStartTime, config.UploadURL)
crashmonitor.Child()
return nil
})
}
if config.ReportCrashes {
if upload {
g.Go(func() error {
crashmonitor.Child()
uploaderChild(uploadStartTime, uploadURL)
return nil
})
}

View 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-20240515213752-9ff3ad9b3e68
# golang.org/x/telemetry v0.0.0-20240520205152-bf80d5667fb9
## explicit; go 1.20
golang.org/x/telemetry
golang.org/x/telemetry/counter