github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5
golang.org/x/arch v0.7.0
golang.org/x/build v0.0.0-20240222153247-cf4ed81bb19f
- golang.org/x/mod v0.15.1-0.20240207185259-766dc5df63e3
+ 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-20240229223025-3d5706d2d0fb
+ golang.org/x/telemetry v0.0.0-20240306210657-d5a85b27db3e
golang.org/x/term v0.17.0
golang.org/x/tools v0.18.0
)
golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/build v0.0.0-20240222153247-cf4ed81bb19f h1:XQ2eu0I26WsNCKQkRehp+5mwjjChw94trD9LT8LLSq0=
golang.org/x/build v0.0.0-20240222153247-cf4ed81bb19f/go.mod h1:HTqTCkubWT8epEK9hDWWGkoOOB7LGSrU1qvWZCSwO50=
-golang.org/x/mod v0.15.1-0.20240207185259-766dc5df63e3 h1:/p/VemLWiTsjHqHwME1Iu+xIu8s9fBtwBk8bU/ejA1A=
-golang.org/x/mod v0.15.1-0.20240207185259-766dc5df63e3/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
+golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
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-20240229223025-3d5706d2d0fb h1:LxVQXEmTbdDLG1nTKZrjqjn72V7ry1X1HLQFVioaRmE=
-golang.org/x/telemetry v0.0.0-20240229223025-3d5706d2d0fb/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
+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/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
logger.Printf("error on Post: %v %q for %q", err, server, fname)
return false
}
+ // hope for a 200, remove file on a 4xx, otherwise it will be retried by another process
if resp.StatusCode != 200 {
logger.Printf("resp error on upload %q: %v for %q %q [%+v]", server, resp.Status, fname, fdate, resp)
+ if resp.StatusCode >= 400 && resp.StatusCode < 500 {
+ err := os.Remove(fname)
+ if err == nil {
+ logger.Printf("removed")
+ } else {
+ logger.Printf("error removing: %v", err)
+ }
+ }
return false
}
// put a copy in the uploaded directory
// Longer term, the go command may become the sole program
// responsible for uploading.)
Upload bool
+
+ // TelemetryDir, if set, will specify an alternate telemetry
+ // directory to write data to. If not set, it uses the default
+ // directory.
+ // This field is intended to be used for isolating testing environments.
+ TelemetryDir string
}
// Start initializes telemetry using the specified configuration.
// steps or external side effects in init functions, as they will
// be executed twice (parent and child).
func Start(config Config) {
+ if config.TelemetryDir != "" {
+ telemetry.ModeFile = telemetry.ModeFilePath(filepath.Join(config.TelemetryDir, "mode"))
+ telemetry.LocalDir = filepath.Join(config.TelemetryDir, "local")
+ telemetry.UploadDir = filepath.Join(config.TelemetryDir, "upload")
+ }
+ mode, _ := telemetry.Mode()
+ if mode == "off" {
+ // Telemetry is turned off. Crash reporting doesn't work without telemetry
+ // at least set to "local", and the uploader isn't started in uploaderChild if
+ // mode is "off"
+ return
+ }
+
counter.Open()
+ if _, err := os.Stat(telemetry.LocalDir); err != nil {
+ // There was a problem statting LocalDir, which is needed for both
+ // crash monitoring and counter uploading. Most likely, there was an
+ // error creating telemetry.LocalDir in the counter.Open call above.
+ // Don't start the child.
+ return
+ }
+
// Crash monitoring and uploading both require a sidecar process.
- if (config.ReportCrashes && crashmonitor.Supported()) || config.Upload {
+ if (config.ReportCrashes && crashmonitor.Supported()) || (config.Upload && mode != "off") {
if os.Getenv(telemetryChildVar) != "" {
child(config)
os.Exit(0)
cmd := exec.Command(exe, "** telemetry **") // this unused arg is just for ps(1)
daemonize(cmd)
cmd.Env = append(os.Environ(), telemetryChildVar+"=1")
+ cmd.Dir = telemetry.LocalDir
// The child process must write to a log file, not
// the stderr file it inherited from the parent, as
}
func uploaderChild() {
+ if mode, _ := telemetry.Mode(); mode == "off" {
+ // There's no work to be done if telemetry is turned off.
+ return
+ }
+ if telemetry.LocalDir == "" {
+ // The telemetry dir wasn't initialized properly, probably because
+ // os.UserConfigDir did not complete successfully. In that case
+ // there are no counters to upload, so we should just do nothing.
+ return
+ }
tokenfilepath := filepath.Join(telemetry.LocalDir, "upload.token")
ok, err := acquireUploadToken(tokenfilepath)
if err != nil {
# golang.org/x/build v0.0.0-20240222153247-cf4ed81bb19f
## explicit; go 1.21
golang.org/x/build/relnote
-# golang.org/x/mod v0.15.1-0.20240207185259-766dc5df63e3
+# golang.org/x/mod v0.16.0
## explicit; go 1.18
golang.org/x/mod/internal/lazyregexp
golang.org/x/mod/modfile
golang.org/x/sys/plan9
golang.org/x/sys/unix
golang.org/x/sys/windows
-# golang.org/x/telemetry v0.0.0-20240229223025-3d5706d2d0fb
+# golang.org/x/telemetry v0.0.0-20240306210657-d5a85b27db3e
## explicit; go 1.20
golang.org/x/telemetry
golang.org/x/telemetry/counter