metrics

package
v0.0.0-...-cf6c40a Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

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

Metrics represents a collection of request metrics

func NewMetrics

func NewMetrics(thresholds map[string][]string) *Metrics

NewMetrics creates a new Metrics instance

func (*Metrics) AddRequestMetrics

func (m *Metrics) AddRequestMetrics(metrics RequestMetrics)

AddRequestMetrics adds a new request metric

func (*Metrics) CalculateAndDisplayMetrics

func (m *Metrics) CalculateAndDisplayMetrics()

CalculateAndDisplayMetrics calculates and displays the metrics

func (*Metrics) NewMetricsRoundTripper

func (m *Metrics) NewMetricsRoundTripper(
	transport *http.Transport,
	metrics *Metrics,
) http.RoundTripper

NewMetricsRoundTripper creates a new RoundTripper with metrics

type RequestMetrics

type RequestMetrics struct {
	DNSStart, DNSDone                   time.Time
	ConnectStart, ConnectDone           time.Time
	TLSHandshakeStart, TLSHandshakeDone time.Time
	GotConn                             time.Time
	WroteHeaders                        time.Time
	WroteRequest                        time.Time
	GotFirstResponseByte                time.Time
	StartTime, EndTime                  time.Time
	Request                             *http.Request
	Response                            *http.Response
	Error                               error
}

RequestMetrics represents a single request metric

type RoundTripper

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

RoundTripper is a custom RoundTripper that records metrics

func (*RoundTripper) RoundTrip

func (m *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes a single HTTP transaction and records metrics

Jump to

Keyboard shortcuts

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