PrometheusCounters class
Performance counters that send their metrics to Prometheus service.
The component is normally used in passive mode conjunction with PrometheusMetricsService
.
Alternatively when connection parameters are set it can push metrics to Prometheus PushGateway.
Configuration parameters
connection(s)
:discovery_key
: (optional) a key to retrieve the connection from IDiscoveryprotocol
: connection protocol: http or httpshost
: host name or IP addressport
: port numberuri
: resource URI or connection string with all parameters in it
options
:retries
: number of retries (default: 3)connect_timeout
: connection timeout in milliseconds (default: 10 sec)timeout
: invocation timeout in milliseconds (default: 10 sec)
References
\*:logger:\*:\*:1.0
(optional) ILogger components to pass log messages\*:counters:\*:\*:1.0
(optional) ICounters components to pass collected measurements\*:discovery:\*:\*:1.0
(optional) IDiscovery services to resolve connection
See RestController See CommandableHttpController
Example
var counters = PrometheusCounters();
counters.configure(ConfigParams.fromTuples([
'connection.protocol', 'http',
'connection.host', 'localhost',
'connection.port', 8080
]));
await counters.open('123')
...
counters.increment('mycomponent.mymethod.calls');
var timing = counters.beginTiming('mycomponent.mymethod.exec_time');
try {
...
} finally {
timing.endTiming();
}
counters.dump();
- Inheritance
-
- Object
- CachedCounters
- PrometheusCounters
- Implemented types
Constructors
- PrometheusCounters()
- Creates a new instance of the performance 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.
inherited
-
clear(
String name) → void -
Clears (resets) a counter specified by its name.
inherited
-
clearAll(
) → void -
Clears (resets) all counters.
inherited
-
close(
IContext? context) → Future -
Closes component and frees used resources.
override
-
configure(
ConfigParams config) → void -
Configures component by passing configuration parameters.
override
-
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
-
isOpen(
) → bool -
Checks if the component is opened.
override
-
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
-
open(
IContext? context) → Future -
Opens the component.
override
-
save(
List< Counter> counters) → Future -
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.
override
-
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