| 313 | } |
| 314 | |
| 315 | func ParseQueryRangeRequest(r *http.Request) (*tempopb.QueryRangeRequest, error) { |
| 316 | req := &tempopb.QueryRangeRequest{} |
| 317 | vals := r.URL.Query() |
| 318 | |
| 319 | // check "query" first. this was originally added for prom compatibility and Grafana still uses it. |
| 320 | if s, ok := extractQueryParam(vals, "query"); ok { |
| 321 | req.Query = s |
| 322 | } |
| 323 | |
| 324 | // also check the `q` parameter. this is what all other Tempo endpoints take for a TraceQL query. |
| 325 | if s, ok := extractQueryParam(vals, urlParamQuery); ok { |
| 326 | req.Query = s |
| 327 | } |
| 328 | |
| 329 | if s, ok := extractQueryParam(vals, QueryModeKey); ok { |
| 330 | req.QueryMode = s |
| 331 | } |
| 332 | |
| 333 | start, end, err := bounds(vals) |
| 334 | if err != nil { |
| 335 | return nil, httpgrpc.Error(http.StatusBadRequest, err.Error()) |
| 336 | } |
| 337 | req.Start = uint64(start.UnixNano()) |
| 338 | req.End = uint64(end.UnixNano()) |
| 339 | |
| 340 | step, err := step(vals, start, end) |
| 341 | if err != nil { |
| 342 | return nil, httpgrpc.Error(http.StatusBadRequest, err.Error()) |
| 343 | } |
| 344 | req.Step = uint64(step.Nanoseconds()) |
| 345 | |
| 346 | // New RF1 params |
| 347 | blockID, _ := extractQueryParam(vals, urlParamBlockID) |
| 348 | if blockID, err := uuid.Parse(blockID); err == nil { |
| 349 | req.BlockID = blockID.String() |
| 350 | } |
| 351 | |
| 352 | startPage, _ := extractQueryParam(vals, urlParamStartPage) |
| 353 | if startPage, err := strconv.ParseUint(startPage, 10, 32); err == nil { |
| 354 | req.StartPage = uint32(startPage) |
| 355 | } |
| 356 | |
| 357 | pagesToSearch, _ := extractQueryParam(vals, urlParamPagesToSearch) |
| 358 | if of, err := strconv.ParseUint(pagesToSearch, 10, 32); err == nil { |
| 359 | req.PagesToSearch = uint32(of) |
| 360 | } |
| 361 | |
| 362 | version, _ := extractQueryParam(vals, urlParamVersion) |
| 363 | req.Version = version |
| 364 | |
| 365 | size, _ := extractQueryParam(vals, urlParamSize) |
| 366 | if size, err := strconv.ParseUint(size, 10, 64); err == nil { |
| 367 | req.Size_ = uint64(size) |
| 368 | } |
| 369 | |
| 370 | footerSize, _ := extractQueryParam(vals, urlParamFooterSize) |
| 371 | if footerSize, err := strconv.ParseUint(footerSize, 10, 32); err == nil { |
| 372 | req.FooterSize = uint32(footerSize) |