mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
71029cea2d
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
41 lines
942 B
Go
41 lines
942 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package controlclient
|
|
|
|
import (
|
|
"bytes"
|
|
"compress/gzip"
|
|
"context"
|
|
"log"
|
|
"net/http"
|
|
"time"
|
|
|
|
"tailscale.com/util/goroutines"
|
|
)
|
|
|
|
func dumpGoroutinesToURL(c *http.Client, targetURL string) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
|
defer cancel()
|
|
|
|
zbuf := new(bytes.Buffer)
|
|
zw := gzip.NewWriter(zbuf)
|
|
zw.Write(goroutines.ScrubbedGoroutineDump())
|
|
zw.Close()
|
|
|
|
req, err := http.NewRequestWithContext(ctx, "PUT", targetURL, zbuf)
|
|
if err != nil {
|
|
log.Printf("dumpGoroutinesToURL: %v", err)
|
|
return
|
|
}
|
|
req.Header.Set("Content-Encoding", "gzip")
|
|
t0 := time.Now()
|
|
_, err = c.Do(req)
|
|
d := time.Since(t0).Round(time.Millisecond)
|
|
if err != nil {
|
|
log.Printf("dumpGoroutinesToURL error: %v to %v (after %v)", err, targetURL, d)
|
|
} else {
|
|
log.Printf("dumpGoroutinesToURL complete to %v (after %v)", targetURL, d)
|
|
}
|
|
}
|