| 32 | ) |
| 33 | |
| 34 | func newSchedulerProcessor(cfg Config, handler RequestHandler, log log.Logger, reg prometheus.Registerer, querierAddress string) (*schedulerProcessor, []services.Service) { |
| 35 | p := &schedulerProcessor{ |
| 36 | log: log, |
| 37 | handler: handler, |
| 38 | maxMessageSize: cfg.GRPCClientConfig.MaxSendMsgSize, |
| 39 | querierID: cfg.QuerierID, |
| 40 | grpcConfig: cfg.GRPCClientConfig, |
| 41 | targetHeaders: cfg.TargetHeaders, |
| 42 | schedulerClientFactory: func(conn *grpc.ClientConn) schedulerpb.SchedulerForQuerierClient { |
| 43 | return schedulerpb.NewSchedulerForQuerierClient(conn) |
| 44 | }, |
| 45 | frontendClientRequestDuration: promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{ |
| 46 | Name: "cortex_querier_query_frontend_request_duration_seconds", |
| 47 | Help: "Time spend doing requests to frontend.", |
| 48 | Buckets: prometheus.ExponentialBuckets(0.001, 4, 6), |
| 49 | }, []string{"operation", "status_code"}), |
| 50 | querierAddress: querierAddress, |
| 51 | } |
| 52 | |
| 53 | frontendClientsGauge := promauto.With(reg).NewGauge(prometheus.GaugeOpts{ |
| 54 | Name: "cortex_querier_query_frontend_clients", |
| 55 | Help: "The current number of clients connected to query-frontend.", |
| 56 | }) |
| 57 | |
| 58 | poolConfig := client.PoolConfig{ |
| 59 | CheckInterval: 5 * time.Second, |
| 60 | HealthCheckEnabled: true, |
| 61 | HealthCheckTimeout: 1 * time.Second, |
| 62 | } |
| 63 | |
| 64 | p.frontendPool = client.NewPool("frontend", poolConfig, nil, p.createFrontendClient, frontendClientsGauge, log) |
| 65 | return p, []services.Service{p.frontendPool} |
| 66 | } |
| 67 | |
| 68 | // Handles incoming queries from query-scheduler. |
| 69 | type schedulerProcessor struct { |