From: Ben Kochie Date: Sat, 22 Jan 2022 19:03:14 +0000 (+0100) Subject: Merge pull request #557 from nikonhub/feature-change_default_http_user_agent X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e34a36be40264b1ceda1ba8ddbd769c4a62eac16;p=blackbox_exporter.git Merge pull request #557 from nikonhub/feature-change_default_http_user_agent Change default user agent --- e34a36be40264b1ceda1ba8ddbd769c4a62eac16 diff --cc prober/http.go index 156feca,555a10a..7d5adc3 --- a/prober/http.go +++ b/prober/http.go @@@ -33,11 -31,11 +33,12 @@@ import "sync" "time" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" + "github.com/andybalholm/brotli" + "github.com/go-kit/log" + "github.com/go-kit/log/level" "github.com/prometheus/client_golang/prometheus" pconfig "github.com/prometheus/common/config" + "github.com/prometheus/common/version" "golang.org/x/net/publicsuffix" "github.com/prometheus/blackbox_exporter/config" @@@ -208,30 -226,9 +209,32 @@@ func (t *transport) GotFirstResponseByt defer t.mu.Unlock() t.current.responseStart = time.Now() } +func (t *transport) TLSHandshakeStart() { + t.mu.Lock() + defer t.mu.Unlock() + t.current.tlsStart = time.Now() +} +func (t *transport) TLSHandshakeDone(_ tls.ConnectionState, _ error) { + t.mu.Lock() + defer t.mu.Unlock() + t.current.tlsDone = time.Now() +} + +// byteCounter implements an io.ReadCloser that keeps track of the total +// number of bytes it has read. +type byteCounter struct { + io.ReadCloser + n int64 +} + +func (bc *byteCounter) Read(p []byte) (int, error) { + n, err := bc.ReadCloser.Read(p) + bc.n += int64(n) + return n, err +} + var userAgentDefaultHeader = fmt.Sprintf("Blackbox Exporter/%s", version.Version) + func ProbeHTTP(ctx context.Context, target string, module config.Module, registry *prometheus.Registry, logger log.Logger) (success bool) { var redirects int var (