MCPcopy
hub / github.com/grafana/dskit / httpTransport

Function httpTransport

runtimeconfig/manager.go:388–409  ·  view source on GitHub ↗
(cfg Config, configName string, registerer prometheus.Registerer, logger log.Logger)

Source from the content-addressed store, hash-verified

386}
387
388func 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}

Callers 3

NewFunction · 0.85

Calls 4

WithMethod · 0.80
CloneMethod · 0.65
LogMethod · 0.45