Skip to content

Commit

Permalink
[dogstatsd] Correct inverted constants (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
prognant authored Jun 19, 2020
1 parent 19dd434 commit c160dcb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ def __init__(self, host=DEFAULT_HOST, port=DEFAULT_PORT, max_buffer_size=None, n
self.port = None
transport = "uds"
if not self._max_payload_size:
self._max_payload_size = UDP_OPTIMAL_PAYLOAD_LENGTH
self._max_payload_size = UDS_OPTIMAL_PAYLOAD_LENGTH
else:
self.socket_path = None
self.host = self.resolve_host(host, use_default_route)
self.port = int(port)
transport = "udp"
if not self._max_payload_size:
self._max_payload_size = UDS_OPTIMAL_PAYLOAD_LENGTH
self._max_payload_size = UDP_OPTIMAL_PAYLOAD_LENGTH

# Socket
self.socket = None
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/dogstatsd/test_statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# datadog
from datadog import initialize, statsd
from datadog import __version__ as version
from datadog.dogstatsd.base import DogStatsd
from datadog.dogstatsd.base import DogStatsd, UDP_OPTIMAL_PAYLOAD_LENGTH
from datadog.dogstatsd.context import TimedContextManagerDecorator
from datadog.util.compat import is_higher_py35, is_p3k
from tests.util.contextmanagers import preserve_environment_variable, EnvVars
Expand Down Expand Up @@ -706,12 +706,13 @@ def test_context_manager(self):
assert_equal(metric, fake_socket.recv())
assert_equal(telemetry_metrics(metrics=2, bytes_sent=len(metric)), fake_socket.recv())
# assert_equal_telemetry("page.views:123|g\ntimer:123|ms", fake_socket.recv(2), telemetry=telemetry_metrics(metrics=2))

def test_batched_buffer_autoflush(self):
fake_socket = FakeSocket()
bytes_sent = 0
with DogStatsd(telemetry_min_flush_interval=0) as statsd:
single_metric = 'mycounter:1|c'
statsd._max_payload_size = 2048
assert_equal(statsd._max_payload_size, UDP_OPTIMAL_PAYLOAD_LENGTH)
metrics_per_packet = statsd._max_payload_size // (len(single_metric) + 1)
statsd.socket = fake_socket
for i in range(metrics_per_packet + 1):
Expand Down

0 comments on commit c160dcb

Please sign in to comment.