[RFC] stadalone statsd implementation #47
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Should you eventually be interested, this is what a completely standalone, drop-in replacement for statsd-c-client could look like. This implementation is constrained in that I wanted to keep it entirely self-contained in statsd.c and not requiring any modification of users of the API. It could of course be further optimized/simplified otherwise. It's also a cut-n-paste of tried-n-tested code of mine, hence the slightly different coding style which I'll fix as needed.
The implementation could be further improved by using a static buffer (with thread-safety implications, which can be handled), hence opening this as a draft. If we go that way it would also probably be interesting to regroup stats sent in successive statsd_*() calls into a single UDP packet, as this implementation allows. Reducing unnecessary network chatter is beneficial to reduce cpu and power usage (if by a very small margin) both on sender and receiver.
This implementation supports floating-point gauges, and it does not modify its parameters, addressing your comment here:
dumpvdl2/src/dumpvdl2.h
Lines 399 to 400 in a398633
One last added benefit is that it would make dumpvdl2 statsd support "packageable" by most distributions, as they usually don't package statsd-c-client
Let me know if there's any interest or if I should keep this to myself :)