MCPcopy
hub / github.com/grafana/tempo / initQueryFrontend

Method initQueryFrontend

cmd/tempo/app/modules.go:464–530  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

462}
463
464func (t *App) initQueryFrontend() (services.Service, error) {
465 // cortexTripper is a bridge between http and httpgrpc.
466 // It does the job of passing data to the cortex frontend code.
467 cortexTripper, v1, err := frontend.InitFrontend(t.cfg.Frontend.Config, log.Logger, prometheus.DefaultRegisterer)
468 if err != nil {
469 return nil, err
470 }
471 t.frontend = v1
472
473 // create query frontend
474 queryFrontend, err := frontend.New(t.cfg.Frontend, cortexTripper, t.Overrides, t.store, t.cacheProvider, t.cfg.HTTPAPIPrefix, t.HTTPAuthMiddleware, t.DataAccessController, log.Logger, prometheus.DefaultRegisterer)
475 if err != nil {
476 return nil, err
477 }
478
479 // register grpc server for queriers to connect to
480 frontend_v1pb.RegisterFrontendServer(t.Server.GRPC(), t.frontend)
481 // we register the streaming querier service on both the http and grpc servers. Grafana expects
482 // this GRPC service to be available on the HTTP server.
483 tempopb.RegisterStreamingQuerierServer(t.Server.GRPC(), queryFrontend)
484
485 httpAPIMiddleware := []middleware.Interface{
486 t.HTTPAuthMiddleware,
487 httpGzipMiddleware(),
488 }
489
490 // use the api timeout for http requests if set. note that this is set in initServer() for
491 // grpc requests
492 if t.cfg.Frontend.APITimeout > 0 {
493 httpAPIMiddleware = append(httpAPIMiddleware, middleware.NewTimeoutMiddleware(t.cfg.Frontend.APITimeout, "unable to process request in the configured timeout", kitlog.NewNopLogger()))
494 }
495
496 // wrap handlers with auth
497 base := middleware.Merge(httpAPIMiddleware...)
498
499 // http trace by id endpoint
500 t.Server.HTTPRouter().Handle(addHTTPAPIPrefix(&t.cfg, api.PathTraces), base.Wrap(queryFrontend.TraceByIDHandler))
501 t.Server.HTTPRouter().Handle(addHTTPAPIPrefix(&t.cfg, api.PathTracesV2), base.Wrap(queryFrontend.TraceByIDHandlerV2))
502
503 // http search endpoints
504 t.Server.HTTPRouter().Handle(addHTTPAPIPrefix(&t.cfg, api.PathSearch), base.Wrap(queryFrontend.SearchHandler))
505 t.Server.HTTPRouter().Handle(addHTTPAPIPrefix(&t.cfg, api.PathSearchTags), base.Wrap(queryFrontend.SearchTagsHandler))
506 t.Server.HTTPRouter().Handle(addHTTPAPIPrefix(&t.cfg, api.PathSearchTagsV2), base.Wrap(queryFrontend.SearchTagsV2Handler))
507 t.Server.HTTPRouter().Handle(addHTTPAPIPrefix(&t.cfg, api.PathSearchTagValues), base.Wrap(queryFrontend.SearchTagsValuesHandler))
508 t.Server.HTTPRouter().Handle(addHTTPAPIPrefix(&t.cfg, api.PathSearchTagValuesV2), base.Wrap(queryFrontend.SearchTagsValuesV2Handler))
509
510 // http metrics endpoints
511 t.Server.HTTPRouter().Handle(addHTTPAPIPrefix(&t.cfg, api.PathMetricsQueryInstant), base.Wrap(queryFrontend.MetricsQueryInstantHandler))
512 t.Server.HTTPRouter().Handle(addHTTPAPIPrefix(&t.cfg, api.PathMetricsQueryRange), base.Wrap(queryFrontend.MetricsQueryRangeHandler))
513
514 // http mcp endpoint
515 t.Server.HTTPRouter().Handle(addHTTPAPIPrefix(&t.cfg, api.PathMCP), base.Wrap(queryFrontend.MCPHandler))
516
517 // the query frontend needs to have knowledge of the blocks so it can shard search jobs
518 if t.cfg.Target == QueryFrontend {
519 t.store.EnablePolling(context.Background(), nil, false)
520 }
521

Callers

nothing calls this directly

Calls 13

InitFrontendFunction · 0.92
NewFunction · 0.92
httpGzipMiddlewareFunction · 0.85
addHTTPAPIPrefixFunction · 0.85
echoHandlerFunction · 0.85
usageStatsHandlerFunction · 0.85
MergeMethod · 0.80
GRPCMethod · 0.65
HandleMethod · 0.65
HTTPRouterMethod · 0.65
WrapMethod · 0.65

Tested by

no test coverage detected