Package org.eclipse.jetty.server.handler
Class StatisticsHandler
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.handler.AbstractHandler
org.eclipse.jetty.server.handler.AbstractHandlerContainer
org.eclipse.jetty.server.handler.HandlerWrapper
org.eclipse.jetty.server.handler.StatisticsHandler
- All Implemented Interfaces:
Handler,HandlerContainer,Container,Destroyable,Dumpable,Dumpable.DumpableContainer,Graceful,LifeCycle
@ManagedObject("Request Statistics Gathering")
public class StatisticsHandler
extends HandlerWrapper
implements Graceful
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.AbstractHandler
AbstractHandler.ErrorDispatchHandlerNested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Graceful
Graceful.ShutdownNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LongAdderprivate final CounterStatisticprivate final CounterStatisticprivate final SampleStatisticprivate final LongAdderprivate final LongAdderprivate booleanprivate final javax.servlet.AsyncListenerprivate final CounterStatisticprivate final SampleStatisticprivate final LongAdderprivate final LongAdderprivate final LongAdderprivate final LongAdderprivate final LongAdderprivate final LongAdderprivate final Graceful.Shutdownprivate final AtomicLongprivate static final LoggerFields inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
_handler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart()Starts the managed lifecycle beans in the order they were added.protected voiddoStop()Stops the managed lifecycle beans in the reverse order they were added.intintintintintintintlongdoubledoublelongintintbooleanintintintlongdoubledoublelongintintintintintlonglongvoidhandle(String path, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Handle a request.booleanvoidsetGracefulShutdownWaitsForRequests(boolean gracefulShutdownWaitsForRequests) Set whether the graceful shutdown should wait for all requests to complete including async requests which are not currently dispatched, or whether it should only wait for all the actively dispatched requests to complete.shutdown()voidResets the current request statistics.toString()protected voidupdateResponse(Request request) Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
destroy, expandChildren, getHandler, getHandlers, insertHandler, setHandlerMethods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer
doShutdown, expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServerMethods inherited from class org.eclipse.jetty.server.handler.AbstractHandler
doError, getServerMethods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpableMethods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
Field Details
-
LOG
-
_statsStartedAt
-
_requestStats
-
_requestTimeStats
-
_dispatchedStats
-
_dispatchedTimeStats
-
_asyncWaitStats
-
_asyncDispatches
-
_expires
-
_errors
-
_responses1xx
-
_responses2xx
-
_responses3xx
-
_responses4xx
-
_responses5xx
-
_responsesTotalBytes
-
_gracefulShutdownWaitsForRequests
private boolean _gracefulShutdownWaitsForRequests -
_shutdown
-
_onCompletion
private final javax.servlet.AsyncListener _onCompletion
-
-
Constructor Details
-
StatisticsHandler
public StatisticsHandler()
-
-
Method Details
-
statsReset
Resets the current request statistics. -
handle
public void handle(String path, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException Description copied from interface:HandlerHandle a request.- Specified by:
handlein interfaceHandler- Overrides:
handlein classHandlerWrapper- Parameters:
path- The target of the request - either a URI or a name.baseRequest- The original unwrapped request object.request- The request either as theRequestobject or a wrapper of that request. Themethod can be used access the Request object if required.HttpConnection.getCurrentConnection().getHttpChannel().getRequest()response- The response as theResponseobject or a wrapper of that request. Themethod can be used access the Response object if required.HttpConnection.getCurrentConnection().getHttpChannel().getResponse()- Throws:
IOException- if unable to handle the request or response processingjavax.servlet.ServletException- if unable to handle the request or response due to underlying servlet issue
-
updateResponse
-
doStart
Description copied from class:ContainerLifeCycleStarts the managed lifecycle beans in the order they were added.- Overrides:
doStartin classAbstractHandler- Throws:
Exception
-
doStop
Description copied from class:ContainerLifeCycleStops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStopin classAbstractHandler- Throws:
Exception
-
setGracefulShutdownWaitsForRequests
public void setGracefulShutdownWaitsForRequests(boolean gracefulShutdownWaitsForRequests) Set whether the graceful shutdown should wait for all requests to complete including async requests which are not currently dispatched, or whether it should only wait for all the actively dispatched requests to complete.- Parameters:
gracefulShutdownWaitsForRequests- true to wait for async requests on graceful shutdown.
-
getGracefulShutdownWaitsForRequests
@ManagedAttribute("if graceful shutdown will wait for all requests") public boolean getGracefulShutdownWaitsForRequests()- Returns:
- whether the graceful shutdown will wait for all requests to complete including async requests which are not currently dispatched, or whether it will only wait for all the actively dispatched requests to complete.
- See Also:
-
getRequests
- Returns:
- the number of requests handled by this handler
since
statsReset()was last called, excluding active requests - See Also:
-
getRequestsActive
- Returns:
- the number of requests currently active.
since
statsReset()was last called.
-
getRequestsActiveMax
- Returns:
- the maximum number of active requests
since
statsReset()was last called.
-
getRequestTimeMax
- Returns:
- the maximum time (in milliseconds) of request handling
since
statsReset()was last called.
-
getRequestTimeTotal
@ManagedAttribute("total time spend in all request handling (in ms)") public long getRequestTimeTotal()- Returns:
- the total time (in milliseconds) of requests handling
since
statsReset()was last called.
-
getRequestTimeMean
- Returns:
- the mean time (in milliseconds) of request handling
since
statsReset()was last called. - See Also:
-
getRequestTimeStdDev
@ManagedAttribute("standard deviation for request handling (in ms)") public double getRequestTimeStdDev()- Returns:
- the standard deviation of time (in milliseconds) of request handling
since
statsReset()was last called. - See Also:
-
getDispatched
- Returns:
- the number of dispatches seen by this handler
since
statsReset()was last called, excluding active dispatches
-
getDispatchedActive
- Returns:
- the number of dispatches currently in this handler
since
statsReset()was last called, including resumed requests
-
getDispatchedActiveMax
@ManagedAttribute("maximum number of active dispatches being handled") public int getDispatchedActiveMax()- Returns:
- the max number of dispatches currently in this handler
since
statsReset()was last called, including resumed requests
-
getDispatchedTimeMax
- Returns:
- the maximum time (in milliseconds) of request dispatch
since
statsReset()was last called.
-
getDispatchedTimeTotal
@ManagedAttribute("total time spent in dispatch handling (in ms)") public long getDispatchedTimeTotal()- Returns:
- the total time (in milliseconds) of requests handling
since
statsReset()was last called.
-
getDispatchedTimeMean
@ManagedAttribute("mean time spent in dispatch handling (in ms)") public double getDispatchedTimeMean()- Returns:
- the mean time (in milliseconds) of request handling
since
statsReset()was last called. - See Also:
-
getDispatchedTimeStdDev
@ManagedAttribute("standard deviation for dispatch handling (in ms)") public double getDispatchedTimeStdDev()- Returns:
- the standard deviation of time (in milliseconds) of request handling
since
statsReset()was last called. - See Also:
-
getAsyncRequests
- Returns:
- the number of requests handled by this handler
since
statsReset()was last called, including resumed requests - See Also:
-
getAsyncRequestsWaiting
- Returns:
- the number of requests currently suspended.
since
statsReset()was last called.
-
getAsyncRequestsWaitingMax
@ManagedAttribute("maximum number of waiting async requests") public int getAsyncRequestsWaitingMax()- Returns:
- the maximum number of current suspended requests
since
statsReset()was last called.
-
getAsyncDispatches
@ManagedAttribute("number of requested that have been asynchronously dispatched") public int getAsyncDispatches()- Returns:
- the number of requests that have been asynchronously dispatched
-
getExpires
- Returns:
- the number of requests that expired while suspended.
- See Also:
-
getErrors
- Returns:
- the number of async errors that occurred.
- See Also:
-
getResponses1xx
- Returns:
- the number of responses with a 1xx status returned by this context
since
statsReset()was last called.
-
getResponses2xx
- Returns:
- the number of responses with a 2xx status returned by this context
since
statsReset()was last called.
-
getResponses3xx
- Returns:
- the number of responses with a 3xx status returned by this context
since
statsReset()was last called.
-
getResponses4xx
- Returns:
- the number of responses with a 4xx status returned by this context
since
statsReset()was last called.
-
getResponses5xx
- Returns:
- the number of responses with a 5xx status returned by this context
since
statsReset()was last called.
-
getStatsOnMs
- Returns:
- the milliseconds since the statistics were started with
statsReset().
-
getResponsesBytesTotal
@ManagedAttribute("total number of bytes across all responses") public long getResponsesBytesTotal()- Returns:
- the total bytes of content sent in responses
-
toStatsHTML
-
shutdown
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceGraceful
-
toString
- Overrides:
toStringin classAbstractLifeCycle
-