diff --git a/modules/frontend/frontend.go b/modules/frontend/frontend.go index 9c6ae4458e0..66d82d55c5f 100644 --- a/modules/frontend/frontend.go +++ b/modules/frontend/frontend.go @@ -14,6 +14,7 @@ import ( "github.com/golang/protobuf/jsonpb" //nolint:all //deprecated "github.com/golang/protobuf/proto" //nolint:all //deprecated "github.com/grafana/dskit/user" + "github.com/grafana/tempo/modules/frontend/combiner" "github.com/opentracing/opentracing-go" "github.com/prometheus/client_golang/prometheus" @@ -54,16 +55,37 @@ func New(cfg Config, next http.RoundTripper, o overrides.Interface, reader tempo retryWare := newRetryWare(cfg.MaxRetries, registerer) - // tracebyid middleware - traceByIDMiddleware := MergeMiddlewares(newTraceByIDMiddleware(cfg, o, logger), retryWare) - searchMiddleware := MergeMiddlewares(newSearchMiddleware(cfg, o, reader, logger), retryWare) - searchTagsMiddleware := MergeMiddlewares(newSearchTagsMiddleware(), retryWare) + // TODO: return error for routes that don't support multi-tenant queries + + // inject multi-tenant middleware in multi-tenant routes + traceByIDMiddleware := MergeMiddlewares( + newMultiTenantMiddleware(cfg, combiner.NewTraceByID, logger), + newTraceByIDMiddleware(cfg, o, logger), retryWare) + + searchMiddleware := MergeMiddlewares( + newMultiTenantMiddleware(cfg, combiner.NewSearch, logger), + newSearchMiddleware(cfg, o, reader, logger), retryWare) + + searchTagsMiddleware := MergeMiddlewares( + newMultiTenantMiddleware(cfg, combiner.NewSearchTags, logger), + newSearchTagsMiddleware(), retryWare) + + searchTagsValuesMiddleware := MergeMiddlewares( + newMultiTenantMiddleware(cfg, combiner.NewSearchTagValues, logger), + newSearchTagsMiddleware(), retryWare) + + searchTagsValuesV2Middleware := MergeMiddlewares( + newMultiTenantMiddleware(cfg, combiner.NewSearchTagValuesV2, logger), + newSearchTagsMiddleware(), retryWare) spanMetricsMiddleware := MergeMiddlewares(newSpanMetricsMiddleware(), retryWare) traces := traceByIDMiddleware.Wrap(next) search := searchMiddleware.Wrap(next) searchTags := searchTagsMiddleware.Wrap(next) + searchTagValues := searchTagsValuesMiddleware.Wrap(next) + searchTagValuesV2 := searchTagsValuesV2Middleware.Wrap(next) + metrics := spanMetricsMiddleware.Wrap(next) return &QueryFrontend{ @@ -71,8 +93,8 @@ func New(cfg Config, next http.RoundTripper, o overrides.Interface, reader tempo SearchHandler: newHandler(search, searchSLOPostHook(cfg.Search.SLO), searchSLOPreHook, logger), SearchTagsHandler: newHandler(searchTags, nil, nil, logger), SearchTagsV2Handler: newHandler(searchTags, nil, nil, logger), - SearchTagsValuesHandler: newHandler(searchTags, nil, nil, logger), - SearchTagsValuesV2Handler: newHandler(searchTags, nil, nil, logger), + SearchTagsValuesHandler: newHandler(searchTagValues, nil, nil, logger), + SearchTagsValuesV2Handler: newHandler(searchTagValuesV2, nil, nil, logger), SpanMetricsSummaryHandler: newHandler(metrics, nil, nil, logger), SearchWSHandler: newSearchStreamingWSHandler(cfg, o, retryWare.Wrap(next), reader, apiPrefix, logger),