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

Function ParseQueryRangeRequest

pkg/api/http.go:315–409  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

313}
314
315func 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)

Callers 7

RoundTripMethod · 0.92
RoundTripMethod · 0.92
QueryRangeHandlerMethod · 0.92
TestQueryRangeRoundtripFunction · 0.85

Calls 9

SetInstantMethod · 0.95
extractQueryParamFunction · 0.85
boundsFunction · 0.85
stepFunction · 0.85
QueryMethod · 0.80
ErrorMethod · 0.65
ParseMethod · 0.65
UnmarshalMethod · 0.65
StringMethod · 0.45

Tested by 4

RoundTripMethod · 0.74
TestQueryRangeRoundtripFunction · 0.68