Documentation ¶
Overview ¶
Package instrumentedclient is a wrapper around standard http.Client that tracks basic HTTP metrics using Prometheus. It also sets some sensinble defaults to important timeout settings. All instrumentedclient instances log to the same Prometheus variables, even if created with NewClient().
Index ¶
- Constants
- Variables
- func Get(url string) (*http.Response, error)
- func GetMetrics() []prometheus.Collector
- func Head(url string) (*http.Response, error)
- func NewClient() *http.Client
- func Post(url string, contentType string, body io.Reader) (*http.Response, error)
- func PostForm(url string, data url.Values) (*http.Response, error)
Constants ¶
View Source
const ( // Timeout for an entire HTTP transaction: sending request, reading and // response, redirects, etc. HTTPRequestResponseTimeout = 10 * time.Second // Timeout for establishing a TCP connection with a remote end. TCPConnectionTimeout = 3 * time.Second // TCP keepalive timeout. TCPKeepAliveTime = 30 * time.Second )
Variables ¶
View Source
var DefaultClient = &http.Client{ Transport: roundTripper, Timeout: HTTPRequestResponseTimeout, }
DefaultClient is an instrumented http.Client with pre-set timeouts.
Functions ¶
func GetMetrics ¶
func GetMetrics() []prometheus.Collector
GetMetrics returns Prometheus all variables that track metrics. Used for registering with an HTTP handler.
func NewClient ¶
NewClient returns a new instrumented http.Client with pre-set timeouts. Use it if you want to adjust default timeouts.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.