CompositeCounters class
Aggregates all counters from component references under a single component.
It allows to capture metrics and conveniently send them to multiple destinations.
References
- *:counters:*:*:1.0 (optional) ICounters components to pass collected measurements
See ICounters
Example
class MyComponent implements IReferenceable {
var _counters = new CompositeCounters();
void setReferences(IReferences references) {
_counters.setReferences(references);
...
}
void myMethod() {
_counters.increment('mycomponent.mymethod.calls');
var timing =_counters.beginTiming('mycomponent.mymethod.exec_time');
try {
...
} finally {
timing.endTiming();
}
}
}
- Implemented types
Constructors
- CompositeCounters([IReferences? references])
- Creates a new instance of the counters.
Properties
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
Methods
-
beginTiming(
String name) → CounterTiming -
Begins measurement of execution time interval.
It returns CounterTiming object which has to be called at
CounterTiming.endTiming to end the measurement and update the counter.
override
-
endTiming(
String? name, int elapsed) → void -
Ends measurement of execution elapsed time and updates specified counter.
override
-
increment(
String? name, int value) → void -
Increments counter by given value.
override
-
incrementOne(
String name) → void -
Increments counter by 1.
override
-
last(
String name, int value) → void -
Records the last calculated measurement value.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setReferences(
IReferences references) → void -
Sets references to dependent components.
override
-
stats(
String name, int value) → void -
Calculates min/average/max statistics based on the current and previous values.
override
-
timestamp(
String name, DateTime value) → void -
Records the given timestamp.
override
-
timestampNow(
String name) → void -
Records the current time as a timestamp.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited