Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where tags list increases in size #94

Merged
merged 1 commit into from
Nov 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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