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

Function NewAPI

tools/query-audit/runner.go:12–32  ·  view source on GitHub ↗

NewAPI instantiates a prometheus api

(backend Backend)

Source from the content-addressed store, hash-verified

10
11// NewAPI instantiates a prometheus api
12func NewAPI(backend Backend) (v1.API, error) {
13 config := api.Config{
14 Address: backend.Host,
15 }
16
17 if len(backend.Headers) > 0 {
18 config.RoundTripper = promhttp.RoundTripperFunc(func(req *http.Request) (*http.Response, error) {
19 for key, value := range backend.Headers {
20 req.Header.Add(key, value)
21 }
22 return http.DefaultTransport.RoundTrip(req)
23 })
24 }
25
26 c, err := api.NewClient(config)
27 if err != nil {
28 return nil, err
29 }
30
31 return v1.NewAPI(c), nil
32}

Callers 1

RunFunction · 0.70

Calls 2

AddMethod · 0.45
RoundTripMethod · 0.45

Tested by

no test coverage detected