diff --git a/cmd/skaffold/skaffold.go b/cmd/skaffold/skaffold.go index db8c3425e3d..e55ada47072 100644 --- a/cmd/skaffold/skaffold.go +++ b/cmd/skaffold/skaffold.go @@ -33,6 +33,7 @@ type ExitCoder interface { } func main() { + instrumentation.SetOnlineStatus() var code int if err := app.Run(os.Stdout, os.Stderr); err != nil { if errors.Is(err, context.Canceled) { diff --git a/pkg/skaffold/instrumentation/meter.go b/pkg/skaffold/instrumentation/meter.go index 72df0aba926..1f216853ea4 100644 --- a/pkg/skaffold/instrumentation/meter.go +++ b/pkg/skaffold/instrumentation/meter.go @@ -97,6 +97,12 @@ func init() { meteredCommands.Insert("build", "delete", "deploy", "dev", "debug", "filter", "generate_pipeline", "render", "run", "test") doesBuild.Insert("build", "render", "dev", "debug", "run") doesDeploy.Insert("deploy", "dev", "debug", "run") +} + +// SetOnlineStatus issues a GET request to see if the user is online. +// http://clients3.google.com/generate_204 is a well-known URL that returns an empty page and HTTP status 204 +// More info can be found here: https://www.chromium.org/chromium-os/chromiumos-design-docs/network-portal-detection +func SetOnlineStatus() { go func() { if shouldExportMetrics { r, err := http.Get("http://clients3.google.com/generate_204")