diff --git a/datadog/dogstatsd/base.py b/datadog/dogstatsd/base.py index 1bdb47f5d..5c7c946eb 100644 --- a/datadog/dogstatsd/base.py +++ b/datadog/dogstatsd/base.py @@ -1026,6 +1026,8 @@ def service_check( self._send(string) def _add_constant_tags(self, tags): + if isinstance(tags, dict): + tags = list(map(lambda kv: '%s:%s' % kv, tags.items())) if self.constant_tags: if tags: return tags + self.constant_tags diff --git a/tests/unit/dogstatsd/test_statsd.py b/tests/unit/dogstatsd/test_statsd.py index 658804a19..2820b2660 100644 --- a/tests/unit/dogstatsd/test_statsd.py +++ b/tests/unit/dogstatsd/test_statsd.py @@ -334,6 +334,10 @@ def test_tagged_histogram(self): self.statsd.histogram('h', 1, tags=['red']) self.assert_equal_telemetry('h:1|h|#red\n', self.recv(2)) + def test_dict_tagged(self): + self.statsd.increment('dct', tags={'country': 'españa'}) + self.assert_equal_telemetry('dct:1|c|#country:españa\n', self.recv(2)) + def test_sample_rate(self): # Disabling telemetry since sample_rate imply randomness self.statsd._telemetry = False