JMetrics class
Metrics collection framework for JIntent.
Provides performance and operational metrics for:
- Intent execution time
- Effect completion time
- State update frequency
- Error rates
Example usage:
void main() {
// Enable metrics collection
JMetrics.enable();
// Optionally attach to JObserver for automatic metrics
JMetrics.attachToObserver();
runApp(MyApp());
}
// Later, retrieve metrics
final metrics = JMetrics.getMetrics();
print('Total intents: ${metrics.where((m) => m.name == 'intent.dispatched').length}');
Constructors
- JMetrics()
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- maxMetrics ↔ int
-
Maximum number of metrics retained; the oldest are dropped first.
getter/setter pair
Static Methods
-
attachToObserver(
) → void - Attaches metrics collection to JObserver for automatic tracking.
-
clear(
) → void - Clears all collected metrics.
-
detachFromObserver(
) → void - Stops the automatic tracking installed by attachToObserver.
-
disable(
) → void - Disables metrics collection.
-
enable(
) → void - Enables metrics collection.
-
getMetrics(
) → List< Metric> - Gets all collected metrics.
-
getMetricsByName(
String name) → List< Metric> - Gets metrics filtered by name.
-
getMetricsByType(
MetricType type) → List< Metric> - Gets metrics filtered by type.
-
getSummary(
) → Map< String, dynamic> - Gets a summary of metrics as a map.
-
incrementCounter(
String name, {Map< String, String> ? tags}) → void - Increments a counter metric.
-
record(
Metric metric) → void - Records a metric.
-
recordGauge(
String name, num value, {Map< String, String> ? tags}) → void - Records a gauge metric (a value that can go up or down).
-
recordHistogram(
String name, num value, {Map< String, String> ? tags}) → void - Records a histogram value (useful for distributions).
-
reset(
) → void - Restores the initial state: disabled, detached from JObserver, no metrics and the default maxMetrics.
-
startTimer(
String name, {Map< String, String> ? tags}) → String - Starts a timer for measuring duration.
-
stopTimer(
String timerId, {Map< String, String> ? tags}) → void - Stops a timer and records the duration.
Constants
- defaultMaxMetrics → const int
- The value maxMetrics has until it is changed or reset.