MCPcopy Index your code
hub / github.com/cortexproject/cortex / newFrontendPool

Function newFrontendPool

pkg/ruler/frontend_client_pool.go:26–51  ·  view source on GitHub ↗
(cfg Config, log log.Logger, reg prometheus.Registerer)

Source from the content-addressed store, hash-verified

24}
25
26func newFrontendPool(cfg Config, log log.Logger, reg prometheus.Registerer) *client.Pool {
27 p := &frontendPool{
28 timeout: cfg.FrontendTimeout,
29 queryResponseFormat: cfg.QueryResponseFormat,
30 prometheusHTTPPrefix: cfg.PrometheusHTTPPrefix,
31 grpcConfig: cfg.GRPCClientConfig,
32 frontendClientRequestDuration: promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
33 Name: "cortex_ruler_query_frontend_request_duration_seconds",
34 Help: "Time spend doing requests to frontend.",
35 Buckets: prometheus.ExponentialBuckets(0.001, 4, 6),
36 }, []string{"operation", "status_code"}),
37 }
38
39 frontendClientsGauge := promauto.With(reg).NewGauge(prometheus.GaugeOpts{
40 Name: "cortex_ruler_query_frontend_clients",
41 Help: "The current number of clients connected to query-frontend.",
42 })
43
44 poolConfig := client.PoolConfig{
45 CheckInterval: time.Minute,
46 HealthCheckEnabled: true,
47 HealthCheckTimeout: 10 * time.Second,
48 }
49
50 return client.NewPool("frontend", poolConfig, nil, p.createFrontendClient, frontendClientsGauge, log)
51}
52
53func (f *frontendPool) createFrontendClient(addr string) (client.PoolClient, error) {
54 opts, err := f.grpcConfig.DialOption(grpcclient.Instrument(f.frontendClientRequestDuration))

Callers 1

Calls 1

NewPoolFunction · 0.92

Tested by

no test coverage detected