Documentation ¶
Index ¶
- Constants
- func DataSourceMetricsMiddleware() sdkhttpclient.Middleware
- func ForwardedCookiesMiddleware(forwardedCookies []*http.Cookie, allowedCookies []string, ...) httpclient.Middleware
- func HTTPLoggerMiddleware(cfg setting.PluginSettings) sdkhttpclient.Middleware
- func New(cfg *setting.Cfg, validator validations.PluginRequestValidator, ...) *sdkhttpclient.Provider
- func PrometheusMetricsMiddleware(metrics *PrometheusMetrics) httpclient.Middleware
- func RedirectLimitMiddleware(reqValidator validations.PluginRequestValidator) sdkhttpclient.Middleware
- func ResponseLimitMiddleware(limit int64) sdkhttpclient.Middleware
- func SetUserAgentMiddleware(userAgent string) httpclient.Middleware
- func SigV4Middleware(verboseLogging bool) httpclient.Middleware
- func TracingMiddleware(logger log.Logger, tracer tracing.Tracer) httpclient.Middleware
- type PrometheusMetrics
Constants ¶
const DataSourceMetricsMiddlewareName = "metrics"
const ForwardedCookiesMiddlewareName = "forwarded-cookies"
const HTTPLoggerMiddlewareName = "http-logger"
const HostRedirectValidationMiddlewareName = "host-redirect-validation"
const ResponseLimitMiddlewareName = "response-limit"
ResponseLimitMiddlewareName is the middleware name used by ResponseLimitMiddleware.
const SetUserAgentMiddlewareName = "user-agent"
SetUserAgentMiddlewareName is the middleware name used by SetUserAgentMiddleware.
const SigV4MiddlewareName = "sigv4"
SigV4MiddlewareName the middleware name used by SigV4Middleware.
const (
TracingMiddlewareName = "tracing"
)
Variables ¶
This section is empty.
Functions ¶
func DataSourceMetricsMiddleware ¶
func DataSourceMetricsMiddleware() sdkhttpclient.Middleware
func ForwardedCookiesMiddleware ¶
func ForwardedCookiesMiddleware(forwardedCookies []*http.Cookie, allowedCookies []string, disallowedCookies []string) httpclient.Middleware
ForwardedCookiesMiddleware middleware that sets Cookie header on the outgoing request, if forwarded cookies configured/provided.
func HTTPLoggerMiddleware ¶
func HTTPLoggerMiddleware(cfg setting.PluginSettings) sdkhttpclient.Middleware
func New ¶
func New(cfg *setting.Cfg, validator validations.PluginRequestValidator, tracer tracing.Tracer) *sdkhttpclient.Provider
New creates a new HTTP client provider with pre-configured middlewares.
func PrometheusMetricsMiddleware ¶
func PrometheusMetricsMiddleware(metrics *PrometheusMetrics) httpclient.Middleware
PrometheusMetricsMiddleware is a middleware that will mutate the in flight, requests, duration and failure count on the provided *PrometheusMetrics instance. This can be used to count the number of requests, successful requests and errors that go through the httpclient, as well as to track the response times. For the metrics to be exposed properly, the provided *PrometheusMetrics should already be registered in a Prometheus registry.
func RedirectLimitMiddleware ¶
func RedirectLimitMiddleware(reqValidator validations.PluginRequestValidator) sdkhttpclient.Middleware
func ResponseLimitMiddleware ¶
func ResponseLimitMiddleware(limit int64) sdkhttpclient.Middleware
func SetUserAgentMiddleware ¶
func SetUserAgentMiddleware(userAgent string) httpclient.Middleware
SetUserAgentMiddleware is middleware that sets the HTTP header User-Agent on the outgoing request. If User-Agent already set, it will not be overridden by this middleware.
func SigV4Middleware ¶
func SigV4Middleware(verboseLogging bool) httpclient.Middleware
SigV4Middleware applies AWS Signature Version 4 request signing for the outgoing request.
func TracingMiddleware ¶
func TracingMiddleware(logger log.Logger, tracer tracing.Tracer) httpclient.Middleware
Types ¶
type PrometheusMetrics ¶
type PrometheusMetrics struct {
// contains filtered or unexported fields
}
PrometheusMetrics groups some metrics for a PrometheusMetricsMiddleware
func NewPrometheusMetricsMiddleware ¶
func NewPrometheusMetricsMiddleware(prefix string) *PrometheusMetrics
NewPrometheusMetricsMiddleware returns a new *PrometheusMetrics with pre-filled metrics, with the specified prefix
func (*PrometheusMetrics) MustRegister ¶
func (m *PrometheusMetrics) MustRegister(registry prometheus.Registerer)
MustRegister is like Register, but, in case of failure, it panics instead of returning an error
func (*PrometheusMetrics) Register ¶
func (m *PrometheusMetrics) Register(registry prometheus.Registerer) error
Register registers the metrics in the current PrometheusMetrics into the provided registry
func (*PrometheusMetrics) WithMustRegister ¶
func (m *PrometheusMetrics) WithMustRegister(registry prometheus.Registerer) *PrometheusMetrics
WithMustRegister calls MustRegister and returns itself. This is to allow to chain the method call upon initialization, useful when declaring metrics in the global scope:
var svcMetrics = NewPrometheusMetricsMiddleware("my_client").WithMustRegister(prometheus.DefaultRegisterer)