-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add support for time-since-last-action heartbeat metrics #26
base: master
Are you sure you want to change the base?
Add support for time-since-last-action heartbeat metrics #26
Conversation
/cc @tibbe |
Could this be implemented outside the library using |
It could be, but in that case why wouldn't |
Also, when I took a look at all Hackage packages with "ekg" in the name, all of them reuse the primitives defined in |
The data Value = Counter {-# UNPACK #-} !Int64
| Gauge {-# UNPACK #-} !Int64
| Label {-# UNPACK #-} !T.Text
| Distribution !Distribution.Stats Counters are monotonically increasing, gauges can go both up and down, and labels/distributions are different types. A heartbeat is simply a type of counter, not a semantically different kind of thing. Same story for (Now, could all the |
Right, if anything a heartbeat is a type of If the temporal semantics of a heartbeat don't matter, and instead it's a type of But it makes sense to use Haskell's type system to encode the different usage rules for the different kinds of things we want to monitor when building software in the real world. Gauges are quantity-valued, Counters are quantity-valued but can only be incremented (though the types admit adding a negative increase), and Heartbeats operate only on times. I will totally cop to ignoring typesafety in |
The distinction makes a difference to the consumer and is why statsd also has this distinction: if you know you're monitoring a monotonically-increasing value you know that if the value went down it must be because the thing you monitored was restarted (or similar). This in turns means that you can accurately graph the value over time (e.g. requests/s) in face on e.g. failing machines. I still don't quite see why heartbeat can't be just a gauge, could you give a client code example showing how it will be used? |
I've found there's a common pattern in services I write, where I want a heartbeat or watchdog timer for periodic jobs being run by an in-memory scheduler. I thought it'd be good to contribute it back as a change upstream.