(k, v)
| 780 | |
| 781 | |
| 782 | def _escape_grouping_key(k, v): |
| 783 | if v == "": |
| 784 | # Per https://github.com/prometheus/pushgateway/pull/346. |
| 785 | return k + "@base64", "=" |
| 786 | elif '/' in v or ' ' in v: |
| 787 | # Added in Pushgateway 0.9.0. |
| 788 | # Use base64 encoding for values containing slashes or spaces |
| 789 | return k + "@base64", base64.urlsafe_b64encode(v.encode("utf-8")).decode("utf-8") |
| 790 | else: |
| 791 | return k, quote_plus(v) |
| 792 | |
| 793 | |
| 794 | def instance_ip_grouping_key() -> Dict[str, Any]: |