MCPcopy Create free account
hub / github.com/cortexproject/cortex / makeRequest

Method makeRequest

pkg/ruler/frontend_client.go:52–88  ·  view source on GitHub ↗
(ctx context.Context, qs string, ts time.Time)

Source from the content-addressed store, hash-verified

50}
51
52func (p *FrontendClient) makeRequest(ctx context.Context, qs string, ts time.Time) (*httpgrpc.HTTPRequest, error) {
53 args := make(url.Values)
54 args.Set("query", qs)
55 if !ts.IsZero() {
56 args.Set("time", ts.Format(time.RFC3339Nano))
57 }
58 body := []byte(args.Encode())
59
60 //lint:ignore faillint wrapper around upstream method
61 orgID, err := user.ExtractOrgID(ctx)
62 if err != nil {
63 return nil, err
64 }
65
66 acceptHeader := ""
67 switch p.queryResponseFormat {
68 case queryResponseFormatJson:
69 acceptHeader = jsonDecoder.ContentType()
70 case queryResponseFormatProtobuf:
71 acceptHeader = fmt.Sprintf("%s,%s", protobufDecoder.ContentType(), jsonDecoder.ContentType())
72 }
73
74 req := &httpgrpc.HTTPRequest{
75 Method: http.MethodPost,
76 Url: p.prometheusHTTPPrefix + instantQueryPath,
77 Body: body,
78 Headers: []*httpgrpc.Header{
79 {Key: textproto.CanonicalMIMEHeaderKey("User-Agent"), Values: []string{fmt.Sprintf("%s/%s", tripperware.RulerUserAgent, version.Version)}},
80 {Key: textproto.CanonicalMIMEHeaderKey("Content-Type"), Values: []string{mimeTypeForm}},
81 {Key: textproto.CanonicalMIMEHeaderKey("Content-Length"), Values: []string{strconv.Itoa(len(body))}},
82 {Key: textproto.CanonicalMIMEHeaderKey("Accept"), Values: []string{acceptHeader}},
83 {Key: textproto.CanonicalMIMEHeaderKey(orgIDHeader), Values: []string{orgID}},
84 },
85 }
86
87 return req, nil
88}
89
90func (p *FrontendClient) InstantQuery(ctx context.Context, qs string, t time.Time) (promql.Vector, error) {
91 log, ctx := spanlogger.New(ctx, "FrontendClient.InstantQuery")

Callers 1

InstantQueryMethod · 0.95

Implementers 4

Frontendpkg/frontend/v1/frontend.go
frontendClientpkg/frontend/v1/frontendv1pb/frontend.
UnimplementedFrontendServerpkg/frontend/v1/frontendv1pb/frontend.
mockGrpcServiceHandlerpkg/cortex/cortex_test.go

Calls 3

SetMethod · 0.65
EncodeMethod · 0.65
ContentTypeMethod · 0.65

Tested by

no test coverage detected