MCPcopy Index your code
hub / github.com/cortexproject/cortex / query

Method query

integration/e2ecortex/client.go:631–671  ·  view source on GitHub ↗
(addr string, headers map[string]string)

Source from the content-addressed store, hash-verified

629}
630
631func (c *Client) query(addr string, headers map[string]string) (*http.Response, []byte, error) {
632 ctx, cancel := context.WithTimeout(context.Background(), c.timeout)
633 defer cancel()
634
635 req, err := http.NewRequestWithContext(ctx, "GET", addr, nil)
636 if err != nil {
637 return nil, nil, err
638 }
639
640 req.Header.Set("X-Scope-OrgID", c.orgID)
641
642 for key, value := range headers {
643 req.Header.Set(key, value)
644 }
645
646 retries := backoff.New(ctx, backoff.Config{
647 MinBackoff: 1 * time.Second,
648 MaxBackoff: 2 * time.Second,
649 MaxRetries: 10,
650 })
651 var (
652 res *http.Response
653 )
654 for retries.Ongoing() {
655 res, err = c.httpClient.Do(req)
656 if err == nil {
657 break
658 }
659 retries.Wait()
660 }
661 if err != nil {
662 return nil, nil, err
663 }
664 defer res.Body.Close()
665
666 body, err := io.ReadAll(res.Body)
667 if err != nil {
668 return nil, nil, err
669 }
670 return res, body, nil
671}
672
673// Series finds series by label matchers.
674func (c *Client) Series(matches []string, start, end time.Time) ([]model.LabelSet, error) {

Callers 6

QueryRangeRawMethod · 0.95
QueryRawMethod · 0.95
SeriesRawMethod · 0.95
LabelNamesRawMethod · 0.95
LabelValuesRawMethod · 0.95
QueryMethod · 0.80

Calls 6

NewFunction · 0.92
OngoingMethod · 0.80
SetMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65
WaitMethod · 0.45

Tested by 1

QueryMethod · 0.64