You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bytes_sent and bytes_dropped_writer telemetry count characters, not bytes #983
datadog.dogstatsd.client.bytes_sent and bytes_dropped_writer count characters, not bytes. datadog/dogstatsd/base.py:1791 does self.bytes_sent += len(packet) on the str, while the bytes actually sent are encoded_packet — computed nine lines above at :1782 and handed to mysocket.send. Same at :1662, :1666 and :1734.
:1648 in the same file is byte-correct (len(packet_with_newline.encode(self.encoding))), from #927 "fix: report the right number of dropped bytes". That PR fixed bytes_dropped_queue and did not touch the other four sites.
To Reproduce
Point a client at a real UDP socket, send a metric with a multibyte tag, and compare the bytes received against the value the client then self-reports:
Over five cases (datadog/dogstatsd at fac2d5e, Python 3.13):
payload
on the wire
reported
env:prod (ascii control)
25
25
city:montréal
31
30
region:東京
30
26
event("deploy", "done 🚀")
25
22
service_check(message="café unreachable")
30
29
Expected behavior
The counters report the number of bytes. DataDog/datadog-gostatsd/telemetry.go:73 documents TotalBytesSent as "the total number of bytes succesfully sent by the client", and feeds it to the same datadog.dogstatsd.client.bytes_sent metric at :290; being Go, its lengths are byte counts by construction.
The reason the suite is green: assert_equal_telemetry (tests/unit/dogstatsd/test_statsd.py:172) builds its default expectation as telemetry_metrics(bytes_sent=len(expected_payload)) — the same character count the implementation uses — and bytes_sent=len( appears 39 times in that file, never once with .encode(...). test_event_with_container_field is the clearest case: at :2567 it asserts the event header as _e{5,32} for a 19-character, 32-byte text, so the byte length is written into the same assertion, and then asserts bytes_sent=len(event3) seven lines later.
Found by checking datadogpy's DogStatsD wire handling field by field against datadog-go, not from a production incident. Written with Claude Code. Happy to open a PR.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.
If you would like this issue to remain open:
Verify that you can still reproduce the issue in the latest version of this project.
Comment that the issue is still reproducible and include updated details requested in the issue template.
Activity
Count utf-8 bytes in the bytes_sent and bytes_dropped_writer telemetry
github-actions commentedon Oct 2, 2026
Thanks for your contribution!
This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.
If you would like this issue to remain open:
Verify that you can still reproduce the issue in the latest version of this project.
Comment that the issue is still reproducible and include updated details requested in the issue template.
Count utf-8 bytes in the bytes_sent and bytes_dropped_writer telemetry
Count utf-8 bytes in the bytes_sent and bytes_dropped_writer telemetry