type RoundTripperFunc … // RoundTrip implements the RoundTripper interface. func (rt RoundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error) { … } // InstrumentRoundTripperInFlight is a middleware that wraps the provided // http.RoundTripper. It sets the provided prometheus.Gauge to the number of // requests currently handled by the wrapped http.RoundTripper. // // See the example for ExampleInstrumentRoundTripperDuration for example usage. func InstrumentRoundTripperInFlight(gauge prometheus.Gauge, next http.RoundTripper) RoundTripperFunc { … } // InstrumentRoundTripperCounter is a middleware that wraps the provided // http.RoundTripper to observe the request result with the provided CounterVec. // The CounterVec must have zero, one, or two non-const non-curried labels. For // those, the only allowed label names are "code" and "method". The function // panics otherwise. For the "method" label a predefined default label value set // is used to filter given values. Values besides predefined values will count // as `unknown` method.`WithExtraMethods` can be used to add more // methods to the set. Partitioning of the CounterVec happens by HTTP status code // and/or HTTP method if the respective instance label names are present in the // CounterVec. For unpartitioned counting, use a CounterVec with zero labels. // // If the wrapped RoundTripper panics or returns a non-nil error, the Counter // is not incremented. // // Use with WithExemplarFromContext to instrument the exemplars on the counter of requests. // // See the example for ExampleInstrumentRoundTripperDuration for example usage. func InstrumentRoundTripperCounter(counter *prometheus.CounterVec, next http.RoundTripper, opts ...Option) RoundTripperFunc { … } // InstrumentRoundTripperDuration is a middleware that wraps the provided // http.RoundTripper to observe the request duration with the provided // ObserverVec. The ObserverVec must have zero, one, or two non-const // non-curried labels. For those, the only allowed label names are "code" and // "method". The function panics otherwise. For the "method" label a predefined // default label value set is used to filter given values. Values besides // predefined values will count as `unknown` method. `WithExtraMethods` // can be used to add more methods to the set. The Observe method of the Observer // in the ObserverVec is called with the request duration in // seconds. Partitioning happens by HTTP status code and/or HTTP method if the // respective instance label names are present in the ObserverVec. For // unpartitioned observations, use an ObserverVec with zero labels. Note that // partitioning of Histograms is expensive and should be used judiciously. // // If the wrapped RoundTripper panics or returns a non-nil error, no values are // reported. // // Use with WithExemplarFromContext to instrument the exemplars on the duration histograms. // // Note that this method is only guaranteed to never observe negative durations // if used with Go1.9+. func InstrumentRoundTripperDuration(obs prometheus.ObserverVec, next http.RoundTripper, opts ...Option) RoundTripperFunc { … } type InstrumentTrace … // InstrumentRoundTripperTrace is a middleware that wraps the provided // RoundTripper and reports times to hook functions provided in the // InstrumentTrace struct. Hook functions that are not present in the provided // InstrumentTrace struct are ignored. Times reported to the hook functions are // time since the start of the request. Only with Go1.9+, those times are // guaranteed to never be negative. (Earlier Go versions are not using a // monotonic clock.) Note that partitioning of Histograms is expensive and // should be used judiciously. // // For hook functions that receive an error as an argument, no observations are // made in the event of a non-nil error value. // // See the example for ExampleInstrumentRoundTripperDuration for example usage. func InstrumentRoundTripperTrace(it *InstrumentTrace, next http.RoundTripper) RoundTripperFunc { … }