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

Function New

prometheus/push/push.go:91–114  ·  view source on GitHub ↗

New creates a new Pusher to push to the provided URL with the provided job name (which must not be empty). You can use just host:port or ip:port as url, in which case “http://” is added automatically. Alternatively, include the schema in the URL. However, do not include the “/metrics/jobs/…” part.

(url, job string)

Source from the content-addressed store, hash-verified

89// in which case “http://” is added automatically. Alternatively, include the
90// schema in the URL. However, do not include the “/metrics/jobs/…” part.
91func New(url, job string) *Pusher {
92 var (
93 reg = prometheus.NewRegistry()
94 err error
95 )
96 if job == "" {
97 err = errJobEmpty
98 }
99 if !strings.Contains(url, "://") {
100 url = "http://" + url
101 }
102 url = strings.TrimSuffix(url, "/")
103
104 return &Pusher{
105 error: err,
106 url: url,
107 job: job,
108 grouping: map[string]string{},
109 gatherers: prometheus.Gatherers{reg},
110 registerer: reg,
111 client: &http.Client{},
112 expfmt: expfmt.NewFormat(expfmt.TypeProtoDelim),
113 }
114}
115
116// Push collects/gathers all metrics from all Collectors and Gatherers added to
117// this Pusher. Then, it pushes them to the Pushgateway configured while

Callers 3

ExamplePusher_AddFunction · 0.92
ExamplePusher_PushFunction · 0.92
TestPushFunction · 0.70

Calls 2

NewRegistryFunction · 0.92
ContainsMethod · 0.80

Tested by 3

ExamplePusher_AddFunction · 0.74
ExamplePusher_PushFunction · 0.74
TestPushFunction · 0.56