| 386 | } |
| 387 | |
| 388 | func httpTransport(cfg Config, configName string, registerer prometheus.Registerer, logger log.Logger) http.RoundTripper { |
| 389 | transport := http.DefaultTransport.(*http.Transport).Clone() |
| 390 | transport.DisableKeepAlives = cfg.HTTPClientDisableKeepAlives |
| 391 | |
| 392 | var rt http.RoundTripper = transport |
| 393 | if cfg.HTTPClientClusterValidation.Label != "" { |
| 394 | invalidClusterValidations := promauto.With(registerer).NewCounterVec(prometheus.CounterOpts{ |
| 395 | Name: "client_invalid_cluster_validation_label_requests_total", |
| 396 | Help: "Number of requests with invalid cluster validation label.", |
| 397 | ConstLabels: map[string]string{ |
| 398 | "client": "runtime-config/" + configName, |
| 399 | "protocol": "http", |
| 400 | }, |
| 401 | }, []string{"method"}) |
| 402 | reporter := func(msg string, method string) { |
| 403 | level.Warn(logger).Log("msg", msg, "method", method, "cluster_validation_label", cfg.HTTPClientClusterValidation.Label, "component", "runtimeconfig", "load_path", cfg.LoadPath) |
| 404 | invalidClusterValidations.WithLabelValues(method).Inc() |
| 405 | } |
| 406 | rt = middleware.ClusterValidationRoundTripper(cfg.HTTPClientClusterValidation.Label, reporter, transport) |
| 407 | } |
| 408 | return rt |
| 409 | } |