Function libcantal::start_with_reading
[−]
[src]
pub fn start_with_reading<'x, T: Collection + ?Sized>(
coll: &'x T
) -> Result<ActiveCollection<'x>, Error>
Start publishing metrics by reading old values first
Note: usually you don't need this method and just use start
. This
constructor is only useful if you have really fast restarting service
(i.e. it often restart faster than cantal's scan interval,
which is 2 seconds). Also if your program restarts normally, it will
clean file with metrics on exit. This method is originally used in
process that restarts in-place by using execve
so destructors don't
run. This constructor is also slightly more expensive.
Concurrent Use
If used very carefully this method can also be used to keep several processes writing to the same file with metrics but this use is not thoroughtly tested and very limited, known limitations:
- Same metrics must be used by all processes (file will be overwritten by a random process if not)
start_with_reading
should not be run concurrently (some external locking is required)- Levels (gauges) should either be externally synchronized or adjusted
by
incr()/decr()
instructions (notset()
) - Process crash may leave some counters / gauges non-adjusted