public interface Counter extends Simon
Counter counter = SimonManager.getCounter("com.my.counter"); System.out.println("counter = " + counter);Output is:
counter = Simon Counter: [com.my.counter INHERIT] counter=0, max=undef, min=undefThis behavior allows the counter to be initialized before it is used and its extremes are tracked - first initialization also sets max/min (extreme) values:
Counter counter = SimonManager.getCounter("com.my.counter").set(47); System.out.println("counter = " + counter);Output is:
counter = Simon Counter: [com.my.counter INHERIT] counter=47, max=47, min=47
increase()
and decrease()
methods when
it is possible to track the monitored value - this can be used for example to count users logged
in. If the value changes by more than 1 than it is possible to use methods with arguments -
increase(long)
and decrease(long)
. Finally method set(long)
is
always available to set the counter to the particular value when needed.Modifier and Type | Method and Description |
---|---|
Counter |
decrease()
Decrements the counter by one.
|
Counter |
decrease(long dec)
Increments the counter by the specified value.
|
long |
getCounter()
Returns the current value of the counter.
|
long |
getDecrementSum()
Returns the sum of all decremented values (as a positive number).
|
long |
getIncrementSum()
Returns the sum of all incremented values.
|
long |
getMax()
Returns maximal value of counter.
|
long |
getMaxTimestamp()
Returns ms timestamp when the max value was reached.
|
long |
getMin()
Returns minimal value of counter.
|
long |
getMinTimestamp()
Returns ms timestamp when the min value was reached.
|
Counter |
increase()
Increments the counter by one.
|
Counter |
increase(long inc)
Increments the counter by the specified value.
|
CounterSample |
sample()
Samples Simon values and returns them in a Java Bean derived from Sample interface.
|
CounterSample |
sampleIncrement(Object key)
Samples increment in Simon values since the previous call of this method with the
same key.
|
CounterSample |
sampleIncrementNoReset(Object key)
Samples current value of incremental Simon.
|
Counter |
set(long val)
Sets the value of the counter to specified value.
|
getChildren, getFirstUsage, getLastUsage, getManager, getName, getNote, getParent, getState, isEnabled, setNote, setState, stopIncrementalSampling
getAttribute, getAttribute, getAttributeNames, getCopyAsSortedMap, removeAttribute, setAttribute
Counter increase(long inc)
inc
- added valueCounter decrease(long dec)
dec
- subtracted valuelong getCounter()
long getMin()
long getMinTimestamp()
long getMax()
long getMaxTimestamp()
Counter set(long val)
val
- new counter valuelong getIncrementSum()
long getDecrementSum()
CounterSample sample()
Simon
CounterSample sampleIncrement(Object key)
Simon
Simon.sample()
. Any subsequent calls with the key
provide increments.
Clients can use any sampling key (any Object) which enables safe access to their own increments.
Using String does not guarantee this as any client can potentially guess the key. This
may or may not be an issue.sampleIncrement
in interface Simon
key
- sampling key used to access incremental sampleSample
with value incrementsCounterSample sampleIncrementNoReset(Object key)
Simon
Simon.sampleIncrement(Object)
but
does not reset the incremental Simon. This method does not start incremental sampling
and keeps returning values from Simon.sample()
for any key that was not used with
Simon.sampleIncrement(Object)
before.sampleIncrementNoReset
in interface Simon
key
- sampling key used to access incremental sampleSample
with value incrementsSimon.sampleIncrement(Object)
Copyright © 2019. All rights reserved.