Skip to main content

REST method execution statistics

Rest-annotated classes get automated timing and error statistic information for all @RestOp and lifecycle-event annotated methods on the class. If you extend from BasicRestServlet or BasicRestResource, then the statistics are made available through the REST interface via the StatsMixin op-mixin's following method:

@RestGet(
path="/stats",
summary="Timing statistics",
description="Timing statistics for method invocations on this resource."
)
@Override /* StatsMixin */
public RestContextStats getStats(RestRequest req) {
return req.getContext().getStats();
}

Rendered in a browser, the method table looks like this. The rows are the methods of the petstore's about resource (/console/about/stats); each shows its run count, timing and error counts:

The per-method statistics table of the petstore about resource

The default REST configuration provides a link to the stats in the navlinks section of the page:

The about resource's navlinks: UP, API and STATS

When a method throws, the thrownStore column links to the stored exceptions. Each one carries a hash that is also written to the log file, which gives a quick way of locating the exception in the logs.

REST interface access to the statistics are provided via the following methods (contributed by StatsMixin):

StatsMixin (composed into BasicRestServlet, BasicRestResource, and their groups)getStats(RestRequest)

Programmatic access to the statistics are provided via the following methods:

RestContextgetStats()