httpoutprom

package module
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 4 Imported by: 0

README

HTTP outgoing request Prometheus metrics

Provides simple wrappers around http.Client or http.RoundTripper for monitoring with Prometheus outgoing http requests.

Metrics

Metrics:

metric description
http_outgoing_request_total A counter for outgoing http requests.
http_outgoing_request_duration_seconds A histogram of outgoing http request latencies.

Default labels:

label description
scheme Request scheme, such as: http, https.
host Request host name.
method Request method, such as: GET, POST, and so on.
code Response status code.

Examples

See example folder.

Licensing

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v0.0.2

func NewClient(recorder *Recorder, client HTTPClient) *Client

func (*Client) Do

func (c *Client) Do(request *http.Request) (*http.Response, error)

type Config added in v0.0.7

type Config struct {
	DurationBuckets []float64
	Registry        prometheus.Registerer
	Service         string
	ServiceLabel    string
	HostLabel       string
	SchemeLabel     string
	MethodLabel     string
	StatusCodeLabel string
}

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type Recorder added in v0.0.7

type Recorder struct {
	// contains filtered or unexported fields
}

func NewRecorder added in v0.0.7

func NewRecorder(cfg Config) *Recorder

func (*Recorder) Collect added in v0.0.7

func (r *Recorder) Collect(in chan<- prometheus.Metric)

func (*Recorder) Describe added in v0.0.7

func (r *Recorder) Describe(in chan<- *prometheus.Desc)

func (*Recorder) IncRequest added in v0.0.7

func (r *Recorder) IncRequest(host, scheme, method, statusCode string)

func (*Recorder) ObserveDurationRequest added in v0.0.7

func (r *Recorder) ObserveDurationRequest(duration time.Duration, host, scheme, method, statusCode string)

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

func NewTransport added in v0.0.2

func NewTransport(recorder *Recorder, transport http.RoundTripper) *Transport

func (Transport) RoundTrip

func (t Transport) RoundTrip(request *http.Request) (*http.Response, error)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL