aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2018-05-08 22:54:12 -0600
committerMatthew Holt <[email protected]>2018-05-08 22:54:12 -0600
commitb05006663f92fd481062c3ba6aba0afa1de5188e (patch)
tree92f393dc5bb61181ce95774d531a17d1e435fad4
parentef48e17e79ad866dd31777ef5961fd98f841bae0 (diff)
downloadcaddy-b05006663f92fd481062c3ba6aba0afa1de5188e.tar.gz
caddy-b05006663f92fd481062c3ba6aba0afa1de5188e.zip
telemetry: Add variance to retry interval, and disable keepalive
-rw-r--r--caddy/caddymain/run.go4
-rw-r--r--telemetry/collection.go2
-rw-r--r--telemetry/telemetry.go13
3 files changed, 13 insertions, 6 deletions
diff --git a/caddy/caddymain/run.go b/caddy/caddymain/run.go
index 9884b0111..96eb1a1e9 100644
--- a/caddy/caddymain/run.go
+++ b/caddy/caddymain/run.go
@@ -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
diff --git a/telemetry/collection.go b/telemetry/collection.go
index 38c2f89ae..a46e2caf1 100644
--- a/telemetry/collection.go
+++ b/telemetry/collection.go
@@ -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
diff --git a/telemetry/telemetry.go b/telemetry/telemetry.go
index 6a83b2fa2..183ee6ea7 100644
--- a/telemetry/telemetry.go
+++ b/telemetry/telemetry.go
@@ -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{})