Size-based packetization for dogstatsd batched metrics #562
Conversation
hush-hush
left a comment
There was a problem hiding this comment.
I think we should deprecate the old behavior. If a user set a number of metrics per buffer we respect and don't check for size.
By default max_buffer_size would be zero and we would use the actual byte size.
2bf0d57 to
62274cb
Compare
62274cb to
35732b3
Compare
hush-hush
left a comment
There was a problem hiding this comment.
Overall it looks good. Since the API for DogStatsd changed we should bump the major, but I'm not sure if we can do it since the whole repo contains multiple project. We should sync with ing-tool-libs on this.
If bumping the major is not possible, we could still receive max_buffer_size in the API but not use it and print a warning ?
I will sync & assess the situation with ing-tool-libs |
datadog/dogstatsd/base.py
Outdated
| return self.socket | ||
|
|
||
| def open_buffer(self, max_buffer_size=50): | ||
| def open_buffer(self): |
There was a problem hiding this comment.
This breaks the current API FWIW.
I'm not against it, but if you're going to break the API, it'd be better to provide a new one that e.g. fixes #439
There was a problem hiding this comment.
I had a quick discussion about that, we agreed not to break the API, pending upcoming rework (I keep in mind the redis pipeline idea thanks again BTW).
77c9b25 to
00368b5
Compare
e8a0e04 to
46a5570
Compare
What does this PR do?
It improves the packetization while sending batched metrics with packet size adjusted to prevent fragmentation while maximizing payload usage. Telemetry is sent in separate packets, once every 10 seconds won't impact overall performance. API is backward compatible,
max_buffer_sizehas been deprecated but not removed, warning are logged if the parameter is used when buildingDogstatsdobjects.Description of the Change
It adds sending heuristic based on current buffer length. Some approximation regarding the actual bytes sent on wire include unicode character encoding (note that the telemetry is not accounting for that either).
Alternate Designs
Better optimal packet size detection could have been considered but it seems overkill, moreover the settings can be overridden.
Possible Drawbacks
Verification Process
Unit tests, integration tests, manual tests, packet capture.
Additional Notes
Future rework of the client is planned and will include better multithreading awareness and optimal packet size management without the need to use batched metrics pattern.
Release Notes
Review checklist (to be filled by reviewers)
changelog/label attached. If applicable it should have thebackward-incompatiblelabel attached.do-not-merge/label attached.kind/andseverity/labels attached at least.