MCPcopy
hub / github.com/prometheus/client_golang / NewClient

Function NewClient

api/client.go:89–104  ·  view source on GitHub ↗

NewClient returns a new Client. It is safe to use the returned Client from multiple goroutines.

(cfg Config)

Source from the content-addressed store, hash-verified

87//
88// It is safe to use the returned Client from multiple goroutines.
89func NewClient(cfg Config) (Client, error) {
90 u, err := url.Parse(cfg.Address)
91 if err != nil {
92 return nil, err
93 }
94 u.Path = strings.TrimRight(u.Path, "/")
95
96 if err := cfg.validate(); err != nil {
97 return nil, err
98 }
99
100 return &httpClient{
101 endpoint: u,
102 client: cfg.client(),
103 }, nil
104}
105
106type httpClient struct {
107 endpoint *url.URL

Callers 11

ExampleAPI_queryFunction · 0.92
ExampleAPI_queryRangeFunction · 0.92
ExampleAPI_seriesFunction · 0.92
runMainFunction · 0.92
runMainFunction · 0.92
BenchmarkClientFunction · 0.85

Calls 2

validateMethod · 0.80
clientMethod · 0.80