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

Method fullURL

prometheus/push/push.go:329–344  ·  view source on GitHub ↗

fullURL assembles the URL used to push/delete metrics and returns it as a string. The job name and any grouping label values containing a '/' will trigger a base64 encoding of the affected component and proper suffixing of the preceding component. Similarly, an empty grouping label value will be enc

()

Source from the content-addressed store, hash-verified

327// characters, the usual url.QueryEscape is used for compatibility with older
328// versions of the Pushgateway and for better readability.
329func (p *Pusher) fullURL() string {
330 urlComponents := []string{}
331 if encodedJob, base64 := encodeComponent(p.job); base64 {
332 urlComponents = append(urlComponents, "job"+base64Suffix, encodedJob)
333 } else {
334 urlComponents = append(urlComponents, "job", encodedJob)
335 }
336 for ln, lv := range p.grouping {
337 if encodedLV, base64 := encodeComponent(lv); base64 {
338 urlComponents = append(urlComponents, ln+base64Suffix, encodedLV)
339 } else {
340 urlComponents = append(urlComponents, ln, encodedLV)
341 }
342 }
343 return fmt.Sprintf("%s/metrics/%s", p.url, strings.Join(urlComponents, "/"))
344}
345
346// encodeComponent encodes the provided string with base64.RawURLEncoding in
347// case it contains '/' and as "=" in case it is empty. If neither is the case,

Callers 2

DeleteMethod · 0.95
pushMethod · 0.95

Calls 1

encodeComponentFunction · 0.85

Tested by

no test coverage detected