http

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientWrapper

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

ClientWrapper wraps an HTTP client with metrics instrumentation.

func NewClientWrapper

func NewClientWrapper(client *http.Client, metrics *Metrics, log *logrus.Logger) *ClientWrapper

NewClientWrapper creates a new HTTP client wrapper with metrics.

func (*ClientWrapper) Client

func (c *ClientWrapper) Client() *http.Client

Client returns the underlying HTTP client.

func (*ClientWrapper) Do

func (c *ClientWrapper) Do(req *http.Request, service, operation string) (*http.Response, error)

Do executes an HTTP request with metrics tracking.

func (*ClientWrapper) Get

func (c *ClientWrapper) Get(url, service, operation string) (*http.Response, error)

Get performs a GET request with metrics.

type Metrics

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

Metrics for API connections.

func NewMetrics

func NewMetrics(namespace string) *Metrics

NewMetrics creates a new API metrics instance.

func (*Metrics) ObserveAPIRequestDuration

func (m *Metrics) ObserveAPIRequestDuration(service, operation string, duration float64)

ObserveAPIRequestDuration records the duration of an API request.

func (*Metrics) RecordAPIError

func (m *Metrics) RecordAPIError(service, operation, errorType string)

RecordAPIError increments the API error counter.

func (*Metrics) RecordAPIRequest

func (m *Metrics) RecordAPIRequest(service, operation string)

RecordAPIRequest increments the API request counter.

type MetricsRoundTripper

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

MetricsRoundTripper is an http.RoundTripper that collects metrics.

func NewMetricsRoundTripper

func NewMetricsRoundTripper(next http.RoundTripper, metrics *Metrics, log *logrus.Logger, opts ...RoundTripperOption) *MetricsRoundTripper

NewMetricsRoundTripper creates a new metrics-collecting round tripper.

func (*MetricsRoundTripper) RoundTrip

func (t *MetricsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface.

type RoundTripperOption

type RoundTripperOption func(*MetricsRoundTripper)

RoundTripperOption is a function that configures a MetricsRoundTripper.

func WithService

func WithService(service string) RoundTripperOption

WithService sets the service name for the MetricsRoundTripper.

Jump to

Keyboard shortcuts

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