From eb766e01f454095838932bd1594bf7c0c3372548 Mon Sep 17 00:00:00 2001 From: Mohammad Yosefpor Date: Tue, 28 Dec 2021 16:07:16 +0330 Subject: [PATCH] change percentiles --- prober/http.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/prober/http.go b/prober/http.go index 76c5764..3f93848 100644 --- a/prober/http.go +++ b/prober/http.go @@ -34,7 +34,7 @@ var ( prometheus.HistogramOpts{ Name: "health_http_dns_lookup_time_seconds", Help: "The response time of dns lookup", - Buckets: []float64{0.001, 0.005, 0.01, 0.02, 0.03, 0.05, 0.075, 0.1, 0.2, 0.5, 0.75, 1, 1.5, 2, 2.5, 3, 4, 5}, + Buckets: []float64{0.0005, 0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.008, 0.01, 0.015, 0.02, 0.03, 0.05, 0.075, 0.1, 0.2, 0.5, 1}, }, []string{"name", "status_code", "dns_error", "result", "url"}, ) @@ -144,16 +144,18 @@ func (h *HTTP) calculateInterval() time.Duration { func (h *HTTP) sendRequest(ctx context.Context) HTTPResult { var startTime time.Time var dnsStartTime time.Time - var dnsDoneTime time.Time + var dnsLookupTime float64 var dnsError string + var dnsHost string httpTrace := &httptrace.ClientTrace{ - DNSStart: func(_ httptrace.DNSStartInfo) { + DNSStart: func(info httptrace.DNSStartInfo) { + dnsHost = info.Host dnsStartTime = time.Now() }, DNSDone: func(info httptrace.DNSDoneInfo) { - dnsDoneTime = time.Now() + dnsLookupTime = time.Since(dnsStartTime).Seconds() if info.Err != nil { - klog.Infof("DNS Error: %v ", info.Err) + klog.Infof("DNS Error for %v in %v seconds: %v ", dnsHost, dnsLookupTime, info.Err) dnsError = info.Err.Error() } }, @@ -167,7 +169,6 @@ func (h *HTTP) sendRequest(ctx context.Context) HTTPResult { startTime = time.Now() res, err := h.Client.Do(req) responseTime := time.Since(startTime).Seconds() - dnsLookupTime := dnsDoneTime.Sub(dnsStartTime).Seconds() if err != nil { return HTTPResult{