Commit b0500666 authored by Matthew Holt's avatar Matthew Holt

telemetry: Add variance to retry interval, and disable keepalive

parent ef48e17e
...@@ -388,6 +388,6 @@ var ( ...@@ -388,6 +388,6 @@ var (
gitCommit string // git rev-parse HEAD gitCommit string // git rev-parse HEAD
gitShortStat string // git diff-index --shortstat gitShortStat string // git diff-index --shortstat
gitFilesModified string // git diff-index --name-only HEAD gitFilesModified string // git diff-index --name-only HEAD
enableTelemetry = true
) )
const enableTelemetry = true
...@@ -44,7 +44,7 @@ func Init(instanceID uuid.UUID, disabledMetricsKeys []string) { ...@@ -44,7 +44,7 @@ func Init(instanceID uuid.UUID, disabledMetricsKeys []string) {
instanceUUID = instanceID instanceUUID = instanceID
disabledMetricsMu.Lock() disabledMetricsMu.Lock()
for _, key := range disabledMetricsKeys { for _, key := range disabledMetricsKeys {
disabledMetrics[key] = false disabledMetrics[strings.TrimSpace(key)] = false
} }
disabledMetricsMu.Unlock() disabledMetricsMu.Unlock()
enabled = true enabled = true
......
...@@ -38,6 +38,7 @@ import ( ...@@ -38,6 +38,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
"math/rand"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
...@@ -202,9 +203,9 @@ func emit(final bool) error { ...@@ -202,9 +203,9 @@ func emit(final bool) error {
// schedule the next update using our default update // schedule the next update using our default update
// interval because the server might be healthy later // 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 { 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 // schedule the next update (if this wasn't the last one and
...@@ -345,7 +346,13 @@ func (s countingSet) MarshalJSON() ([]byte, error) { ...@@ -345,7 +346,13 @@ func (s countingSet) MarshalJSON() ([]byte, error) {
var ( var (
// httpClient should be used for HTTP requests. It // httpClient should be used for HTTP requests. It
// is configured with a timeout for reliability. // 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 holds the data that we are building up to send.
buffer = make(map[string]interface{}) buffer = make(map[string]interface{})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment