Documentation ¶
Index ¶
- Variables
- func ContextWithMetrics(ctx context.Context, cfg *HttpMetricCollectionConfig) context.Context
- func WithBearerToken(ctx context.Context, bearerToken string) context.Context
- type AuthenticatingRoundTripper
- type ExaminingRoundTripper
- type HttpCounterMetricPicker
- type HttpCounterMetricPickerFunc
- type HttpGaugeMetricPicker
- type HttpGaugeMetricPickerFunc
- type HttpHistogramOrSummaryMetricPicker
- type HttpHistogramOrSummaryMetricPickerFunc
- type HttpMetricCollectingRoundTripper
- type HttpMetricCollectionConfig
- type RoundTripExaminer
- type RoundTripExaminerFunc
Constants ¶
This section is empty.
Variables ¶
var AuthenticatingRoundTripperContextKey = authenticatingRoundTripperContextKeyType{}
Functions ¶
func ContextWithMetrics ¶ added in v0.8.2
func ContextWithMetrics(ctx context.Context, cfg *HttpMetricCollectionConfig) context.Context
ContextWithMetrics returns a new context based on the supplied one that contains the provided metrics collection configurations. If this context is used to perform an HTTP request with the HttpMetricCollectingRoundTripper, the configured metrics will be collected.
func WithBearerToken ¶
WithBearerToken inserts the bearer token into the returned context which is based on the provided context. If this context is then used with the HTTP request in a client having the AuthenticatingRoundTripper as its transport, the round tripper will insert this token into the Authorization header of the request.
Types ¶
type AuthenticatingRoundTripper ¶
type AuthenticatingRoundTripper struct {
http.RoundTripper
}
AuthenticatingRoundTripper is a wrapper around an HTTP round tripper that add a bearer token from the context (if any) before performing the request using the wrapped round tripper.
type ExaminingRoundTripper ¶
type ExaminingRoundTripper struct { http.RoundTripper Examiner RoundTripExaminer }
ExaminingRoundTripper is an HTTP request round tripper that calls the Examiner after the request is made so that it can examine the request and response or turn it into an error.
type HttpCounterMetricPicker ¶ added in v0.8.2
type HttpCounterMetricPicker interface {
Pick(r *http.Request, resp *http.Response, err error) []prometheus.Counter
}
HttpCounterMetricPicker is an interface used by the HttpMetricCollectingRoundTripper to pick the counter metrics to collect based on the request and response. Because it is used during an HTTP round trip, the implementations of this interface must be thread-safe.
type HttpCounterMetricPickerFunc ¶ added in v0.8.2
HttpCounterMetricPickerFunc is a functional implementation of HttpCounterMetricPicker.
func (HttpCounterMetricPickerFunc) Pick ¶ added in v0.8.2
func (h HttpCounterMetricPickerFunc) Pick(r *http.Request, resp *http.Response, err error) []prometheus.Counter
type HttpGaugeMetricPicker ¶ added in v0.8.2
type HttpGaugeMetricPicker interface {
Pick(r *http.Request, resp *http.Response, err error) []prometheus.Gauge
}
HttpGaugeMetricPicker is an interface used by the HttpMetricCollectingRoundTripper to pick the gauge metrics to collect based on the request and response. Because it is used during an HTTP round trip, the implementations of this interface must be thread-safe.
type HttpGaugeMetricPickerFunc ¶ added in v0.8.2
HttpGaugeMetricPickerFunc is a functional implementation of HttpGaugeMetricPicker
func (HttpGaugeMetricPickerFunc) Pick ¶ added in v0.8.2
func (h HttpGaugeMetricPickerFunc) Pick(r *http.Request, resp *http.Response, err error) []prometheus.Gauge
type HttpHistogramOrSummaryMetricPicker ¶ added in v0.8.2
type HttpHistogramOrSummaryMetricPicker interface {
Pick(r *http.Request, resp *http.Response, err error) []prometheus.Observer
}
HttpHistogramOrSummaryMetricPicker is an interface used by the HttpMetricCollectingRoundTripper to pick the histogram or summary metrics to collect based on the request and response. Because it is used during an HTTP round trip, the implementations of this interface must be thread-safe.
type HttpHistogramOrSummaryMetricPickerFunc ¶ added in v0.8.2
type HttpHistogramOrSummaryMetricPickerFunc func(*http.Request, *http.Response, error) []prometheus.Observer
HttpHistogramOrSummaryMetricPickerFunc is a functional implementation of HttpHistogramOrSummaryMetricPicker.
func (HttpHistogramOrSummaryMetricPickerFunc) Pick ¶ added in v0.8.2
func (h HttpHistogramOrSummaryMetricPickerFunc) Pick(r *http.Request, resp *http.Response, err error) []prometheus.Observer
type HttpMetricCollectingRoundTripper ¶ added in v0.8.2
type HttpMetricCollectingRoundTripper struct {
http.RoundTripper
}
HttpMetricCollectingRoundTripper is a wrapper around http.RoundTripper interface that, given an HttpMetricCollectionConfig, collects the metrics for each HTTP request processed. The metric collection configuration is passed to the roundtripper by injecting it into a context, so it can differ per request.
type HttpMetricCollectionConfig ¶ added in v0.8.2
type HttpMetricCollectionConfig struct { GaugePicker HttpGaugeMetricPicker CounterPicker HttpCounterMetricPicker HistogramOrSummaryPicker HttpHistogramOrSummaryMetricPicker }
HttpMetricCollectionConfig specifies what metric should be collected.
type RoundTripExaminer ¶
RoundTripExaminer is interface enabling the implementors to examine the request and response during the roundtrip and potentially somehow modify them or turn them into error.