mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05: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
 | 
						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) {
 | 
				
			|||||||
	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 (
 | 
				
			|||||||
	"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 {
 | 
				
			|||||||
	// 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) {
 | 
				
			|||||||
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{})
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user