Skip to content

Commit

Permalink
Use tag_value instead of tag.value for tagless statsd
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed May 12, 2020
1 parent fe6e562 commit 5857459
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions baseframe/statsd.py
Expand Up @@ -102,13 +102,14 @@ def _metric_name(self, name, tags):
tag_join = '='
else:
prefix = 'flask_app.{}'.format(current_app.config['SITE_ID'])
tag_sep = tag_join = '.'
tag_sep = '.'
tag_join = '_'
if tags:
name += tag_sep + tag_sep.join(
tag_join.join((str(t), str(v))) if v is not None else str(t)
for t, v in tags.items()
)
return '%s.%s' % (prefix, name)
return '{}.{}'.format(prefix, name)

def _wrapper(self, metric, stat, *args, **kwargs):
tags = kwargs.pop('tags', None)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_statsd.py
Expand Up @@ -92,7 +92,7 @@ def test_wrapper_tags(self):
with patch('statsd.StatsClient.incr') as mock_incr:
statsd.incr('test.counter', tags={'tag': 'value'})
mock_incr.assert_called_once_with(
'flask_app.tests.test_statsd.test.counter.tag.value', rate=1
'flask_app.tests.test_statsd.test.counter.tag_value', rate=1
)

# Tags are enabled if a separator character is specified in config,
Expand Down

0 comments on commit 5857459

Please sign in to comment.