Feuerlabs/exometer — pull request #105 by uwiger (2014-10-31 15:04:21+00:00)
Title: add wrap_counter type

Feedback wanted.

Wrapping counters are sometimes useful (e.g. expected in SNMP). This PR adds a `wrap_counter` type (docs not yet updated), where the `{wrap, {Min, Max}}` option provides a range.

To discuss:
* Another option would be to extend the `counter` type.
* What should the initial value be? Separately specified? Currently, initial value is `0`, which is also what the counter resets to.

Example:
```erlang
15:21:42.136 [info] Application exometer started on node nonode@nohost
2> exometer:new([c], wrap_counter, [{wrap,{0,4}}]).
ok
3> exometer:update([c],1).
ok
4> exometer:get_value([c]).
{ok,[{value,1},{ms_since_reset,10727}]}
5> [begin exometer:update([c],1), exometer:get_value([c],value) end || _ <- lists:seq(1,10)].
[{ok,[{value,2}]},
{ok,[{value,3}]},
{ok,[{value,4}]},
{ok,[{value,0}]},
{ok,[{value,1}]},
{ok,[{value,2}]},
{ok,[{value,3}]},
{ok,[{value,4}]},
{ok,[{value,0}]},
{ok,[{value,1}]}]
6> exometer:reset([c]).
ok
7> exometer:get_value([c]).
{ok,[{value,0},{ms_since_reset,2799}]}
```