diff --git a/datadog/dogstatsd/base.py b/datadog/dogstatsd/base.py index b039f1d7f..07aaefdbf 100644 --- a/datadog/dogstatsd/base.py +++ b/datadog/dogstatsd/base.py @@ -929,11 +929,19 @@ def _reset_telemetry(self): self.bytes_dropped_queue = 0 self.bytes_dropped_writer = 0 self.packets_sent = 0 - self.packets_dropped = 0 self.packets_dropped_queue = 0 self.packets_dropped_writer = 0 self._last_flush_time = time.time() + # Aliases for backwards compatibility. + @property + def packets_dropped(self): + return self.packets_dropped_queue + self.packets_dropped_writer + + @property + def bytes_dropped(self): + return self.bytes_dropped_queue + self.bytes_dropped_writer + def _flush_telemetry(self): telemetry_tags = ",".join(self._add_constant_tags(self._client_tags)) diff --git a/tests/unit/dogstatsd/test_statsd.py b/tests/unit/dogstatsd/test_statsd.py index 56855146a..2b65ecb7a 100644 --- a/tests/unit/dogstatsd/test_statsd.py +++ b/tests/unit/dogstatsd/test_statsd.py @@ -1928,3 +1928,18 @@ def test_set_socket_timeout(self): statsd.set_socket_timeout(1) self.assertEqual(statsd.socket.timeout, 1) self.assertEqual(statsd.socket_timeout, 1) + + def test_telemetry_api(self): + statsd = DogStatsd(disable_background_sender=False) + + self.assertEqual(statsd.metrics_count, 0) + self.assertEqual(statsd.events_count, 0) + self.assertEqual(statsd.service_checks_count, 0) + self.assertEqual(statsd.bytes_sent, 0) + self.assertEqual(statsd.bytes_dropped, 0) + self.assertEqual(statsd.bytes_dropped_queue, 0) + self.assertEqual(statsd.bytes_dropped_writer, 0) + self.assertEqual(statsd.packets_sent, 0) + self.assertEqual(statsd.packets_dropped, 0) + self.assertEqual(statsd.packets_dropped_queue, 0) + self.assertEqual(statsd.packets_dropped_writer, 0)