Watches requests.
see is called as the request begins and is not awaited, so an observer is free to await ObservedRequest.summary and report once the request has finished:
class Metrics implements Observer {
const Metrics();
@override
Future<void> see(ObservedRequest observed) async {
final summary = await observed.summary;
requests.labels(summary.routePath ?? 'unmatched').inc();
latency.observe(summary.duration.inMilliseconds);
}
}
Or report immediately, and ignore the futures entirely:
@override
void see(ObservedRequest observed) {
log('${observed.request.method} ${observed.request.uri}');
}
Errors are caught and logged rather than allowed to reach the response — a broken exporter must not take the request with it.
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
-
see(
ObservedRequest observed) → FutureOr< void> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited