General format function. >>> StatsdClient.format("example.format", 2, "T") {'example.format': '2|T'} >>> formatted = StatsdClient.format(("example.format31", "example.format37"), "2", "T") >>> formatted['example.format31'] == '2|T' True >>> f
(keys, value, _type)
| 88 | |
| 89 | @staticmethod |
| 90 | def format(keys, value, _type): |
| 91 | """ |
| 92 | General format function. |
| 93 | |
| 94 | >>> StatsdClient.format("example.format", 2, "T") |
| 95 | {'example.format': '2|T'} |
| 96 | >>> formatted = StatsdClient.format(("example.format31", "example.format37"), "2", "T") |
| 97 | >>> formatted['example.format31'] == '2|T' |
| 98 | True |
| 99 | >>> formatted['example.format37'] == '2|T' |
| 100 | True |
| 101 | >>> len(formatted) |
| 102 | 2 |
| 103 | """ |
| 104 | data = {} |
| 105 | value = "{0}|{1}".format(value, _type) |
| 106 | # TODO: Allow any iterable except strings |
| 107 | if not isinstance(keys, (list, tuple)): |
| 108 | keys = [keys] |
| 109 | for key in keys: |
| 110 | data[key] = value |
| 111 | return data |
| 112 | |
| 113 | @staticmethod |
| 114 | def sample(data, sample_rate): |