@@ -51,6 +51,12 @@ func newQueryRangeStreamingGRPCHandler(cfg Config, next pipeline.AsyncRoundTripp
5151 return err
5252 }
5353
54+ // Normalize exemplars before combiner creation: 0 (unspecified) or above the configured
55+ // maximum defaults to MaxExemplars.
56+ if req .Exemplars == 0 || req .Exemplars > cfg .Metrics .Sharder .MaxExemplars {
57+ req .Exemplars = cfg .Metrics .Sharder .MaxExemplars
58+ }
59+
5460 traceql .AlignRequest (req )
5561
5662 // the end time cutoff is applied here because it has to be done before combiner creation
@@ -75,14 +81,6 @@ func newQueryRangeStreamingGRPCHandler(cfg Config, next pipeline.AsyncRoundTripp
7581 tenant , _ := user .ExtractOrgID (ctx )
7682 start := time .Now ()
7783
78- // Normalize exemplars before combiner creation: 0 (unspecified) or above the configured
79- // maximum defaults to MaxExemplars. The sharder applies the same normalization to sub-requests,
80- // but runs after the combiner is created, so we must mirror it here.
81- if cfg .Metrics .Sharder .MaxExemplars > 0 {
82- if req .Exemplars == 0 || int (req .Exemplars ) > cfg .Metrics .Sharder .MaxExemplars {
83- req .Exemplars = uint32 (cfg .Metrics .Sharder .MaxExemplars ) //nolint:gosec // G115
84- }
85- }
8684 var finalResponse * tempopb.QueryRangeResponse
8785 c , err := combiner .NewTypedQueryRange (req , cfg .Metrics .Sharder .MaxResponseSeries )
8886 if err != nil {
@@ -141,6 +139,12 @@ func newMetricsQueryRangeHTTPHandler(cfg Config, next pipeline.AsyncRoundTripper
141139 return httpInvalidRequest (err ), nil
142140 }
143141
142+ // Normalize exemplars before combiner creation: 0 (unspecified) or above the configured
143+ // maximum defaults to MaxExemplars.
144+ if queryRangeReq .Exemplars == 0 || queryRangeReq .Exemplars > cfg .Metrics .Sharder .MaxExemplars {
145+ queryRangeReq .Exemplars = cfg .Metrics .Sharder .MaxExemplars
146+ }
147+
144148 traceql .AlignRequest (queryRangeReq )
145149
146150 // the end time cutoff is applied here because it has to be done before combiner creation
@@ -156,14 +160,6 @@ func newMetricsQueryRangeHTTPHandler(cfg Config, next pipeline.AsyncRoundTripper
156160 }
157161 req = api .BuildQueryRangeRequest (req , queryRangeReq , "" )
158162
159- // Normalize exemplars before combiner creation: 0 (unspecified) or above the configured
160- // maximum defaults to MaxExemplars. The sharder applies the same normalization to sub-requests,
161- // but runs after the combiner is created, so we must mirror it here.
162- if cfg .Metrics .Sharder .MaxExemplars > 0 {
163- if queryRangeReq .Exemplars == 0 || int (queryRangeReq .Exemplars ) > cfg .Metrics .Sharder .MaxExemplars {
164- queryRangeReq .Exemplars = uint32 (cfg .Metrics .Sharder .MaxExemplars ) //nolint:gosec // G115
165- }
166- }
167163 // build and use roundtripper
168164 combiner , err := combiner .NewTypedQueryRange (queryRangeReq , cfg .Metrics .Sharder .MaxResponseSeries )
169165 if err != nil {
0 commit comments