56quarters / cadence

An extensible Statsd client for Rust
https://docs.rs/cadence/
Apache License 2.0
84 stars 27 forks source link

Add support for incrementing and decrementing a gauge #180

Closed pmembrey closed 2 years ago

pmembrey commented 2 years ago

The statsd spec provides for incrementing and decrementing a gauge just as can be done with a counter. This allows independent parts of an application to report the change they are making to the gauge without having to synchronise or coordinate with each other.

The gauge takes either a number (say 123.45) or a delta (such as -1 or +7).

56quarters commented 2 years ago

I'm unlikely to merge a PR that adds this.

I don't think gauge deltas make sense because of the ambiguity they introduce: -1 was already a valid value to set a gauge to but with deltas it now means something different. The fact that you can no longer set gauges to negative values is noted in the docs as a limitation. The suggested work around is to set a gauge to zero first. This isn't a particularly satisfying answer because it's perfectly reasonable to send a single metric per UDP packet and UDP packets can be reordered, leading to different values on the server side.

Another reason I'm unlikely to add support for this is because DataDog clients don't appear to support it and some Cadence users use it with DataDog.

pmembrey commented 2 years ago

Those are great points. I agree that it's likely to cause more trouble than its worth, so I'll close this out. Thanks for taking the time to give such a detailed response! 😊