normalizeRequestExemplars resolves the final exemplar limit for a query range request. It applies the exemplars hint from the TraceQL query if present, overriding the value from the HTTP parameter. req.Exemplars is then capped to maxExemplars. If no hint is set and req.Exemplars is 0 (unspecified),
(req *tempopb.QueryRangeRequest, maxExemplars uint32)
| 188 | // from the HTTP parameter. req.Exemplars is then capped to maxExemplars. |
| 189 | // If no hint is set and req.Exemplars is 0 (unspecified), it defaults to maxExemplars. |
| 190 | func normalizeRequestExemplars(req *tempopb.QueryRangeRequest, maxExemplars uint32) error { |
| 191 | expr, err := traceql.ParseNoOptimizations(req.Query) |
| 192 | if err != nil { |
| 193 | return err |
| 194 | } |
| 195 | if v, ok := expr.Hints.GetInt(traceql.HintExemplars, false); ok { |
| 196 | req.Exemplars = uint32(max(v, 0)) //nolint: gosec // G115 |
| 197 | } else if v, ok := expr.Hints.GetBool(traceql.HintExemplars, false); ok && !v { |
| 198 | req.Exemplars = 0 |
| 199 | } else if req.Exemplars == 0 { |
| 200 | req.Exemplars = maxExemplars |
| 201 | } |
| 202 | if req.Exemplars > maxExemplars { |
| 203 | req.Exemplars = maxExemplars |
| 204 | } |
| 205 | return nil |
| 206 | } |
| 207 | |
| 208 | func logQueryRangeResult(ctx context.Context, logger log.Logger, tenantID string, durationSeconds float64, req *tempopb.QueryRangeRequest, resp *tempopb.QueryRangeResponse, err error) { |
| 209 | traceID, _ := tracing.ExtractTraceID(ctx) |