mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-19 22:02:45 +08:00
telemetry: Add variance to retry interval, and disable keepalive
This commit is contained in:
parent
ef48e17e79
commit
b05006663f
|
@ -388,6 +388,6 @@ var (
|
|||
gitCommit string // git rev-parse HEAD
|
||||
gitShortStat string // git diff-index --shortstat
|
||||
gitFilesModified string // git diff-index --name-only HEAD
|
||||
|
||||
enableTelemetry = true
|
||||
)
|
||||
|
||||
const enableTelemetry = true
|
||||
|
|
|
@ -44,7 +44,7 @@ func Init(instanceID uuid.UUID, disabledMetricsKeys []string) {
|
|||
instanceUUID = instanceID
|
||||
disabledMetricsMu.Lock()
|
||||
for _, key := range disabledMetricsKeys {
|
||||
disabledMetrics[key] = false
|
||||
disabledMetrics[strings.TrimSpace(key)] = false
|
||||
}
|
||||
disabledMetricsMu.Unlock()
|
||||
enabled = true
|
||||
|
|
|
@ -38,6 +38,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -202,9 +203,9 @@ func emit(final bool) error {
|
|||
// schedule the next update using our default update
|
||||
// interval because the server might be healthy later
|
||||
|
||||
// ensure we won't slam the telemetry server
|
||||
// ensure we won't slam the telemetry server; add a little variance
|
||||
if reply.NextUpdate < 1*time.Second {
|
||||
reply.NextUpdate = defaultUpdateInterval
|
||||
reply.NextUpdate = defaultUpdateInterval + time.Duration(rand.Intn(int(1*time.Minute)))
|
||||
}
|
||||
|
||||
// schedule the next update (if this wasn't the last one and
|
||||
|
@ -345,7 +346,13 @@ func (s countingSet) MarshalJSON() ([]byte, error) {
|
|||
var (
|
||||
// httpClient should be used for HTTP requests. It
|
||||
// is configured with a timeout for reliability.
|
||||
httpClient = http.Client{Timeout: 1 * time.Minute}
|
||||
httpClient = http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSHandshakeTimeout: 30 * time.Second,
|
||||
DisableKeepAlives: true,
|
||||
},
|
||||
Timeout: 1 * time.Minute,
|
||||
}
|
||||
|
||||
// buffer holds the data that we are building up to send.
|
||||
buffer = make(map[string]interface{})
|
||||
|
|
Loading…
Reference in New Issue
Block a user