()
| 402 | } |
| 403 | |
| 404 | func (t *App) initQuerier() (services.Service, error) { |
| 405 | if !IsSingleBinary(t.cfg.Target) && t.cfg.Querier.Worker.FrontendAddress == "" { // if we're not in single binary mode and worker address is not specified - bail |
| 406 | return nil, fmt.Errorf("frontend worker address not specified") |
| 407 | } else if IsSingleBinary(t.cfg.Target) && t.cfg.Querier.Worker.FrontendAddress == "" { // if we're in single binary mode with no worker address specified, register default endpoint |
| 408 | t.cfg.Querier.Worker.FrontendAddress = fmt.Sprintf("127.0.0.1:%d", t.cfg.Server.GRPCListenPort) |
| 409 | level.Warn(log.Logger).Log("msg", "Worker address is empty in single binary mode. Attempting automatic worker configuration. If queries are unresponsive consider configuring the worker explicitly.", "address", t.cfg.Querier.Worker.FrontendAddress) |
| 410 | } |
| 411 | |
| 412 | // do not enable polling if this is the single binary. in that case the backend-worker will take care of polling |
| 413 | if t.cfg.Target == Querier { |
| 414 | t.store.EnablePolling(context.Background(), nil, false) |
| 415 | } |
| 416 | |
| 417 | liveStoreRing := t.readRings[ringLiveStore] |
| 418 | |
| 419 | querier, err := querier.New( |
| 420 | t.cfg.Querier, |
| 421 | liveStoreRing, |
| 422 | t.cfg.LiveStoreClient, |
| 423 | t.partitionRing, |
| 424 | t.cfg.Frontend.TraceByID.ExternalEnabled, |
| 425 | t.store, |
| 426 | t.Overrides, |
| 427 | ) |
| 428 | if err != nil { |
| 429 | return nil, fmt.Errorf("failed to create querier: %w", err) |
| 430 | } |
| 431 | t.querier = querier |
| 432 | |
| 433 | middleware := middleware.Merge( |
| 434 | t.HTTPAuthMiddleware, |
| 435 | ) |
| 436 | |
| 437 | tracesHandler := middleware.Wrap(http.HandlerFunc(t.querier.TraceByIDHandler)) |
| 438 | t.Server.HTTPRouter().Handle(path.Join(api.PathPrefixQuerier, addHTTPAPIPrefix(&t.cfg, api.PathTraces)), tracesHandler) |
| 439 | |
| 440 | tracesHandlerV2 := middleware.Wrap(http.HandlerFunc(t.querier.TraceByIDHandlerV2)) |
| 441 | t.Server.HTTPRouter().Handle(path.Join(api.PathPrefixQuerier, addHTTPAPIPrefix(&t.cfg, api.PathTracesV2)), tracesHandlerV2) |
| 442 | |
| 443 | searchHandler := t.HTTPAuthMiddleware.Wrap(http.HandlerFunc(t.querier.SearchHandler)) |
| 444 | t.Server.HTTPRouter().Handle(path.Join(api.PathPrefixQuerier, addHTTPAPIPrefix(&t.cfg, api.PathSearch)), searchHandler) |
| 445 | |
| 446 | searchTagsHandler := t.HTTPAuthMiddleware.Wrap(http.HandlerFunc(t.querier.SearchTagsHandler)) |
| 447 | t.Server.HTTPRouter().Handle(path.Join(api.PathPrefixQuerier, addHTTPAPIPrefix(&t.cfg, api.PathSearchTags)), searchTagsHandler) |
| 448 | |
| 449 | searchTagsV2Handler := t.HTTPAuthMiddleware.Wrap(http.HandlerFunc(t.querier.SearchTagsV2Handler)) |
| 450 | t.Server.HTTPRouter().Handle(path.Join(api.PathPrefixQuerier, addHTTPAPIPrefix(&t.cfg, api.PathSearchTagsV2)), searchTagsV2Handler) |
| 451 | |
| 452 | searchTagValuesHandler := t.HTTPAuthMiddleware.Wrap(http.HandlerFunc(t.querier.SearchTagValuesHandler)) |
| 453 | t.Server.HTTPRouter().Handle(path.Join(api.PathPrefixQuerier, addHTTPAPIPrefix(&t.cfg, api.PathSearchTagValues)), searchTagValuesHandler) |
| 454 | |
| 455 | searchTagValuesV2Handler := t.HTTPAuthMiddleware.Wrap(http.HandlerFunc(t.querier.SearchTagValuesV2Handler)) |
| 456 | t.Server.HTTPRouter().Handle(path.Join(api.PathPrefixQuerier, addHTTPAPIPrefix(&t.cfg, api.PathSearchTagValuesV2)), searchTagValuesV2Handler) |
| 457 | |
| 458 | queryRangeHandler := t.HTTPAuthMiddleware.Wrap(http.HandlerFunc(t.querier.QueryRangeHandler)) |
| 459 | t.Server.HTTPRouter().Handle(path.Join(api.PathPrefixQuerier, addHTTPAPIPrefix(&t.cfg, api.PathMetricsQueryRange)), queryRangeHandler) |
| 460 | |
| 461 | return t.querier, t.querier.CreateAndRegisterWorker(t.Server.HTTPHandler()) |
nothing calls this directly
no test coverage detected