Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] stadalone statsd implementation #47

Draft
wants to merge 1 commit into
base: unstable
Choose a base branch
from

Conversation

f00b4r0
Copy link
Contributor

@f00b4r0 f00b4r0 commented Aug 2, 2024

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

// Can't have char const * pointers here, because statsd-c-client
// may potentially modify their contents :/

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 :)

This gets rid of the semi-borken statsd-c-client dependency and uses a
standalone implementation instead. Also supports floating point gauges.

Currently a packet is still sent for each data point to keep the patch
within statsd.c, but the code can be further optimized to send multiple
datapoint per packet. The code does not modify the passed arguments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant