(ctx context.Context, qs string, ts time.Time)
| 50 | } |
| 51 | |
| 52 | func (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 | |
| 90 | func (p *FrontendClient) InstantQuery(ctx context.Context, qs string, t time.Time) (promql.Vector, error) { |
| 91 | log, ctx := spanlogger.New(ctx, "FrontendClient.InstantQuery") |
no test coverage detected