|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface MonitoringStatistics
Monitoring statistics return statistic information about application run like number of requests received, duration of request processing, number of successfully processed requests, statistical information about execution of methods and resources, information about matching but also static information about application configuration like application name, registered resource classes and such.
Monitoring statistics is the main interface from which all statistic information can be retrieved. Statistics can be retried in two ways: these can be injected or received from registered callback interfaceMonitoringStatisticsListener. The following is the example of statistic injection:
@Path("resource")
public static class StatisticsTest {
@Inject
Provider<MonitoringStatistics> statistics;
@GET
public String getAppName() throws InterruptedException {
final MonitoringStatistics monitoringStatistics = statistics.get();
final String name = monitoringStatistics.getApplicationStatistics()
.getResourceConfig().getApplicationName();
return name;
}
}
Note usage of Provider to retrieve statistics. Statistics change over time and this will
inject the latest statistics. In the case of singleton resources usage of Provider is the only way how
to inject statistics that are up to date.
Retrieving statistics by MonitoringStatisticsListener is convenient in cases when there is a need
to take an action only when new statistics are calculated which occurs in not defined irregular intervals
(once per second for example).
The contract does not mandate MonitoringStatistics to be immutable. Implementation of monitoring statistics
might be mutable, which means that an instance of MonitoringStatistics
might change its internal state over time. In order to get immutable snapshot of statistics
the method snapshot() must be called to get a snapshot of the statistics that guarantees
that data to be immutable and consistent. Nested statistics interfaces contain also snapshot method which
can be used in the same way.
Note that a snapshot of MonitoringStatistics performs a deep snapshot of nested statistics object too, so there
is no need to call the snapshot method again on nested statistics components.
The implementation of this interface may be mutable and change it's state by an external event, however it is guaranteed to be thread-safe.
| Method Summary | |
|---|---|
ApplicationStatistics |
getApplicationStatistics()
Get global statistics about application and configuration of application. |
ExceptionMapperStatistics |
getExceptionMapperStatistics()
Get statistics about registered exception mappers. |
ExecutionStatistics |
getRequestStatistics()
Get the global application statistics of request execution. |
Map<Class<?>,ResourceStatistics> |
getResourceClassStatistics()
Get the statistics for each resource Class that is deployed in the application. |
ResponseStatistics |
getResponseStatistics()
Get global application response statistics. |
Map<String,ResourceStatistics> |
getUriStatistics()
Get the statistics for each URI that is exposed in the application. |
MonitoringStatistics |
snapshot()
Get the immutable consistent snapshot of the monitoring statistics. |
| Method Detail |
|---|
Map<String,ResourceStatistics> getUriStatistics()
resource statistics that contain information about
execution of resource methods available on the URI. The map contain URIs that are available in
application without URIs available in sub resource locators and URIs that are available trough sub
resource locators and were already matched by any request.
Map<Class<?>,ResourceStatistics> getResourceClassStatistics()
Class that is deployed in the application. Keys of returned
map are classes of resources and values are resource statistics
that contain information about
execution of resource methods available in the resource class. Note that one resource class can serve
request matched to different URIs. By default the map will contain resource classes which are registered
in the resource model plus resource classes of sub resources returned from sub resource locators.
ExecutionStatistics getRequestStatistics()
ResponseStatistics getResponseStatistics()
ApplicationStatistics getApplicationStatistics()
ExceptionMapperStatistics getExceptionMapperStatistics()
exception mappers.
MonitoringStatistics snapshot()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||