You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rm...@apache.org on 2013/08/01 13:12:53 UTC

svn commit: r1509169 [2/2] - in /commons/sandbox/monitoring/trunk: ./ aop/src/main/java/org/apache/commons/monitoring/aop/ aop/src/test/java/org/apache/commons/monitoring/aop/ aspectj/src/main/java/org/apache/commons/monitoring/aspectj/ aspectj/src/tes...

Modified: commons/sandbox/monitoring/trunk/spring/src/test/resources/monitoring.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/spring/src/test/resources/monitoring.xml?rev=1509169&r1=1509168&r2=1509169&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/spring/src/test/resources/monitoring.xml (original)
+++ commons/sandbox/monitoring/trunk/spring/src/test/resources/monitoring.xml Thu Aug  1 11:12:51 2013
@@ -22,18 +22,11 @@
 
   <bean id="service" class="org.apache.commons.monitoring.spring.service.MyService" />
 
-  <bean id="monitoringAdvisor" class="org.apache.commons.monitoring.spring.AopaliancePerformanceInterceptor" />
-
   <bean class="org.apache.commons.monitoring.spring.BeanNameMonitoringAutoProxyCreator">
     <property name="beanNames">
       <list>
         <value>service</value>
       </list>
     </property>
-    <property name="interceptorNames">
-      <list>
-        <value>monitoringAdvisor</value>
-      </list>
-    </property>
   </bean>
-</beans>
\ No newline at end of file
+</beans>

Modified: commons/sandbox/monitoring/trunk/src/site/xdoc/instrumentation.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/site/xdoc/instrumentation.xml?rev=1509169&r1=1509168&r2=1509169&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/site/xdoc/instrumentation.xml (original)
+++ commons/sandbox/monitoring/trunk/src/site/xdoc/instrumentation.xml Thu Aug  1 11:12:51 2013
@@ -37,7 +37,7 @@
     <section name="Concepts">
       <subsection name="Monitors">
         <p>
-          The application exposes it's state based on<b>monitors</b>. A monitor is an abstraction for any
+          The application exposes it's state based on<b>monitors</b>. A counter is an abstraction for any
           element in the application that can expose state or resource consumption. This can be a code
           fragment, a web application URI, a JDBC query, some business object data, etc. It is identified
           by :
@@ -53,7 +53,7 @@
             </li>
             <li>a
               <b>subsystem</b>
-              that associate the monitor to a functional subsystem in the application
+              that associate the counter to a functional subsystem in the application
               ("admin", "accounts management" ...)
             </li>
           </ul>
@@ -65,7 +65,7 @@
       </subsection>
       <subsection name="Repository">
         <p>
-          Monitors are registered in a repository, that ensure a monitor is unique for a name/category/subsytem
+          Monitors are registered in a repository, that ensure a counter is unique for a name/category/subsytem
           Key. The repository is used to retrieve existing monitors and create new ones. The
           <a href="xref/org/apache/commons/monitoring/impl/repositories/DefaultRepository">default repository
             implementation
@@ -73,9 +73,9 @@
           creates new Monitor instance when a non-existing one is requested, so you don't have to wory
           about monitors management.
           <pre>
-            Monitor monitor = repository.getMonitor( "MyService.myMethod" );
-            Monitor monitor = repository.getMonitor( "SoapEndpoint.process", "soap" );
-            Monitor monitor = repository.getMonitor( "/admin/userEdit.do", "struts", "user management" );
+            Monitor counter = repository.getMonitor( "MyService.myMethod" );
+            Monitor counter = repository.getMonitor( "SoapEndpoint.process", "soap" );
+            Monitor counter = repository.getMonitor( "/admin/userEdit.do", "struts", "user management" );
           </pre>
           You can use a custom repository by extending one of the provided implementations. You can also
           use the
@@ -89,7 +89,7 @@
           Monitors manage a set of
           <code>Metrics</code>
           that the application uses to expose state. The
-          monitor only identifies where the data comes from, and the statValues handle the monitored data.
+          counter only identifies where the data comes from, and the statValues handle the monitored data.
           There is two types of values that application can use, depending on the data to be exposed :
           <ul>
             <li>a
@@ -134,7 +134,7 @@
         </p>
         <p>The
           <a href="xref/org/apache/commons/monitoring/impl/monitors/CreateValuesOnDemandMonitor">
-            default monitor implementation
+            default counter implementation
           </a>
           will create the required Gauge/Counters implementation when a
           statValue is requested by the application.
@@ -142,14 +142,14 @@
       </subsection>
       <subsection name="Role">
         <p>
-          A monitor can handle many statValues. Metrics are identified in a monitor by a role, that
+          A counter can handle many statValues. Metrics are identified in a counter by a role, that
           describes the data beeing computed. There is predefined roles for performances, concurrency
-          monitoring and failures count, but any other relevant counter/gauge can be registered to a monitor.
+          monitoring and failures count, but any other relevant counter/gauge can be registered to a counter.
           <pre>
             final static Role BYTES = new Role( "bytes", Unit.BYTES, Counter.class );
 
-            static Monitor monitor = repository.getMonitor( "SoapEndpoint.process" );
-            static Counter bytes = monitor.getCounter( BYTES );
+            static Monitor counter = repository.getMonitor( "SoapEndpoint.process" );
+            static Counter bytes = counter.getCounter( BYTES );
 
             public void process( SOAPMessage message )
             {
@@ -161,7 +161,7 @@
           </pre>
           A role can be considered as a statValue prototype. It defines :
           <ul>
-            <li>The name of the statValue inside the monitor</li>
+            <li>The name of the statValue inside the counter</li>
             <li>The unit used for data gathered by the statValue</li>
             <li>The statValue type, beeing either
               <code>Counter.class</code>
@@ -189,8 +189,8 @@
         <p>Performance monitoring is first-class use case of Commons Monitoring. The
           <code>org.apache.commons.monitoring.stopwatches.StopWatch</code>
           class provides the necessary tooling
-          to compute and monitor code or service invocation performances. A StopWatch is created
-          by the repository for a monitor. The stopwatch is initialy "started", and will compute
+          to compute and counter code or service invocation performances. A StopWatch is created
+          by the repository for a counter. The stopwatch is initialy "started", and will compute
           elapsed time until it is stopped by the application. The application MUST ALLWAYS stop
           the StopWatches it has created ! To ensure this, always use a finally block :
           <pre>
@@ -208,7 +208,7 @@
         <p>
           You can nest stopWatches, in many case by monitoring some high-level process (for example web
           request rendering time) and nested low-level service (remote service invocation, JDBC request...).
-          The monitor maintains statistics about those informations as the PERFORMANCE and RESPONSE_TIME
+          The counter maintains statistics about those informations as the PERFORMANCE and RESPONSE_TIME
           counters. First one only computes performance of the target code, not sub-processes.
         </p>
         <p>
@@ -231,7 +231,7 @@
         The
         <b>Monitoring</b>
         class is a convenience utility class to make application instrumentation
-        as simple as possible. To monitor application performance, simply do :
+        as simple as possible. To counter application performance, simply do :
         <pre>
           public void myMethodToGetMonitored()
           {
@@ -247,7 +247,7 @@
           }
         </pre>
         The StopWatch class will compute the time elapsed during code execution and report it to the
-        monitor "MyClass.myMethod".
+        counter "MyClass.myMethod".
       </p>
       <p>
         Other helper classes are provided for simplier use with commons frameworks. The

Modified: commons/sandbox/monitoring/trunk/src/site/xdoc/listeners.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/site/xdoc/listeners.xml?rev=1509169&r1=1509168&r2=1509169&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/site/xdoc/listeners.xml (original)
+++ commons/sandbox/monitoring/trunk/src/site/xdoc/listeners.xml Thu Aug  1 11:12:51 2013
@@ -30,9 +30,9 @@
       </p>
       <p>
         For example, the application can switch between two implementations of a component depending
-        on the business process load. A monitor that computes this load can be used by the application to
+        on the business process load. A counter that computes this load can be used by the application to
         detect the overload and switch to a lightweight implementation. To implement this, the application
-        may use the monitor and programmatically (in a
+        may use the counter and programmatically (in a
         <code>if then else</code>
         block) select the
         implementation to use. A more elegant way is to attach a Listener to the Gauge that monitors the load.
@@ -48,7 +48,7 @@
       <p>
         <code>Monitor.Listener</code>
         allows the application to get evolved when a new Metric is registered
-        to the monitor. The application can register new statValues (or
+        to the counter. The application can register new statValues (or
         <em>automagically</em>
         creates new ones
         when requested) at any moment, and this listener can be used to get notified and pre-configure the
@@ -56,7 +56,7 @@
       </p>
       <p>
         <code>Repository.Listener</code>
-        can be used by the application to get notified any time a new monitor
+        can be used by the application to get notified any time a new counter
         instance is created, for example to register a Monitor.Listener !
       </p>
     </section>
@@ -67,7 +67,7 @@
         application scalability.
       </p>
       <p>
-        The StopWatches used to monitor execution can be registered in the
+        The StopWatches used to counter execution can be registered in the
         <code>ExecutionStack</code>
         utility
         class that maintain the set of active stopWatches for the current thread. It is recommended
@@ -93,7 +93,7 @@
         When a SecondaryRepository is created, it registers all the required listeners to maintain a set
         or secondary monitors / counters / gauges in sync with the "primary" repository.
         A secondary gauge will share the initial state of the primary gauge. A secondary counter will start
-        with initial value set to 0. The secondary repository can so be used to monitor the application during
+        with initial value set to 0. The secondary repository can so be used to counter the application during
         a period as if monitoring had just been reseted. It can then be detached from the primary repository,
         and will then not get notified anymore on application monitoring events.
       </p>

Modified: commons/sandbox/monitoring/trunk/src/site/xdoc/tutorial.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/site/xdoc/tutorial.xml?rev=1509169&r1=1509168&r2=1509169&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/site/xdoc/tutorial.xml (original)
+++ commons/sandbox/monitoring/trunk/src/site/xdoc/tutorial.xml Thu Aug  1 11:12:51 2013
@@ -29,7 +29,7 @@
         The
         <b>Monitoring</b>
         class is a convenience utility class to make application instrumentation
-        as simple as possible. To monitor application performance, simply do :
+        as simple as possible. To counter application performance, simply do :
         <pre>
           public void myMethodToGetMonitored()
           {
@@ -45,7 +45,7 @@
           }
         </pre>
         The StopWatch class will compute the time elapsed during code execution and report it to the
-        monitor "MyClass.myMethod".
+        counter "MyClass.myMethod".
       </p>
     </section>
     <section name="Instrumentation">
@@ -53,14 +53,14 @@
         A
         <b>Monitor</b>
         defines a control point in the application. It can be associated to a resource,
-        a code fragment or anything relevant for the application. The monitor is unique and retrieved from
+        a code fragment or anything relevant for the application. The counter is unique and retrieved from
         a<b>Repository</b>. It is identified by a name, a category (technical description of the application
         component) and a subsystem (functional description). In the previous code sample, only a name was set
         as category and subsystem are optional. We recommend to use them to create monitors as this is a
         convenient and powerful way to group and sort monitors and associated statistics.
       </p>
       <p>
-        The monitor maintains a set of Metrics, that can be either
+        The counter maintains a set of Metrics, that can be either
         <b>Counters</b>
         or<b>Gauges</b>.
         <ul>
@@ -69,18 +69,18 @@
           </li>
           <li>A Gauge allows the application to expose how a resource is used : active connections...</li>
         </ul>
-        Each Metric is identified by a ROLE in the monitor. Default roles are defined for PERFORMANCES and
-        CONCURRENCY (threads running same code), and you can register Counters/Gauges for custom roles to monitor
+        Each Metric is identified by a ROLE in the counter. Default roles are defined for PERFORMANCES and
+        CONCURRENCY (threads running same code), and you can register Counters/Gauges for custom roles to counter
         anything that is relevant for your application (bytes processed, message payload, account balance ...) :
         <pre>
-          Monitor monitor = repository.getMonitor( "SoapEndpoint.process", "soap" );
+          Monitor counter = repository.getMonitor( "SoapEndpoint.process", "soap" );
 
           // Process a SOAP message
-          monitor.getCounter( "bytes" ).add( SOAPMessage.getSize() );
+          counter.getCounter( "bytes" ).add( SOAPMessage.getSize() );
         </pre>
       </p>
       <p>
-        Commons Monitoring provides Helpers to instrument application, for example to monitor web application
+        Commons Monitoring provides Helpers to instrument application, for example to counter web application
         Request or JDBC operations, so that in many case you don't have to know commons-monitoring API to
         get basic instrumentation on your application.
       </p>

Modified: commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml?rev=1509169&r1=1509168&r2=1509169&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml (original)
+++ commons/sandbox/monitoring/trunk/src/site/xdoc/web.xml Thu Aug  1 11:12:51 2013
@@ -46,7 +46,7 @@
             &lt;/filter-mapping&gt;
           </pre>
           Any incoming request will then be monitored and added to the repository.
-          The monitor name is the requested URI path, and the extension is used to select a category.
+          The counter name is the requested URI path, and the extension is used to select a category.
         </p>
       </subsection>
       <subsection name="MonitoringServlet">

Modified: commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/jsp/StartTag.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/jsp/StartTag.java?rev=1509169&r1=1509168&r2=1509169&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/jsp/StartTag.java (original)
+++ commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/jsp/StartTag.java Thu Aug  1 11:12:51 2013
@@ -17,6 +17,8 @@
 
 package org.apache.commons.monitoring.web.jsp;
 
+import org.apache.commons.monitoring.Role;
+import org.apache.commons.monitoring.counter.Counter;
 import org.apache.commons.monitoring.repositories.Repository;
 import org.apache.commons.monitoring.stopwatches.StopWatch;
 
@@ -26,7 +28,7 @@ import javax.servlet.jsp.tagext.TagSuppo
 import static org.apache.commons.monitoring.web.jsp.TagUtils.getScope;
 
 /**
- * A JSP tag to monitor JSP rendering performances
+ * A JSP tag to counter JSP rendering performances
  *
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */
@@ -34,8 +36,6 @@ public class StartTag extends TagSupport
     private String id;
     private String scope;
     private String name;
-    private String category;
-    protected String repository;
 
     public void setId(String id) {
         this.id = id;
@@ -43,7 +43,7 @@ public class StartTag extends TagSupport
 
     @Override
     public int doStartTag() throws JspException {
-        final StopWatch stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getMonitor(name, category));
+        final StopWatch stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getCounter(new Counter.Key(Role.JSP, name)));
         if (scope != null) {
             pageContext.setAttribute(id, stopWatch, getScope(scope));
         } else {
@@ -52,24 +52,11 @@ public class StartTag extends TagSupport
         return EVAL_PAGE;
     }
 
-    /**
-     * @param scope the scope to set
-     */
     public void setScope(String scope) {
         this.scope = scope;
     }
 
-    /**
-     * @param name the name to set
-     */
     public void setName(String name) {
         this.name = name;
     }
-
-    /**
-     * @param category the category to set
-     */
-    public void setCategory(String category) {
-        this.category = category;
-    }
 }

Modified: commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/jsp/StopTag.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/jsp/StopTag.java?rev=1509169&r1=1509168&r2=1509169&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/jsp/StopTag.java (original)
+++ commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/jsp/StopTag.java Thu Aug  1 11:12:51 2013
@@ -25,7 +25,7 @@ import javax.servlet.jsp.tagext.TagSuppo
 import static org.apache.commons.monitoring.web.jsp.TagUtils.getScope;
 
 /**
- * A JSP tag to monitor JSP rendering performances
+ * A JSP tag to counter JSP rendering performances
  *
  * @author <a href="mailto:nicolas@apache.org">Nicolas De Loof</a>
  */

Modified: commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/servlet/MonitoringFilter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/servlet/MonitoringFilter.java?rev=1509169&r1=1509168&r2=1509169&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/servlet/MonitoringFilter.java (original)
+++ commons/sandbox/monitoring/trunk/web/src/main/java/org/apache/commons/monitoring/web/servlet/MonitoringFilter.java Thu Aug  1 11:12:51 2013
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.monitoring.web.servlet;
 
+import org.apache.commons.monitoring.Role;
+import org.apache.commons.monitoring.counter.Counter;
 import org.apache.commons.monitoring.repositories.Repository;
 import org.apache.commons.monitoring.stopwatches.StopWatch;
 
@@ -30,7 +32,10 @@ import javax.servlet.http.HttpServletRes
 import java.io.IOException;
 
 public class MonitoringFilter implements Filter {
-    private String category;
+    @Override
+    public void init(final FilterConfig filterConfig) throws ServletException {
+        // no-op
+    }
 
     @Override
     public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
@@ -44,10 +49,14 @@ public class MonitoringFilter implements
         }
     }
 
+    @Override
+    public void destroy() {
+        // no-op
+    }
+
     protected void doFilter(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws IOException, ServletException {
         final String uri = getRequestedUri(request);
-        final String category = getCategory(uri);
-        final StopWatch stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getMonitor(uri, category));
+        final StopWatch stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getCounter(new Counter.Key(Role.WEB, uri)));
         try {
             chain.doFilter(request, response);
         } finally {
@@ -60,21 +69,4 @@ public class MonitoringFilter implements
         final String context = request.getContextPath();
         return uri.substring(context.length());
     }
-
-    protected String getCategory(final String uri) {
-        return category;
-    }
-
-    @Override
-    public void init(final FilterConfig config) throws ServletException {
-        category = config.getInitParameter("category");
-        if (category == null) {
-            category = "web";
-        }
-    }
-
-    @Override
-    public void destroy() {
-        // Nop
-    }
 }
\ No newline at end of file