Re-add code to replace periods with dashes

This commit is contained in:
Ryan Mclean 2016-08-02 17:33:00 -04:00
parent 41b18a6c92
commit af62789a96
2 changed files with 6 additions and 5 deletions

View file

@ -162,7 +162,8 @@ class StatsDCollector(object):
"""
path = self._get_prefixes(metric_type) + list(path)
return '{}.{}'.format(self._namespace, '.'.join(str(p) for p in path))
return '{}.{}'.format(self._namespace,
'.'.join(str(p).replace('.', '-') for p in path))
def _get_prefixes(self, metric_type):
"""Get prefixes where applicable

View file

@ -58,7 +58,7 @@ class StatsdMetricCollectionTests(testing.AsyncHTTPTestCase):
self.assertEqual(response.code, 204)
expected = 'testing.timers.{}.SimpleHandler.GET.204'.format(
socket.gethostname())
socket.gethostname().replace('.', '-'))
for path, value, stat_type in self.statsd.find_metrics(expected, 'ms'):
assert_between(250.0, float(value), 500.0)
@ -67,7 +67,7 @@ class StatsdMetricCollectionTests(testing.AsyncHTTPTestCase):
self.assertEqual(response.code, 204)
prefix = 'testing.counters.{}.request.path'.format(
socket.gethostname())
socket.gethostname().replace('.', '-'))
for path, value, stat_type in self.statsd.find_metrics(prefix, 'c'):
self.assertEqual(int(value), 1)
@ -76,7 +76,7 @@ class StatsdMetricCollectionTests(testing.AsyncHTTPTestCase):
self.assertEqual(response.code, 204)
prefix = 'testing.counters.{}.path'.format(
socket.gethostname())
socket.gethostname().replace('.', '-'))
for path, value, stat_type in self.statsd.find_metrics(prefix, 'c'):
self.assertEqual(int(value), 5)
@ -85,7 +85,7 @@ class StatsdMetricCollectionTests(testing.AsyncHTTPTestCase):
self.assertEqual(response.code, 204)
prefix = 'testing.timers.{}.one.two.three'.format(
socket.gethostname())
socket.gethostname().replace('.', '-'))
for path, value, stat_type in self.statsd.find_metrics(prefix, 'ms'):
assert_between(250.0, float(value), 300.0)