Skip to content

Commit

Permalink
Merge pull request #94 from steven-liu/fix-constant-tags
Browse files Browse the repository at this point in the history
Fix bug where tags list increases in size
  • Loading branch information
yannmh committed Nov 3, 2015
2 parents 84e8d94 + d68749c commit b5f7d6d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def _report(self, metric, metric_type, value, tags, sample_rate):
# Append all client level tags to every metric
if self.constant_tags:
if tags:
tags += self.constant_tags
tags = tags + self.constant_tags
else:
tags = self.constant_tags

Expand Down
11 changes: 11 additions & 0 deletions tests/unit/dogstatsd/test_statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ def test_counter_constant_tag_with_metric_level_tags(self):
self.statsd.increment('page.views', tags=['extra'])
t.assert_equal('page.views:1|c|#extra,bar:baz,foo', self.recv())

def test_gauge_constant_tags_with_metric_level_tags_twice(self):
metric_level_tag = ['foo:bar']
self.statsd.constant_tags=['bar:baz']
self.statsd.gauge('gauge', 123.4, tags=metric_level_tag)
assert self.recv() == 'gauge:123.4|g|#foo:bar,bar:baz'

# sending metrics multiple times with same metric-level tags
# should not duplicate the tags being sent
self.statsd.gauge('gauge', 123.4, tags=metric_level_tag)
assert self.recv() == 'gauge:123.4|g|#foo:bar,bar:baz'

@staticmethod
def assert_almost_equal(a, b, delta):
assert 0 <= abs(a - b) <= delta, "%s - %s not within %s" % (a, b, delta)
Expand Down

0 comments on commit b5f7d6d

Please sign in to comment.