Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Jetty/Tutorial/Statistics"

(2 intermediate revisions by the same user not shown)
Line 21: Line 21:
 
===Request Statistics===
 
===Request Statistics===
  
To collect request statistics a StatisticsHandler must be configured as one of the handlers of the server. Typically this can be done as the top level handler, but you may choose to configure a statistics handler for just one context by creating a context configuration file.  The following jetty.xml fragment shows how to configure a top level statistics handler:
+
To collect request statistics a StatisticsHandler must be configured as one of the handlers of the server. Typically this can be done as the top level handler, but you may choose to configure a statistics handler for just one context by creating a context configuration file. Jetty distribution contains a configuration file etc/jetty-stats.xml that allows injecting the StatisticsHandler into existing jetty configuration by specifying it on the command line. Please note that jetty-stats.xml has to appear in the command line '''after''' the main Jetty configuration file as shown below.
 +
 
 +
  > java -jar start.jar OPTIONS=default etc/jetty.xml etc/jetty-stats.xml
 +
 
 +
Alternately, if you are making multiple changes to the Jetty configuration, you could include statistics handler configuration into your jetty.xml. The following fragment shows how to configure a top level statistics handler:
  
 
<source lang="xml">
 
<source lang="xml">
Line 43: Line 47:
 
</Set>
 
</Set>
 
</source>
 
</source>
 +
 +
===Session Statistics===
 +
 +
Session statistics are enabled by default and do not need to be configured.
  
 
| more =  
 
| more =  

Revision as of 10:59, 17 February 2010



Introduction

Jetty allows collecting several types of statistics. This tutorial shows how to configure Jetty to enable collecting statistics, although it is not recommended and it is best to use a JMX agent to select statistics only when needed.

Details

Connector statistics

The following example shows how to turn on connector statistics in jetty.xml.

<Item>
  <New class="org.mortbay.jetty.nio.SelectChannelConnector">
    <Set name="port">8080</Set>
    <Set name="maxIdleTime">30000</Set>
    <Set name="lowResourceMaxIdleTime">3000</Set>
    <Set name="Acceptors">1</Set>
    <Set name="StatsOn">true</Set>
  </New>
</Item>

Request Statistics

To collect request statistics a StatisticsHandler must be configured as one of the handlers of the server. Typically this can be done as the top level handler, but you may choose to configure a statistics handler for just one context by creating a context configuration file. Jetty distribution contains a configuration file etc/jetty-stats.xml that allows injecting the StatisticsHandler into existing jetty configuration by specifying it on the command line. Please note that jetty-stats.xml has to appear in the command line after the main Jetty configuration file as shown below.

> java -jar start.jar OPTIONS=default etc/jetty.xml etc/jetty-stats.xml

Alternately, if you are making multiple changes to the Jetty configuration, you could include statistics handler configuration into your jetty.xml. The following fragment shows how to configure a top level statistics handler:

<!-- =========================================================== -->
<!-- Set handler Collection Structure                            -->
<!-- =========================================================== -->
<Set name="handler">
  <New class="org.mortbay.jetty.handler.StatisticsHandler">
    <Set name="handler">
      <New id="handlers" class="org.mortbay.jetty.handler.HandlerCollection">
        <Set name="handlers">
         <Array type="org.mortbay.jetty.Handler">
           <Item><New id="contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/></Item>
           <Item><New id="defaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/></Item>
           <Item><New id="requestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/></Item>
         </Array>
        </Set>
      </New>
    </Set>
  </New>
</Set>

Session Statistics

Session statistics are enabled by default and do not need to be configured.

Additional Resources

See Jetty JMX tutorial for instructions on how to configure Jetty JMX integration.

Copyright © Eclipse Foundation, Inc. All Rights Reserved.