LogCounters class

Performance counters that periodically dumps counters measurements to logger.

Configuration parameters

  • options:
    • interval: interval in milliseconds to save current counters measurements (default: 5 mins)
    • reset_timeout: timeout in milliseconds to reset the counters. 0 disables the reset (default: 0)

References

  • *:logger:*:*:1.0 ILogger components to dump the captured counters
  • *:context-info:*:*:1.0 (optional) ContextInfo to detect the context id and specify counters source

See Counter See CachedCounters See CompositeLogger

Example

var counters = LogCounters();
counters.setReferences(References.fromTuples([
    Descriptor("pip-services", "logger", "console", "default", "1.0"), ConsoleLogger()
]));

counters.increment("mycomponent.mymethod.calls");
var timing = counters.beginTiming("mycomponent.mymethod.exec_time");
try {
    ...
} finally {
    timing.endTiming();
}

counters.dump();
Inheritance

Constructors

LogCounters()
Creates a new instance of the counters.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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.
inherited
clear(String name) → void
Clears (resets) a counter specified by its name.
inherited
clearAll() → void
Clears (resets) all counters.
inherited
configure(ConfigParams config) → void
Configures component by passing configuration parameters.
inherited
dump() → void
Dumps (saves) the current values of counters.
inherited
endTiming(String? name, int elapsed) → void
Ends measurement of execution elapsed time and updates specified counter.
inherited
get(String? name, CounterType type) Counter
Gets a counter specified by its name. It counter does not exist or its type doesn't match the specified type it creates a new one.
inherited
getAll() List<Counter>
Gets all captured counters.
inherited
getInterval() int
Gets the counters dump/save interval.
inherited
increment(String name, int value) → void
Increments counter by given value.
inherited
incrementOne(String name) → void
Increments counter by 1.
inherited
last(String name, int value) → void
Records the last calculated measurement value.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
save(List<Counter>? counters) → void
Saves the current counters measurements.
override
setInterval(int value) → void
Sets the counters dump/save interval.
inherited
setReferences(IReferences references) → void
Sets references to dependent components.
stats(String name, int value) → void
Calculates min/average/max statistics based on the current and previous values.
inherited
timestamp(String name, DateTime value) → void
Records the given timestamp.
inherited
timestampNow(String name) → void
Records the current time as a timestamp.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited