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
()
| 327 | // characters, the usual url.QueryEscape is used for compatibility with older |
| 328 | // versions of the Pushgateway and for better readability. |
| 329 | func (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, |
no test coverage detected