public interface MonitoringStatistics
MonitoringStatisticsListener
. The following is the example of statistic injection:
@Path("resource") public static class StatisticsTest { @Inject Provider<MonitoringStatistics> statistics; @GET public long getTotalExceptionMappings() throws InterruptedException { final MonitoringStatistics monitoringStatistics = statistics.get(); final long totalExceptionMappings = monitoringStatistics.getExceptionMapperStatistics().getTotalMappings(); return totalExceptionMappings; } }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.
Modifier and Type | Method and Description |
---|---|
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()
Deprecated.
implementing class is immutable hence snapshot creation is not needed anymore
|
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()
ExceptionMapperStatistics getExceptionMapperStatistics()
exception mappers
.@Deprecated MonitoringStatistics snapshot()
Copyright © 2007-2021, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.